diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..b7ca95b5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# JS files must always use LF for tools to work +*.js eol=lf diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 00000000..e893c62e --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,30 @@ +name: PHP Composer + +on: + push: + pull_request: + +jobs: + run: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: + - "7.4" + - "8.0" + - "8.1" + - "8.2" + + name: Lint PHP ${{ matrix.php-version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP version + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - run: composer install + - run: composer test diff --git a/.gitignore b/.gitignore index a9edc003..1bcabeb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,4 @@ -gw-resources/* -blogs.dir/* -# Mac OS X Files -.DS_Store -# Thumbnails -._* -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - - -# Windows Files -# image file caches -Thumbs.db -# Folder config file -Desktop.ini -jQuery Themes.esproj +/gw-resources/* +/blogs.dir/* +/vendor/ +/composer.lock diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..1f2f86fe --- /dev/null +++ b/.mailmap @@ -0,0 +1 @@ +Michał Gołębiowski-Owczarek diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..089b211a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,22 @@ +# Contributing + +Welcome! Thanks for your interest in contributing to jquery-wp-content. More information on how to contribute to this and other projects is over at [contribute.jquery.org](https://contribute.jquery.org). You'll definitely want to take a look at the articles on contributing [to our websites](https://contribute.jquery.org/web-sites/) and [code](https://contribute.jquery.org/code). + +You may also want to take a look at our [commit & pull request guide](https://contribute.jquery.org/commits-and-pull-requests/) and [style guides](https://contribute.jquery.org/style-guide/) for instructions on how to maintain your fork and submit your code. Before we can merge any pull request, we'll also need you to sign our [contributor license agreement](https://contribute.jquery.org/cla). + +You can [Chat on Gitter](https://gitter.im/jquery/dev), should you have any questions. If you've never contributed to open source before, we've put together [a short guide with tips, tricks, and ideas on getting started](https://contribute.jquery.org/open-source/). + +## Code knowledge + +### Protocol-relative URLs + +As of 2023, we run with the default WordPress settings to formatting and cleaning URLs. If revisiting this in the future, consider the following constraints: + +* When accessing sites in older browsers over HTTP instead of HTTPS, references to theme assets (e.g. stylesheets) must either use the current scheme, or use a protocol-relative URL, or be an absolute path URL without protocol or hostname (`theme_root_uri`). + +* Intra-site links to pages and categories should generally use a path or the canonical URL. + +* Avoid stripping the protocol from a `clean_url` filter as various uses require a full URL: + * Server-side requests, such as for `downloads.wordpress.org`, must specify an explicit protocol in the URL. + * When building `/wp-sitemap.xml`, URLs must be full and with the canonical protocol explicitly set. Sitemaps are invalid if they contain relative URLs. + * When outputting `` via `wp_head/rel_canonical`, the URL must be full and canonical. Or `rel_canonical` must be remove_action'ed replaced with a custom version that calls `esc_attr()` instead of `esc_url()` to avoid the `clean_url` filter. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..7d5393a1 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,278 @@ + 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. diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 00000000..d78dca0d --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,52 @@ +Copyright jQuery Foundation and other contributors, https://github.com/jquery/jquery-wp-content + +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. + +==== + +- Cairo + https://github.com/Gue3bara/Cairo + located at themes/jquery/lib/Cairo + +- Disable Emojis + https://wordpress.org/plugins/disable-emojis/ + located at plugins/disable-emojis + +- Font Awesome + https://fontawesome.com/v3/ + located at themes/jquery/lib/FontAwesome + and included in themes/jquery/css/base.css + +- Gilded Wordpress + https://github.com/scottgonzalez/grunt-wordpress + located at plugins/gilded-wordpress + +- Memcached + https://wordpress.org/plugins/memcached/ + https://github.com/Automattic/wp-memcached/tree/35e1ea16f6b8cb8a1e6fbca124e33a44db21fa74 (2023-12-11) + located at plugins/memcached/ + +- No Comments on Pages + https://wordpress.org/plugins/no-comments-on-pages/ + located at plugins/no-comments-on-pages + +- Normalize.css + https://github.com/necolas/normalize.css/tree/v1.0.1 + located at themes/jquery/lib/normalize + and included in themes/jquery/css/base.css + +- typesense-minibar + https://github.com/jquery/typesense-minibar + located at themes/jquery/lib/typesense-minibar diff --git a/README.md b/README.md index 7d5a676d..9de076af 100644 --- a/README.md +++ b/README.md @@ -1,130 +1,22 @@ -# jQuery.com jquery-wp-content +# jquery-wp-content -This is a set of plugins, themes, and configuration files for jQuery's website infrastructure, which is powered by WordPress. It is designed as a custom content directory. So think of `jquery-wp-content` as your `wp-content` directory. +This repository provisions the `wp-content` directory of a WordPress installation, with the themes, plugins, and site options for jQuery Project websites. -## Prerequisites +## Getting started -This install guide assumes you already have certain prerequisites already configured within your environment. +### Production -* Apache -* Mysql -* PHP +To learn how the sites are managed in production, refer to +. -## Installation +### Staging -1. Configure your local webserver with a virtual host that covers the relevant jQuery domains, such as `*.jquery.com` and `*.jqueryui.com`, all pointing to the same root. For example, in Apache: +Changes pushed to the `main` branch of this repository are automatically +pulled onto the staging servers, which are publicly reachable via the +`stage.*` subdomains of the live sites. For example, the staging site +for is served at - ``` - - ServerName local.jquery.com - ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.qunitjs.com *.sizzlejs.com *.jquerymobile.com - DocumentRoot "/srv/www/jquery" - - Options All - AllowOverride All - Order allow,deny - Allow from all - - - ``` +## Local - Make sure that virtual hosts are enabled as well: - - ``` - NameVirtualHost *:80 - ``` - - Both blocks of code should be pasted into `extra/httpd-vhosts.conf`. - Be sure to check `httpd.conf` to verify there is a line that includes - `httpd-vhosts.conf`. It may already exist, but be commented out. - - You do not need to configure your `/etc/hosts` file for `local.*` because `jquery.com`'s DNS handles this for you. - -1. Place the WordPress core files **at** the document root you chose. For example, if you used `/srv/www/jquery`, you should unzip or clone WordPress directly into that directory, *not* a directory below it. **Do not install WordPress.** You can do this any number of ways: - * Download the latest version from http://wordpress.org/latest.zip - * Check out the latest tag from http://core.svn.wordpress.org/tags/ - * Clone the official WordPress Github mirror at http://github.com/wordpress/wordpress/ - -1. Clone `jquery-wp-content` inside of the directory where you put WordPress, so you have a file tree that looks like this: - - ``` - ├── jquery - │   ├── gw-resources - │   ├── index.php - │   ├── jquery-wp-content - │   ├── license.txt - │   ├── readme.html - │   ├── wp-activate.php - │   ├── wp-admin - │   ├── wp-blog-header.php - │   ├── wp-comments-post.php - │   ├── wp-config-sample.php - │   ├── wp-content - │   ├── ... - │   └── xmlrpc.php - ``` - -1. Copy `jquery-wp-content/wp-config-sample.php` and move it up one directory, to `wp-config.php`. Fill in your database credentials. - -1. Create an .htaccess file with the following content into that same document root: - - ``` - RewriteEngine On - RewriteBase / - RewriteRule ^index\.php$ - [L] - - RewriteRule ^resources/?$ index.php [L] - RewriteRule ^resources/(.+) gw-resources/%{HTTP_HOST}/$1 [L] - - # Add a trailing slash to the wp-admin of a subsite. - RewriteRule ^([_0-9a-zA-Z\.-]+/)?wp-admin$ $1wp-admin/ [R=301,L] - - RewriteCond %{REQUEST_FILENAME} -f [OR] - RewriteCond %{REQUEST_FILENAME} -d - RewriteRule ^ - [L] - - # Handle wp-admin, wp-includes, and root PHP files for subsites. - RewriteRule ^[_0-9a-zA-Z\.-]+/((wp-admin|wp-includes).*) $1 [L] - RewriteRule ^[_0-9a-zA-Z\.-]+/(.*\.php)$ $1 [L] - - RewriteRule . index.php [L] - ``` - -1. Make sure that you have assigned your WordPress files and directories the correct permissions. -For example, if your WordPress files are in the directory ```wordpress```, and you are running Apache under Mac OS X with the ```_www``` user: - - ``` - sudo chown -R _www wordpress - sudo chmod -R g+w wordpress - ``` - -1. Go to `http://local.jquery.com` and walk through the standard WordPress installation. `jquery-wp-content` includes a special install script that will initialize the entire network. - -1. Be sure to have node >= 0.8 installed on your system. Some sites, such as download.jqueryui.com, require that version or greater. - -## Auto-Updates -Changes pushed to master will be pulled onto the stage domain. - -## Copyright - -Copyright 2013 jQuery Foundation and other contributors. All rights reserved. - -The `jquery-wp-content` repository contains themes for rendering all jQuery Foundation web sites. - -### What is licensed - -The contents of the web sites that run on top of `jquery-wp-content` are all available under the terms of the MIT license ( http://jquery.org/license ). - -Special exception: Code samples are given away for you to freely use, for any purpose. For code samples in API sites -and Learn articles (unlike the source code of jQuery projects) you don't even have to say where you got the code from. -Just use it. - -The PHP files in the `jquery-wp-content` repository are a derivative work of WordPress, and available under the -terms of the GPL license ( http://codex.wordpress.org/License ). - -### What is not licensed - -The design, layout, and look-and-feel of the `jquery-wp-content` repository, including all CSS, images, and -icons, are copyright jQuery Foundation, Inc. and are not licensed for use. Designs and CSS from `jquery-wp-content` may not be used on any site, personal or commerical, without prior written consent from the jQuery Foundation. `jquery-wp-content` contains CSS, images, and icons that are copyrighted by other individuals; those items are licensed under their original terms. - -The only permitted (and encouraged) exception to "use" is the case of cloning/forking this repository in order to create a local development environment to facilitate making contributions to jQuery Foundation websites. +To help preview or debug changes locally during development, +you can use . diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..1da74c8f --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "require": { + "php": ">= 7.4" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "1.3.2" + }, + "scripts": { + "test": "parallel-lint --exclude vendor/ .", + "deps": [ + "curl -O -q --output-dir themes/jquery/lib/typesense-minibar 'https://raw.githubusercontent.com/jquery/typesense-minibar/1.3.4/{typesense-minibar.css,typesense-minibar.js,LICENSE.txt}'", + "curl -q https://raw.githubusercontent.com/jquery/typesense-minibar/1.3.4/typesense-minibar-foot.css >> themes/jquery/lib/typesense-minibar/typesense-minibar.css", + + "curl -O -q --output-dir plugins/memcached 'https://raw.githubusercontent.com/Automattic/wp-memcached/35e1ea16f6b8cb8a1e6fbca124e33a44db21fa74/{object-cache.php,readme.txt,LICENSE}'", + + "git rm -rf plugins/disable-emojis/", + "curl -s 'https://downloads.wordpress.org/plugin/disable-emojis.1.7.7.zip' | tar -xv -C plugins/", + "git add plugins/disable-emojis/" + ] + } +} diff --git a/config.php b/config.php deleted file mode 100644 index f968b0f1..00000000 --- a/config.php +++ /dev/null @@ -1,93 +0,0 @@ -set_role( 'administrator' ); - - $guess_url = wp_guess_url(); - - foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) - $wpdb->$table = $prefixed_table; - - install_network(); - populate_network( 1, $domain, $user_email, 'jQuery Network', $base, false ); - - update_site_option( 'site_admins', array( $user->user_login ) ); - update_site_option( 'allowedthemes', array() ); - - $wpdb->insert( $wpdb->blogs, array( 'site_id' => 1, 'domain' => $domain, 'path' => $base, 'registered' => current_time( 'mysql' ) ) ); - $blog_id = $wpdb->insert_id; - update_user_meta( $user_id, 'source_domain', $domain ); - update_user_meta( $user_id, 'primary_blog', $blog_id ); - if ( !$upload_path = get_option( 'upload_path' ) ) { - $upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads'; - update_option( 'upload_path', $upload_path ); - } - update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path ); - - foreach ( jquery_sites() as $site => $details ) - jquery_install_site( $site, $user ); - - wp_new_blog_notification( $blog_title, $guess_url, $user_id, $message = __( 'The password you chose during the install.' ) ); - wp_cache_flush(); - - return array( 'url' => $guess_url, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message ); -} - -function jquery_install_site( $site, $user ) { - $sites = jquery_sites(); - $details = $sites[ $site ]; - - if ( strpos( $site, '/' ) ) { - list( $domain, $path ) = explode( '/', $site, 2 ); - $path = '/' . trim( $path, '/' ) . '/'; - } else { - $domain = $site; - $path = '/'; - } - - $default_options = jquery_default_site_options(); - $default_options['admin_email'] = $user->user_email; - - if ( 1 !== $details['blog_id'] ) { - $blog_id = insert_blog( JQUERY_STAGING_PREFIX . $domain, $path, 1 ); - if ( $blog_id != $details['blog_id'] ) - wp_die( "Something went very wrong when trying to install $domain as site $blog_id-{$details['blog_id']}. Find nacin." ); - - switch_to_blog( $blog_id ); - - install_blog( $blog_id, $details['options']['blogname'] ); - - add_user_to_blog( $blog_id, $user->ID, 'administrator' ); - } - - $options = array_merge( $default_options, $details['options'] ); - foreach ( $options as $option => $value ) - update_option( $option, $value ); - - delete_option( 'rewrite_rules' ); - restore_current_blog(); -} diff --git a/mu-plugins/_loader.php b/mu-plugins/_loader.php index d4bcd362..809d1240 100644 --- a/mu-plugins/_loader.php +++ b/mu-plugins/_loader.php @@ -1,15 +1,13 @@ 2 ) { - foreach ( (array) glob( dirname( __FILE__ ) . "/$subdomain-sites/*.php" ) as $type_specific_file ) { - require_once( $type_specific_file ); - } - } -} -unset( $live_domain, $subdomain, $domain_specific_file, $type_specific_file ); +// Plugins enabled everywhere for local dev (jquery-wp-docker) +// +// For production, plugin enablement is managed via Puppet: +// https://github.com/jquery/infrastructure-puppet/blob/staging/modules/profile/manifests/wordpress/docs.pp + +require_once __DIR__ . '/../plugins/disable-emojis/disable-emojis.php'; +require_once __DIR__ . '/../plugins/gilded-wordpress/gilded-wordpress.php'; +require_once __DIR__ . '/../plugins/jquery-actions.php'; +require_once __DIR__ . '/../plugins/jquery-filters.php'; +require_once __DIR__ . '/../plugins/jquery-tags-on-pages.php'; +require_once __DIR__ . '/../plugins/redirects.php'; diff --git a/mu-plugins/analytics.php b/mu-plugins/analytics.php deleted file mode 100644 index 6d3075ce..00000000 --- a/mu-plugins/analytics.php +++ /dev/null @@ -1,18 +0,0 @@ - - -is_main_query() || ! $query->is_search() ) - return $posts; - - $priorities = array_fill( 0, 4, array() ); - - $search_terms = $query->query_vars['search_terms']; - $search_terms = array_map( 'strtolower', $search_terms ); - foreach ( $posts as $post ) { - if ( strtolower( $post->post_title ) === implode( ' ', $search_terms ) ) { - // Perfect title match: Priority 0. - $priorities[0][] = $post; - continue; - } - - foreach ( array( 1 => 'post_title', 2 => 'post_excerpt' ) as $priority => $field ) { - foreach ( $search_terms as $search_term ) { - // A search term is not present in the field, so move to the next field. - if ( false === stripos( $post->$field, $search_term ) ) - continue 2; - } - - // Found all matching terms in this field, so add it to the respective priority. - $priorities[ $priority ][] = $post; - continue 2; - } - - // No matches in a priority field, so assume the post got here via the content. - $priorities[3][] = $post; - } - - return array_merge( $priorities[0], $priorities[1], $priorities[2], $priorities[3] ); -}, 10, 2 ); \ No newline at end of file diff --git a/mu-plugins/jquery-filters.php b/mu-plugins/jquery-filters.php deleted file mode 100644 index 45a7e5d9..00000000 --- a/mu-plugins/jquery-filters.php +++ /dev/null @@ -1,81 +0,0 @@ - $value ) { - if ( 'stylesheet' === $option || 'template' === $option ) - continue; // Don't mess with themes for now. - add_filter( 'pre_option_' . $option, function( $null ) use ( $value, $blog_id ) { - if ( $blog_id == get_current_blog_id() ) - return $value; - return $null; - } ); -} -unset( $sites, $options, $option ); - -// Disable WordPress auto-paragraphing for posts. -remove_filter( 'the_content', 'wpautop' ); - -// Disable WordPress text transformations (smart quotes, etc.) for posts. -remove_filter( 'the_content', 'wptexturize' ); - -// Disable more restrictive multisite upload settings. -remove_filter( 'upload_mimes', 'check_upload_mimes' ); -// Give unfiltered upload ability to super admins. -define( 'ALLOW_UNFILTERED_UPLOADS', true ); -// Until unfiltered uploads make it into XML-RPC: -add_filter( 'upload_mimes', function( $mimes ) { - $mimes['eot'] = 'application/vnd.ms-fontobject'; - $mimes['svg'] = 'image/svg+xml'; - $mimes['ttf'] = 'application/x-font-ttf'; - $mimes['woff'] = 'application/font-woff'; - $mimes['xml'] = 'text/xml'; - $mimes['php'] = 'application/x-php'; - $mimes['json'] = 'application/json'; - return $mimes; -} ); - -// Increase file size limit to 1GB -add_filter( 'pre_site_option_fileupload_maxk', function() { - return 1024 * 1024; -} ); - -// Allow full HTML in term descriptions. -add_action( 'init', 'jquery_unfiltered_html_for_term_descriptions' ); -add_action( 'set_current_user', 'jquery_unfiltered_html_for_term_descriptions' ); -function jquery_unfiltered_html_for_term_descriptions() { - remove_filter( 'pre_term_description', 'wp_filter_kses' ); - remove_filter( 'pre_term_description', 'wp_filter_post_kses' ); - if ( ! current_user_can( 'unfiltered_html' ) ) - add_filter( 'pre_term_description', 'wp_filter_post_kses' ); -} - -// Bypass multisite checks. -add_filter( 'ms_site_check', '__return_true' ); - -// Add body classes found in postmeta. -add_filter( 'body_class', function( $classes ) { - $sites = jquery_sites(); - if ( isset( $sites[ JQUERY_LIVE_SITE ]['body_class'] ) ) - array_unshift( $classes, $sites[ JQUERY_LIVE_SITE ]['body_class'] ); - if ( 0 === strpos( JQUERY_LIVE_SITE, 'api.' ) ) - array_unshift( $classes, 'api' ); - - if ( is_page() ) - $classes[] = 'page-slug-' . sanitize_html_class( strtolower( get_queried_object()->post_name ) ); - if ( is_singular() && $post_classes = get_post_meta( get_queried_object_id(), 'body_class', true ) ) - $classes = array_merge( $classes, explode( ' ', $post_classes ) ); - - if ( is_archive() || is_search() ) { - $classes[] = 'listing'; - } - - return $classes; -}); diff --git a/mu-plugins/jquery.org/lib/Stripe.php b/mu-plugins/jquery.org/lib/Stripe.php deleted file mode 100644 index 68658828..00000000 --- a/mu-plugins/jquery.org/lib/Stripe.php +++ /dev/null @@ -1,45 +0,0 @@ -_apiKey = $apiKey; - } - - public static function apiUrl($url='') - { - $apiBase = Stripe::$apiBase; - return "$apiBase$url"; - } - - public static function utf8($value) - { - if (is_string($value)) - return utf8_encode($value); - else - return $value; - } - - private static function _encodeObjects($d) - { - if ($d instanceof Stripe_ApiResource) { - return $d->id; - } else if ($d === true) { - return 'true'; - } else if ($d === false) { - return 'false'; - } else if (is_array($d)) { - $res = array(); - foreach ($d as $k => $v) - $res[$k] = self::_encodeObjects($v); - return $res; - } else { - return $d; - } - } - - public static function encode($d) - { - return http_build_query($d, null, '&'); - } - - public function request($meth, $url, $params=null) - { - if (!$params) - $params = array(); - list($rbody, $rcode, $myApiKey) = $this->_requestRaw($meth, $url, $params); - $resp = $this->_interpretResponse($rbody, $rcode); - return array($resp, $myApiKey); - } - - public function handleApiError($rbody, $rcode, $resp) - { - if (!is_array($resp) || !isset($resp['error'])) - throw new Stripe_ApiError("Invalid response object from API: $rbody (HTTP response code was $rcode)", $rcode, $rbody, $resp); - $error = $resp['error']; - switch ($rcode) { - case 400: - case 404: - throw new Stripe_InvalidRequestError(isset($error['message']) ? $error['message'] : null, - isset($error['param']) ? $error['param'] : null, - $rcode, $rbody, $resp); - case 401: - throw new Stripe_AuthenticationError(isset($error['message']) ? $error['message'] : null, $rcode, $rbody, $resp); - case 402: - throw new Stripe_CardError(isset($error['message']) ? $error['message'] : null, - isset($error['param']) ? $error['param'] : null, - isset($error['code']) ? $error['code'] : null, - $rcode, $rbody, $resp); - default: - throw new Stripe_ApiError(isset($error['message']) ? $error['message'] : null, $rcode, $rbody, $resp); - } - } - - private function _requestRaw($meth, $url, $params) - { - $myApiKey = $this->_apiKey; - if (!$myApiKey) - $myApiKey = Stripe::$apiKey; - if (!$myApiKey) - throw new Stripe_AuthenticationError('No API key provided. (HINT: set your API key using "Stripe::setApiKey()". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.'); - - $absUrl = $this->apiUrl($url); - $params = self::_encodeObjects($params); - $langVersion = phpversion(); - $uname = php_uname(); - $ua = array('bindings_version' => Stripe::VERSION, - 'lang' => 'php', - 'lang_version' => $langVersion, - 'publisher' => 'stripe', - 'uname' => $uname); - $headers = array('X-Stripe-Client-User-Agent: ' . json_encode($ua), - 'User-Agent: Stripe/v1 PhpBindings/' . Stripe::VERSION, - 'Authorization: Bearer ' . $myApiKey); - list($rbody, $rcode) = $this->_curlRequest($meth, $absUrl, $headers, $params); - return array($rbody, $rcode, $myApiKey); - } - - private function _interpretResponse($rbody, $rcode) - { - try { - $resp = json_decode($rbody, true); - } catch (Exception $e) { - throw new Stripe_ApiError("Invalid response body from API: $rbody (HTTP response code was $rcode)", $rcode, $rbody); - } - - if ($rcode < 200 || $rcode >= 300) { - $this->handleApiError($rbody, $rcode, $resp); - } - return $resp; - } - - private function _curlRequest($meth, $absUrl, $headers, $params) - { - $curl = curl_init(); - $meth = strtolower($meth); - $opts = array(); - if ($meth == 'get') { - $opts[CURLOPT_HTTPGET] = 1; - if (count($params) > 0) { - $encoded = self::encode($params); - $absUrl = "$absUrl?$encoded"; - } - } else if ($meth == 'post') { - $opts[CURLOPT_POST] = 1; - $opts[CURLOPT_POSTFIELDS] = self::encode($params); - } else if ($meth == 'delete') { - $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; - if (count($params) > 0) { - $encoded = self::encode($params); - $absUrl = "$absUrl?$encoded"; - } - } else { - throw new Stripe_ApiError("Unrecognized method $meth"); - } - - $absUrl = self::utf8($absUrl); - $opts[CURLOPT_URL] = $absUrl; - $opts[CURLOPT_RETURNTRANSFER] = true; - $opts[CURLOPT_CONNECTTIMEOUT] = 30; - $opts[CURLOPT_TIMEOUT] = 80; - $opts[CURLOPT_RETURNTRANSFER] = true; - $opts[CURLOPT_HTTPHEADER] = $headers; - if (!Stripe::$verifySslCerts) - $opts[CURLOPT_SSL_VERIFYPEER] = false; - - curl_setopt_array($curl, $opts); - $rbody = curl_exec($curl); - - $errno = curl_errno($curl); - if ($errno == CURLE_SSL_CACERT || - $errno == CURLE_SSL_PEER_CERTIFICATE || - $errno == 77 // CURLE_SSL_CACERT_BADFILE (constant not defined in PHP though) - ) { - array_push($headers, 'X-Stripe-Client-Info: {"ca":"using Stripe-supplied CA bundle"}'); - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - curl_setopt($curl, CURLOPT_CAINFO, - dirname(__FILE__) . '/../data/ca-certificates.crt'); - $rbody = curl_exec($curl); - } - - if ($rbody === false) { - $errno = curl_errno($curl); - $message = curl_error($curl); - curl_close($curl); - $this->handleCurlError($errno, $message); - } - - $rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - curl_close($curl); - return array($rbody, $rcode); - } - - public function handleCurlError($errno, $message) - { - $apiBase = Stripe::$apiBase; - switch ($errno) { - case CURLE_COULDNT_CONNECT: - case CURLE_COULDNT_RESOLVE_HOST: - case CURLE_OPERATION_TIMEOUTED: - $msg = "Could not connect to Stripe ($apiBase). Please check your internet connection and try again. If this problem persists, you should check Stripe's service status at https://twitter.com/stripestatus, or let us know at support@stripe.com."; - break; - case CURLE_SSL_CACERT: - case CURLE_SSL_PEER_CERTIFICATE: - $msg = "Could not verify Stripe's SSL certificate. Please make sure that your network is not intercepting certificates. (Try going to $apiBase in your browser.) If this problem persists, let us know at support@stripe.com."; - break; - default: - $msg = "Unexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com."; - } - - $msg .= "\n\n(Network error [errno $errno]: $message)"; - throw new Stripe_ApiConnectionError($msg); - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/ApiResource.php b/mu-plugins/jquery.org/lib/Stripe/ApiResource.php deleted file mode 100755 index 98be3eab..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/ApiResource.php +++ /dev/null @@ -1,104 +0,0 @@ -refresh(); - return $instance; - } - - public function refresh() - { - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $url = $this->instanceUrl(); - - list($response, $apiKey) = $requestor->request('get', $url); - $this->refreshFrom($response, $apiKey); - return $this; - } - - public static function className($class) - { - // Useful for namespaces: Foo\Stripe_Charge - if ($postfix = strrchr($class, '\\')) - $class = substr($postfix, 1); - if (substr($class, 0, strlen('Stripe')) == 'Stripe') - $class = substr($class, strlen('Stripe')); - $class = str_replace('_', '', $class); - $name = urlencode($class); - $name = strtolower($name); - return $name; - } - - public static function classUrl($class) - { - $base = self::className($class); - return "/v1/${base}s"; - } - - public function instanceUrl() - { - $id = $this['id']; - $class = get_class($this); - if (!$id) { - throw new Stripe_InvalidRequestError("Could not determine which URL to request: $class instance has invalid ID: $id", null); - } - $id = Stripe_ApiRequestor::utf8($id); - $base = self::classUrl($class); - $extn = urlencode($id); - return "$base/$extn"; - } - - private static function _validateCall($method, $params=null, $apiKey=null) - { - if ($params && !is_array($params)) - throw new Stripe_Error("You must pass an array as the first argument to Stripe API method calls. (HINT: an example call to create a charge would be: \"StripeCharge::create(array('amount' => 100, 'currency' => 'usd', 'card' => array('number' => 4242424242424242, 'exp_month' => 5, 'exp_year' => 2015)))\")"); - if ($apiKey && !is_string($apiKey)) - throw new Stripe_Error('The second argument to Stripe API method calls is an optional per-request apiKey, which must be a string. (HINT: you can set a global apiKey by "Stripe::setApiKey()")'); - } - - protected static function _scopedAll($class, $params=null, $apiKey=null) - { - self::_validateCall('all', $params, $apiKey); - $requestor = new Stripe_ApiRequestor($apiKey); - $url = self::classUrl($class); - list($response, $apiKey) = $requestor->request('get', $url, $params); - return Stripe_Util::convertToStripeObject($response, $apiKey); - } - - protected static function _scopedCreate($class, $params=null, $apiKey=null) - { - self::_validateCall('create', $params, $apiKey); - $requestor = new Stripe_ApiRequestor($apiKey); - $url = self::classUrl($class); - list($response, $apiKey) = $requestor->request('post', $url, $params); - return Stripe_Util::convertToStripeObject($response, $apiKey); - } - - protected function _scopedSave($class) - { - self::_validateCall('save'); - if ($this->_unsavedValues) { - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $params = array(); - foreach ($this->_unsavedValues->toArray() as $k) - $params[$k] = $this->$k; - $url = $this->instanceUrl(); - list($response, $apiKey) = $requestor->request('post', $url, $params); - $this->refreshFrom($response, $apiKey); - } - return $this; - } - - protected function _scopedDelete($class, $params=null) - { - self::_validateCall('delete'); - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $url = $this->instanceUrl(); - list($response, $apiKey) = $requestor->request('delete', $url, $params); - $this->refreshFrom($response, $apiKey); - return $this; - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/AuthenticationError.php b/mu-plugins/jquery.org/lib/Stripe/AuthenticationError.php deleted file mode 100755 index 0c820305..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/AuthenticationError.php +++ /dev/null @@ -1,5 +0,0 @@ -param = $param; - $this->code = $code; - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/Charge.php b/mu-plugins/jquery.org/lib/Stripe/Charge.php deleted file mode 100755 index ae5cda7c..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Charge.php +++ /dev/null @@ -1,55 +0,0 @@ -_apiKey); - $url = $this->instanceUrl() . '/refund'; - list($response, $apiKey) = $requestor->request('post', $url, $params); - $this->refreshFrom($response, $apiKey); - return $this; - } - - public function capture($params=null) - { - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $url = $this->instanceUrl() . '/capture'; - list($response, $apiKey) = $requestor->request('post', $url, $params); - $this->refreshFrom($response, $apiKey); - return $this; - } - - public function updateDispute($params=null) - { - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $url = $this->instanceUrl() . '/dispute'; - list($response, $apiKey) = $requestor->request('post', $url, $params); - $this->refreshFrom(array('dispute' => $response), $apiKey, true); - return $this->dispute; - } -} \ No newline at end of file diff --git a/mu-plugins/jquery.org/lib/Stripe/Coupon.php b/mu-plugins/jquery.org/lib/Stripe/Coupon.php deleted file mode 100755 index 9ead002c..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Coupon.php +++ /dev/null @@ -1,34 +0,0 @@ -id; - $ii = Stripe_InvoiceItem::create($params, $this->_apiKey); - return $ii; - } - - public function invoices($params=null) - { - if (!$params) - $params = array(); - $params['customer'] = $this->id; - $invoices = Stripe_Invoice::all($params, $this->_apiKey); - return $invoices; - } - - public function invoiceItems($params=null) - { - if (!$params) - $params = array(); - $params['customer'] = $this->id; - $iis = Stripe_InvoiceItem::all($params, $this->_apiKey); - return $iis; - } - - public function charges($params=null) - { - if (!$params) - $params = array(); - $params['customer'] = $this->id; - $charges = Stripe_Charge::all($params, $this->_apiKey); - return $charges; - } - - public function updateSubscription($params=null) - { - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $url = $this->instanceUrl() . '/subscription'; - list($response, $apiKey) = $requestor->request('post', $url, $params); - $this->refreshFrom(array('subscription' => $response), $apiKey, true); - return $this->subscription; - } - - public function cancelSubscription($params=null) - { - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $url = $this->instanceUrl() . '/subscription'; - list($response, $apiKey) = $requestor->request('delete', $url, $params); - $this->refreshFrom(array('subscription' => $response), $apiKey, true); - return $this->subscription; - } - - public function deleteDiscount() - { - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $url = $this->instanceUrl() . '/discount'; - list($response, $apiKey) = $requestor->request('delete', $url); - $this->refreshFrom(array('discount' => null), $apiKey, true); - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/Error.php b/mu-plugins/jquery.org/lib/Stripe/Error.php deleted file mode 100755 index 89619567..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Error.php +++ /dev/null @@ -1,27 +0,0 @@ -http_status = $http_status; - $this->http_body = $http_body; - $this->json_body = $json_body; - } - - public function getHttpStatus() - { - return $this->http_status; - } - - public function getHttpBody() - { - return $this->http_body; - } - - public function getJsonBody() - { - return $this->json_body; - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/Event.php b/mu-plugins/jquery.org/lib/Stripe/Event.php deleted file mode 100755 index 1c73bd1c..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Event.php +++ /dev/null @@ -1,22 +0,0 @@ -param = $param; - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/Invoice.php b/mu-plugins/jquery.org/lib/Stripe/Invoice.php deleted file mode 100755 index 458643ec..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Invoice.php +++ /dev/null @@ -1,51 +0,0 @@ -request('get', $url, $params); - return Stripe_Util::convertToStripeObject($response, $apiKey); - } - - public function save() - { - $class = get_class(); - return self::_scopedSave($class); - } - - public function pay() - { - $requestor = new Stripe_ApiRequestor($this->_apiKey); - $url = $this->instanceUrl() . '/pay'; - list($response, $apiKey) = $requestor->request('post', $url); - $this->refreshFrom($response, $apiKey); - return $this; - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/InvoiceItem.php b/mu-plugins/jquery.org/lib/Stripe/InvoiceItem.php deleted file mode 100755 index a93ddada..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/InvoiceItem.php +++ /dev/null @@ -1,40 +0,0 @@ -_apiKey); - list($response, $apiKey) = $requestor->request('get', $this['url'], $params); - return Stripe_Util::convertToStripeObject($response, $apiKey); - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/Object.php b/mu-plugins/jquery.org/lib/Stripe/Object.php deleted file mode 100755 index f334ca6d..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Object.php +++ /dev/null @@ -1,144 +0,0 @@ -_apiKey = $apiKey; - $this->_values = array(); - $this->_unsavedValues = new Stripe_Util_Set(); - $this->_transientValues = new Stripe_Util_Set(); - if ($id) - $this->id = $id; - } - - // Standard accessor magic methods - public function __set($k, $v) - { - // TODO: may want to clear from $_transientValues. (Won't be user-visible.) - $this->_values[$k] = $v; - if (!self::$_permanentAttributes->includes($k)) - $this->_unsavedValues->add($k); - } - public function __isset($k) - { - return isset($this->_values[$k]); - } - public function __unset($k) - { - unset($this->_values[$k]); - $this->_transientValues->add($k); - $this->_unsavedValues->discard($k); - } - public function __get($k) - { - if (array_key_exists($k, $this->_values)) { - return $this->_values[$k]; - } else if ($this->_transientValues->includes($k)) { - $class = get_class($this); - $attrs = join(', ', array_keys($this->_values)); - error_log("Stripe Notice: Undefined property of $class instance: $k. HINT: The $k attribute was set in the past, however. It was then wiped when refreshing the object with the result returned by Stripe's API, probably as a result of a save(). The attributes currently available on this object are: $attrs"); - return null; - } else { - $class = get_class($this); - error_log("Stripe Notice: Undefined property of $class instance: $k"); - return null; - } - } - - // ArrayAccess methods - public function offsetSet($k, $v) - { - $this->$k = $v; - } - - public function offsetExists($k) - { - return array_key_exists($k, $this->_values); - } - - public function offsetUnset($k) - { - unset($this->$k); - } - public function offsetGet($k) - { - return array_key_exists($k, $this->_values) ? $this->_values[$k] : null; - } - - // This unfortunately needs to be public to be used in Util.php - public static function scopedConstructFrom($class, $values, $apiKey=null) - { - $obj = new $class(isset($values['id']) ? $values['id'] : null, $apiKey); - $obj->refreshFrom($values, $apiKey); - return $obj; - } - - public static function constructFrom($values, $apiKey=null) - { - $class = get_class(); - return self::scopedConstructFrom($class, $values, $apiKey); - } - - public function refreshFrom($values, $apiKey, $partial=false) - { - $this->_apiKey = $apiKey; - // Wipe old state before setting new. This is useful for e.g. updating a - // customer, where there is no persistent card parameter. Mark those values - // which don't persist as transient - if ($partial) - $removed = new Stripe_Util_Set(); - else - $removed = array_diff(array_keys($this->_values), array_keys($values)); - - foreach ($removed as $k) { - if (self::$_permanentAttributes->includes($k)) - continue; - unset($this->$k); - } - - foreach ($values as $k => $v) { - if (self::$_permanentAttributes->includes($k)) - continue; - $this->_values[$k] = Stripe_Util::convertToStripeObject($v, $apiKey); - $this->_transientValues->discard($k); - $this->_unsavedValues->discard($k); - } - } - - public function __toJSON() - { - if (defined('JSON_PRETTY_PRINT')) - return json_encode($this->__toArray(true), JSON_PRETTY_PRINT); - else - return json_encode($this->__toArray(true)); - } - - public function __toString() - { - return $this->__toJSON(); - } - - public function __toArray($recursive=false) - { - if ($recursive) - return Stripe_Util::convertStripeObjectToArray($this->_values); - else - return $this->_values; - } -} - - -Stripe_Object::init(); diff --git a/mu-plugins/jquery.org/lib/Stripe/Plan.php b/mu-plugins/jquery.org/lib/Stripe/Plan.php deleted file mode 100755 index 171b6735..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Plan.php +++ /dev/null @@ -1,40 +0,0 @@ -refresh(); - return $instance; - } - - public static function classUrl($class) - { - $base = self::className($class); - return "/v1/${base}"; - } - - public function instanceUrl() - { - $class = get_class($this); - $base = self::classUrl($class); - return "$base"; - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/Stripe.php b/mu-plugins/jquery.org/lib/Stripe/Stripe.php deleted file mode 100755 index d6563dbf..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Stripe.php +++ /dev/null @@ -1,27 +0,0 @@ - $v) { - // FIXME: this is an encapsulation violation - if (Stripe_Object::$_permanentAttributes->includes($k)) { - continue; - } - if ($v instanceof Stripe_Object) { - $results[$k] = $v->__toArray(true); - } - else if (is_array($v)) { - $results[$k] = self::convertStripeObjectToArray($v); - } - else { - $results[$k] = $v; - } - } - return $results; - } - - public static function convertToStripeObject($resp, $apiKey) - { - $types = array('charge' => 'Stripe_Charge', - 'customer' => 'Stripe_Customer', - 'list' => 'Stripe_List', - 'invoice' => 'Stripe_Invoice', - 'invoiceitem' => 'Stripe_InvoiceItem', 'event' => 'Stripe_Event', - 'transfer' => 'Stripe_Transfer'); - if (self::isList($resp)) { - $mapped = array(); - foreach ($resp as $i) - array_push($mapped, self::convertToStripeObject($i, $apiKey)); - return $mapped; - } else if (is_array($resp)) { - if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) - $class = $types[$resp['object']]; - else - $class = 'Stripe_Object'; - return Stripe_Object::scopedConstructFrom($class, $resp, $apiKey); - } else { - return $resp; - } - } -} diff --git a/mu-plugins/jquery.org/lib/Stripe/Util/Set.php b/mu-plugins/jquery.org/lib/Stripe/Util/Set.php deleted file mode 100755 index e2654830..00000000 --- a/mu-plugins/jquery.org/lib/Stripe/Util/Set.php +++ /dev/null @@ -1,34 +0,0 @@ -_elts = array(); - foreach ($members as $item) - $this->_elts[$item] = true; - } - - public function includes($elt) - { - return isset($this->_elts[$elt]); - } - - public function add($elt) - { - $this->_elts[$elt] = true; - } - - public function discard($elt) - { - unset($this->_elts[$elt]); - } - - // TODO: make Set support foreach - public function toArray() - { - return array_keys($this->_elts); - } -} diff --git a/mu-plugins/jquery.org/stripe.php b/mu-plugins/jquery.org/stripe.php deleted file mode 100644 index 4fb5d15f..00000000 --- a/mu-plugins/jquery.org/stripe.php +++ /dev/null @@ -1,140 +0,0 @@ - admin_url('admin-ajax.php'), - 'action' => 'stripe_charge', - 'nonce' => wp_create_nonce('stripe-nonce'), - 'key' => STRIPE_PUBLIC - ) ); - } - - public static function coupon() { - require_once( 'lib/Stripe.php' ); - Stripe::setApiKey( STRIPE_SECRET ); - - // Verify required data - if ( empty( $_REQUEST[ 'coupon' ] ) ) { - self::fail( 'Please enter a coupon code.'); - } - - try { - $coupon = Stripe_Coupon::retrieve( $_REQUEST[ 'coupon' ] ); - } catch( Exception $e ) { - self::fail( 'Invalid coupon id' ); - } - - echo json_encode(array( - 'percent_off' => $coupon->percent_off, - 'amount_off' => $coupon->amount_off - )); - exit(); - } - - public static function charge() { - require_once( 'lib/Stripe.php' ); - Stripe::setApiKey( STRIPE_SECRET ); - - // Verify required data - if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( $_REQUEST['nonce'], 'stripe-nonce' ) ) { - self::fail( 'Invalid Nonce' ); - } - if ( empty( $_REQUEST['email'] ) ) { - self::fail( 'Looks like you forgot to provide us with your email, ' . - 'please go back and make sure you provide it.' ); - } - if ( empty( $_REQUEST['token'] ) ) { - self::fail( 'It seems we didn\'t get your payment information, ' . - 'please go back and try again.' ); - } - - $token = $_REQUEST['token']; - $email = $_REQUEST['email']; - $name = $_REQUEST['firstName'] . ' ' . $_REQUEST['lastName']; - $plan = $_REQUEST['planId']; - $address = $_REQUEST['address']; - $coupon = empty( $_REQUEST['coupon'] ) ? null : $_REQUEST['coupon']; - - // Create Stripe subscription - $customer = Stripe_Customer::create( array( - 'email' => $email, - 'card' => $token, - 'description' => stripcslashes($name) - ) ); - $subscription = array( - 'plan' => $plan - ); - if ( !empty( $coupon ) ) { - $subscription['coupon'] = $coupon; - } - $charge = $customer->updateSubscription( $subscription ); - $stripeId = $customer->id; - - // Create or update WordPress user - $user = get_user_by( 'email', $email ); - if ( $user ) { - $user_id = $user->ID; - } else { - $user_id = wp_insert_user(array( - 'user_pass' => wp_generate_password(), - 'user_login' => $email, - 'user_email' => $email, - 'first_name' => $_REQUEST['firstName'], - 'last_name' => $_REQUEST['lastName'], - 'display_name' => $name - ) ); - } - - // Store Stripe ID and gift choices on WordPress user - $customerInfo = array( - 'stripe_id' => $stripeId, - 'address' => $address - ); - if ( !empty( $_REQUEST[ 'tshirt' ] ) ) { - $customerInfo[ 'tshirt' ] = $_REQUEST[ 'tshirt' ]; - } - if ( !empty( $_REQUEST[ 'hoodie' ] ) ) { - $customerInfo[ 'hoodie' ] = $_REQUEST[ 'hoodie' ]; - } - if ( !empty( $_REQUEST[ 'bag' ] ) ) { - $customerInfo[ 'bag' ] = $_REQUEST[ 'bag' ]; - } - foreach( $customerInfo as $key => $value ) { - add_user_meta( $user_id, $key, $value ); - } - - $mailBody = "$name ($email) has signed up for $plan.\n"; - $mailBody .= "WordPress user id: $user_id\n"; - if ( !empty( $coupon ) ) { - $mailBody .= "coupon: $coupon\n"; - } - foreach( $customerInfo as $key => $value ) { - $mailBody .= "$key: $value\n"; - } - - mail( 'membership@jquery.org', "New Foundation Member ($name)", $mailBody ); - - echo $user_id; - exit(); - } - - public static function fail( $message ) { - header( 'HTTP/1.0 400 Bad Request' ); - echo $message; - exit(); - } -} - -add_action( 'init', array( 'StripeForm', 'init' ) ); -add_action( 'wp_ajax_nopriv_stripe_charge', array( 'StripeForm', 'charge' ) ); -add_action( 'wp_ajax_stripe_charge', array( 'StripeForm', 'charge' ) ); -add_action( 'wp_ajax_nopriv_stripe_coupon', array( 'StripeForm', 'coupon' ) ); -add_action( 'wp_ajax_stripe_coupon', array( 'StripeForm', 'coupon' ) ); diff --git a/mu-plugins/jqueryui.com/jquery-filters.php b/mu-plugins/jqueryui.com/jquery-filters.php deleted file mode 100644 index a59dd8c9..00000000 --- a/mu-plugins/jqueryui.com/jquery-filters.php +++ /dev/null @@ -1,48 +0,0 @@ -'); - if ( $demoPos === false ) { - return $content; - } - - $plugin = $post->post_name; - $demoList = json_decode( file_get_contents( GW_RESOURCE_DIR . '/demos/demo-list.json' ) ); - $demos = $demoList->$plugin; - $defaultDemo = $demos[ 0 ]; - - $demoContent .= - '
' . - '

Examples

' . - '
    '; - foreach ( $demoList->$plugin as $demo ) { - $filename = $demo->filename; - $demoContent .= - ($filename === 'default' ? '
  • ' : '
  • ') . - '' . - $demo->title . - '' . - '
  • '; - } - $demoContent .= - '
' . - '
'; - - $demoContent .= ''; - $demoContent .= '
' . $defaultDemo->description . '
'; - - $demoContent .= - '
' . - ' view source' . - '
' . - file_get_contents( GW_RESOURCE_DIR . '/demos-highlight/' . $plugin . '/default.html' ) . - '
' . - '
'; - - return str_replace( '', $demoContent, $content ); -} ); - -?> diff --git a/mu-plugins/plugins.jquery.com/posts.php b/mu-plugins/plugins.jquery.com/posts.php deleted file mode 100644 index bb3ca22c..00000000 --- a/mu-plugins/plugins.jquery.com/posts.php +++ /dev/null @@ -1,91 +0,0 @@ - array( - 'name' => __( 'jQuery Plugins' ), - 'singular_name' => __( 'jQuery Plugin' ) - ), - 'public' => true, - 'map_meta_cap' => true, - 'hierarchical' => true, - 'taxonomies' => array( 'post_tag' ), - 'rewrite' => false, - 'query_var' => 'plugin', - 'delete_with_user' => false, - ) ); -} - -// Rewrite jquery_plugin posts to be at the root -add_filter( 'post_type_link', function( $post_link, $post ) { - if ( 'jquery_plugin' === $post->post_type ) { - return user_trailingslashit( home_url( get_page_uri( $post ) ) ); - } - return $post_link; -}, 10, 2 ); - -// Copy the page rewrite rules and have them catch plugins (after pages are checked). -add_filter( 'page_rewrite_rules', function( $rules ) { - foreach ( $rules as $rule => $match ) { - if ( false === strpos( $rule, 'attachment/' ) ) - $rules[ str_replace( '.?.+?', '.*?.+?', $rule ) ] = str_replace( 'pagename=', 'plugin=', $match ); - } - return $rules; -} ); - -// Only search against parent jquery_plugin posts -function jquery_plugin_posts_only_for_searches( $query ) { - if ( $query->is_main_query() && ($query->is_search() || $query->is_tag()) ) { - $query->set( 'post_type', 'jquery_plugin' ); - $query->set( 'post_parent', 0 ); - $query->set( 'meta_key', 'watchers' ); - $query->set( 'orderby', 'meta_value_num' ); - $query->set( 'order', 'DESC' ); - } -} - -add_action( 'init', 'post_type_jquery_plugin_init' ); -add_action( 'pre_get_posts', 'jquery_plugin_posts_only_for_searches' ); -add_filter( 'pre_option_permalink_structure', function() { - return '/%postname%'; -} ); - -/* - * Ensure that the post_tag taxonomy uses our own special counting logic. - * - * Normally, this would simply be specified by register_taxonomy() with - * the update_count_callback flag. Since we use the core tag taxonomy, - * let's just continue to hijack it. - */ -add_action( 'init', function() { - $GLOBALS['wp_taxonomies']['post_tag']->update_count_callback = 'jquery_update_plugin_tag_count'; -} ); - -/** - * Mostly just _update_post_term_count(), tweaked for - * post_type = 'jquery_plugin' and post_parent = 0. - */ -function jquery_update_plugin_tag_count( $terms, $taxonomy ) { - global $wpdb; - foreach ( (array) $terms as $term ) { - $count = (int) $wpdb->get_var( $wpdb->prepare( - "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts " . - "WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id " . - "AND post_status = 'publish' AND post_type = 'jquery_plugin' " . - "AND post_parent = 0 AND term_taxonomy_id = %d", - $term ) ); - do_action( 'edit_term_taxonomy', $term, $taxonomy ); - $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); - do_action( 'edited_term_taxonomy', $term, $taxonomy ); - } -} diff --git a/mu-plugins/plugins.jquery.com/xmlrpc.php b/mu-plugins/plugins.jquery.com/xmlrpc.php deleted file mode 100644 index 8be65846..00000000 --- a/mu-plugins/plugins.jquery.com/xmlrpc.php +++ /dev/null @@ -1,47 +0,0 @@ -escape( $args ); - - // Authenticate - $blog_id = $args[0]; - $username = $args[1]; - $password = $args[2]; - - if ( ! $user = $wp_xmlrpc_server->login( $username, $password ) ) { - return $wp_xmlrpc_server->error; - } - - // Find post - $plugin_name = $args[3]; - $query = new WP_Query( array( - 'post_type' => 'jquery_plugin', - 'name' => $plugin_name, - 'update_post_term_cache' => false, - 'update_post_meta_cache' => false, - )); - - if ( empty( $query->posts ) ) { - return null; - } - - // Delegate to wp_getPost() for consistent return values - return $wp_xmlrpc_server->wp_getPost(array( - $blog_id, - $username, - $password, - $query->posts[0]->ID - )); -} - -function jq_pjc_register_xmlrpc_methods( $methods ) { - $methods[ 'jq-pjc.getPostForPlugin' ] = 'jq_pjc_get_post_for_plugin'; - return $methods; -} - -add_filter( 'xmlrpc_methods', 'jq_pjc_register_xmlrpc_methods' ); diff --git a/mu-plugins/redirects.php b/mu-plugins/redirects.php deleted file mode 100644 index 750f437b..00000000 --- a/mu-plugins/redirects.php +++ /dev/null @@ -1,27 +0,0 @@ - array( - '/addons/' => '/plugins/' - ) -); - -add_filter( 'template_redirect', function() { - global $jquery_redirects; - - // Only handle 404 Not Found - if ( !is_404() ) { - return; - } - - // Check if this site has any redirects - if ( empty( $jquery_redirects[ JQUERY_LIVE_SITE ] ) ) { - return; - } - - // See if any redirects match the current URL - $url = trailingslashit( $_SERVER[ 'REQUEST_URI' ] ); - if ( !empty( $jquery_redirects[ JQUERY_LIVE_SITE ][ $url ] ) ) { - wp_redirect( $jquery_redirects[ JQUERY_LIVE_SITE ][ $url ], 301 ); - } -}); diff --git a/object-cache-disabled.php b/object-cache-disabled.php deleted file mode 100644 index 40854933..00000000 --- a/object-cache-disabled.php +++ /dev/null @@ -1,352 +0,0 @@ -object-cache.php file from your content directory.' ); -} elseif ( version_compare( '5.2.4', phpversion(), '>=' ) ) { - wp_die( 'The APC object cache backend requires PHP 5.2 or higher. You are running ' . phpversion() . '. Please remove the object-cache.php file from your content directory.' ); -} - -// Users with setups where multiple installs share a common wp-config.php can use this -// to guarantee uniqueness for the keys generated by this object cache -if ( !defined( 'WP_APC_KEY_SALT' ) ) - define( 'WP_APC_KEY_SALT', 'wp' ); - -function wp_cache_add( $key, $data, $group = '', $expire = 0 ) { - global $wp_object_cache; - - return $wp_object_cache->add( $key, $data, $group, $expire ); -} - -function wp_cache_incr( $key, $n = 1, $group = '' ) { - global $wp_object_cache; - - return $wp_object_cache->incr2( $key, $n, $group ); -} - -function wp_cache_decr( $key, $n = 1, $group = '' ) { - global $wp_object_cache; - - return $wp_object_cache->decr( $key, $n, $group ); -} - -function wp_cache_close() { - return true; -} - -function wp_cache_delete( $key, $group = '' ) { - global $wp_object_cache; - - return $wp_object_cache->delete( $key, $group ); -} - -function wp_cache_flush() { - global $wp_object_cache; - - return $wp_object_cache->flush(); -} - -function wp_cache_get( $key, $group = '', $force = false ) { - global $wp_object_cache; - - return $wp_object_cache->get( $key, $group, $force ); -} - -function wp_cache_init() { - global $wp_object_cache; - - $wp_object_cache = new APC_Object_Cache(); -} - -function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) { - global $wp_object_cache; - - return $wp_object_cache->replace( $key, $data, $group, $expire ); -} - -function wp_cache_set( $key, $data, $group = '', $expire = 0 ) { - global $wp_object_cache; - - if ( defined('WP_INSTALLING') == false ) - return $wp_object_cache->set( $key, $data, $group, $expire ); - else - return $wp_object_cache->delete( $key, $group ); -} - -function wp_cache_add_global_groups( $groups ) { - global $wp_object_cache; - - $wp_object_cache->add_global_groups( $groups ); -} - -function wp_cache_add_non_persistent_groups( $groups ) { - global $wp_object_cache; - - $wp_object_cache->add_non_persistent_groups( $groups ); -} - -class WP_Object_Cache { - var $global_groups = array(); - - var $no_mc_groups = array(); - - var $cache = array(); - var $stats = array( 'get' => 0, 'delete' => 0, 'add' => 0 ); - var $group_ops = array(); - - var $cache_enabled = true; - var $default_expiration = 0; - var $abspath = ''; - var $debug = false; - - function add( $id, $data, $group = 'default', $expire = 0 ) { - $key = $this->key( $id, $group ); - - if ( is_object( $data ) ) - $data = clone $data; - - $store_data = $data; - - if ( is_array( $data ) ) - $store_data = new ArrayObject( $data ); - - if ( in_array( $group, $this->no_mc_groups ) ) { - $this->cache[$key] = $data; - return true; - } elseif ( isset( $this->cache[$key] ) && $this->cache[$key] !== false ) { - return false; - } - - $expire = ( $expire == 0 ) ? $this->default_expiration : $expire; - - $result = apc_add( $key, $store_data, $expire ); - if ( false !== $result ) { - @ ++$this->stats['add']; - $this->group_ops[$group][] = "add $id"; - $this->cache[$key] = $data; - } - - return $result; - } - - function add_global_groups( $groups ) { - if ( !is_array( $groups ) ) - $groups = (array) $groups; - - $this->global_groups = array_merge( $this->global_groups, $groups ); - $this->global_groups = array_unique( $this->global_groups ); - } - - function add_non_persistent_groups( $groups ) { - if ( !is_array( $groups ) ) - $groups = (array) $groups; - - $this->no_mc_groups = array_merge( $this->no_mc_groups, $groups ); - $this->no_mc_groups = array_unique( $this->no_mc_groups ); - } - - // This is named incr2 because Batcache looks for incr - // We will define that in a class extension if it is available (APC 3.1.1 or higher) - function incr2( $id, $n = 1, $group = 'default' ) { - $key = $this->key( $id, $group ); - if ( function_exists( 'apc_inc' ) ) - return apc_inc( $key, $n ); - else - return false; - } - - function decr( $id, $n = 1, $group = 'default' ) { - $key = $this->key( $id, $group ); - if ( function_exists( 'apc_dec' ) ) - return apc_dec( $id, $n ); - else - return false; - } - - function close() { - return true; - } - - function delete( $id, $group = 'default' ) { - $key = $this->key( $id, $group ); - - if ( in_array( $group, $this->no_mc_groups ) ) { - unset( $this->cache[$key] ); - return true; - } - - $result = apc_delete( $key ); - - @ ++$this->stats['delete']; - $this->group_ops[$group][] = "delete $id"; - - if ( false !== $result ) - unset( $this->cache[$key] ); - - return $result; - } - - function flush() { - // Don't flush if multi-blog. - if ( function_exists( 'is_site_admin' ) || defined( 'CUSTOM_USER_TABLE' ) && defined( 'CUSTOM_USER_META_TABLE' ) ) - return true; - - return apc_clear_cache( 'user' ); - } - - function get($id, $group = 'default', $force = false) { - $key = $this->key($id, $group); - - if ( isset($this->cache[$key]) && ( !$force || in_array($group, $this->no_mc_groups) ) ) { - if ( is_object( $this->cache[$key] ) ) - $value = clone $this->cache[$key]; - else - $value = $this->cache[$key]; - } else if ( in_array($group, $this->no_mc_groups) ) { - $this->cache[$key] = $value = false; - } else { - $value = apc_fetch( $key ); - if ( is_object( $value ) && 'ArrayObject' == get_class( $value ) ) - $value = $value->getArrayCopy(); - if ( NULL === $value ) - $value = false; - $this->cache[$key] = $value; - } - - @ ++$this->stats['get']; - $this->group_ops[$group][] = "get $id"; - - if ( 'checkthedatabaseplease' === $value ) { - unset( $this->cache[$key] ); - $value = false; - } - - return $value; - } - - function key( $key, $group ) { - if ( empty( $group ) ) - $group = 'default'; - - if ( false !== array_search( $group, $this->global_groups ) ) - $prefix = $this->global_prefix; - else - $prefix = $this->blog_prefix; - - return WP_APC_KEY_SALT . ':' . $this->abspath . ":$prefix$group:$key"; - } - - function replace( $id, $data, $group = 'default', $expire = 0 ) { - return $this->set( $id, $data, $group, $expire ); - } - - function set( $id, $data, $group = 'default', $expire = 0 ) { - $key = $this->key( $id, $group ); - if ( isset( $this->cache[$key] ) && ('checkthedatabaseplease' === $this->cache[$key] ) ) - return false; - - if ( is_object( $data ) ) - $data = clone $data; - - $store_data = $data; - - if ( is_array( $data ) ) - $store_data = new ArrayObject( $data ); - - $this->cache[$key] = $data; - - if ( in_array( $group, $this->no_mc_groups ) ) - return true; - - $expire = ( $expire == 0 ) ? $this->default_expiration : $expire; - $result = apc_store( $key, $store_data, $expire ); - - return $result; - } - - function colorize_debug_line( $line ) { - $colors = array( - 'get' => 'green', - 'set' => 'purple', - 'add' => 'blue', - 'delete' => 'red'); - - $cmd = substr( $line, 0, strpos( $line, ' ' ) ); - - $cmd2 = "$cmd"; - - return $cmd2 . substr( $line, strlen( $cmd ) ) . "\n"; - } - - function stats() { - echo "

\n"; - foreach ( $this->stats as $stat => $n ) { - echo "$stat $n"; - echo "
\n"; - } - echo "

\n"; - echo "

APC:

"; - foreach ( $this->group_ops as $group => $ops ) { - if ( !isset( $_GET['debug_queries'] ) && 500 < count( $ops ) ) { - $ops = array_slice( $ops, 0, 500 ); - echo "Too many to show! Show them anyway.\n"; - } - echo "

$group commands

"; - echo "
\n";
-			$lines = array();
-			foreach ( $ops as $op ) {
-				$lines[] = $this->colorize_debug_line($op); 
-			}
-			print_r($lines);
-			echo "
\n"; - } - if ( $this->debug ) { - $apc_info = apc_cache_info(); - echo "

"; - echo "Cache Hits: {$apc_info['num_hits']}
\n"; - echo "Cache Misses: {$apc_info['num_misses']}\n"; - echo "

\n"; - } - } - - function WP_Object_Cache() { - $this->abspath = md5( ABSPATH ); - - global $blog_id, $table_prefix; - $this->global_prefix = ''; - $this->blog_prefix = ''; - if ( function_exists( 'is_multisite' ) ) { - $this->global_prefix = ( is_multisite() || defined('CUSTOM_USER_TABLE') && defined('CUSTOM_USER_META_TABLE') ) ? '' : $table_prefix; - $this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ) . ':'; - } - - $this->cache_hits =& $this->stats['get']; - $this->cache_misses =& $this->stats['add']; - } -} - -if ( function_exists( 'apc_inc' ) ) { - class APC_Object_Cache extends WP_Object_Cache { - function incr( $id, $n = 1, $group = 'default' ) { - return parent::incr2( $id, $n, $group ); - } - } -} else { - class APC_Object_Cache extends WP_Object_Cache { - // Blank - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 67195f5a..00000000 --- a/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "2.4.19" -} diff --git a/plugins/allow-numeric-stubs/allow-numeric-stubs.php b/plugins/allow-numeric-stubs/allow-numeric-stubs.php deleted file mode 100644 index 90272bfc..00000000 --- a/plugins/allow-numeric-stubs/allow-numeric-stubs.php +++ /dev/null @@ -1,130 +0,0 @@ -<!--nextpage--> ability in Pages to accomplish it. -Version: 2.1.0 -Author: Viper007Bond -Author URI: http://www.viper007bond.com/ - -************************************************************************** - -Copyright (C) 2008-2010 Viper007Bond - -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 . - -**************************************************************************/ - -class Allow_Numeric_Stubs { - - function allow_numeric_stubs() { - register_activation_hook( __FILE__, array( &$this, 'flush_rewrite_rules' ) ); - - add_filter( 'page_rewrite_rules', array( &$this, 'page_rewrite_rules' ) ); - - add_action( 'save_post', array( &$this, 'maybe_fix_stub' ), 2, 2 ); - add_filter( 'editable_slug', array( &$this, 'maybe_fix_editable_slug' ) ); - } - - - // Force a flush of the rewrite rules (for when this plugin is activated) - function flush_rewrite_rules() { - global $wp_rewrite; - $wp_rewrite->flush_rules(); - } - - - // Remove the rewrite rule that "breaks" it (paged content) and replace it with one that allows numeric stubs - function page_rewrite_rules( $rules ) { - unset( $rules['(.?.+?)(/[0-9]+)?/?$'] ); - - $rules['(.?.+?)?/?$'] = 'index.php?pagename=$matches[1]'; - - return $rules; - } - - - // WordPress will add "-2" to numeric stubs as they aren't normally allowed. - // Undo that for numeric page slugs when the post is saved. - function maybe_fix_stub( $post_ID, $post ) { - - // Pages only - if ( 'page' != $post->post_type ) - return; - - // Only mess with numeric stubs or stubs that are 12345-2 - if ( ! is_numeric( $post->post_name ) && $post->post_name == $this->maybe_unsuffix_slug( $post->post_name ) ) - return; - - // Infinite loops are bad - remove_action( 'save_post', array( &$this, 'maybe_fix_stub' ), 2, 2 ); - - // Update the post with a filter active that'll fix the slug back to what it was supposed to be - add_filter( 'wp_insert_post_data', array(&$this, 'slug_fixer'), 10, 2 ); - wp_update_post( $post ); - remove_filter( 'wp_insert_post_data', array(&$this, 'slug_fixer'), 10, 2 ); - - // Put this filter back incase any other posts are updated on this pageload - add_action( 'save_post', array( &$this, 'maybe_fix_stub' ), 2, 2 ); - } - - - // Ensure that post_name stays as we pass it as wp_unique_post_slug() will try and add a "-2" to the end of it - function slug_fixer( $data, $postarr ) { - // $data['post_name'] = $postarr['post_name']; // Not sure why this isn't working - - $data['post_name'] = $this->maybe_unsuffix_slug( $postarr['post_name'] ); - - return $data; - } - - - // Re-fix the page slug for the editable URL - function maybe_fix_editable_slug( $slug ) { - global $post; - - if ( empty( $post ) ) - $thispost = get_post( $_POST['post_id'] ); - else - $thispost = $post; - - if ( empty( $thispost->post_type ) ) - return $slug; - - if ( 'page' == $thispost->post_type ) - $slug = $this->maybe_unsuffix_slug( $slug ); - - return $slug; - } - - - // Checks to see if a string is numeric with "-2" on the end of it - // If so, it returns the original numeric string - function maybe_unsuffix_slug( $slug ) { - if ( '-2' == substr( $slug, -2 ) ) { - $nonsuffixslug = substr( $slug, 0, -2 ); - - if ( is_numeric( $nonsuffixslug ) ) - $slug = $nonsuffixslug; - } - - return $slug; - } -} - -$Allow_Numeric_Stubs = new Allow_Numeric_Stubs(); - -?> \ No newline at end of file diff --git a/plugins/allow-numeric-stubs/readme.txt b/plugins/allow-numeric-stubs/readme.txt deleted file mode 100644 index 203933c7..00000000 --- a/plugins/allow-numeric-stubs/readme.txt +++ /dev/null @@ -1,50 +0,0 @@ -=== Allow Numeric Stubs === -Contributors: Viper007Bond -Donate link: http://www.viper007bond.com/donate/ -Tags: page, pages, numeric, number -Requires at least: 3.3 -Tested up to: 3.3 -Stable tag: trunk - -Allows Pages to have a stub that is only a number. Sacrifices the paged content ability in Pages to accomplish it. - -== Description == - -It is not possible to have a page slug (the page's name in the URL) that is a number. For example this will not work: `yoursite.com/about/2/`. That URL conflicts with paged content feature where you can posts and pages with multiple pages of content by adding `` within your content. - -This plugin allows you to have Pages with numbers as stubs by giving up the ability to have paged content pages which isn't a big deal as most people don't use paged content pages anyway. - -== Installation == - -###Updgrading From A Previous Version### - -To upgrade from a previous version of this plugin, delete the entire folder and files from the previous version of the plugin and then follow the installation instructions below. - -###Installing The Plugin### - -Go to your WordPress administration area and then navigate to Plugins -> Add New in the menu. Search for this plugin's name and then press the install link. - -= See Also:** ["Installing Plugins" article on the WP Codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) - -== ChangeLog == - -= Version 2.1.0 = - -* Update for WordPress 3.3 and it's newer rewrite rules. - -= Version 2.0.1 = - -* Re-add the `save_post` filter after fixing the slug incase multiple posts are updated in one pageload. - -= Version 2.0.0 = - -* Recoded for WordPress 3.0+. WordPress now won't let you manually enter a numeric stub -- it will prefix "-2" onto the end of it so that the page is viewable. This new plugin version works around it. - -= Version 1.0.0 = - -* Initial release. - -== Upgrade Notice == - -= 2.1.0 = -WordPress 3.3 compatibility. \ No newline at end of file diff --git a/plugins/disable-emojis/composer.json b/plugins/disable-emojis/composer.json new file mode 100644 index 00000000..a7ced755 --- /dev/null +++ b/plugins/disable-emojis/composer.json @@ -0,0 +1,12 @@ +{ + "name": "ryanhellyer/disable-emojiis", + "description": "WordPress plugin which disables the WordPress emoji functionality. GDPR friendly.", + "type": "wordpress-plugin", + "license": "GPL-2.0", + "authors": [ + { + "name": "ryanhellyer" + } + ], + "require": {} +} diff --git a/plugins/disable-emojis/disable-emojis.php b/plugins/disable-emojis/disable-emojis.php new file mode 100644 index 00000000..fed54201 --- /dev/null +++ b/plugins/disable-emojis/disable-emojis.php @@ -0,0 +1,83 @@ + $url ) { + if ( strpos( $url, $emoji_svg_url_bit ) !== false ) { + unset( $urls[$key] ); + } + } + + } + + return $urls; +} diff --git a/themes/jquery/license.txt b/plugins/disable-emojis/license.txt old mode 100755 new mode 100644 similarity index 98% rename from themes/jquery/license.txt rename to plugins/disable-emojis/license.txt index d31195ab..5fbe4a70 --- a/themes/jquery/license.txt +++ b/plugins/disable-emojis/license.txt @@ -1,281 +1,281 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110, 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 Library 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 - + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110, 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 Library 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 + diff --git a/plugins/disable-emojis/readme.txt b/plugins/disable-emojis/readme.txt new file mode 100644 index 00000000..d3dd881d --- /dev/null +++ b/plugins/disable-emojis/readme.txt @@ -0,0 +1,93 @@ +=== Disable Emojis (GDPR friendly) === +Contributors: ryanhellyer +Tags: emojis, gdpr, disable +Donate link: https://geek.hellyer.kiwi/donate/ +Requires at least: 4.8 +Tested up to: 6.8 +Stable tag: 1.7.7 + + +This plugin disables the new WordPress emoji functionality. GDPR friendly. + + +== Description == + +This plugin disables the new WordPress emoji functionality. GDPR friendly. + + +Note: Emoticons will still work and emojis will still work in browsers which have built in support for them. This plugin simply removes the extra code bloat used to add support for emojis in older browsers. + += GDPR compliancy = + +This plugin does not do anything to make your site less GDPR compliant. It disables the DNS prefetching of emojis within WordPress, which should ensure improved privacy. To determine if your site is GDPR compliant, please seek legal advice. I have done my best to ensure the plugin is 100% GDPR compliant, but I am not a lawyer so can not guarantee anything ;) + + +== Installation == + +After you've downloaded and extracted the files: + +1. Upload the complete 'disable-emojis' folder to the '/wp-content/plugins/' directory OR install via the plugin installer +2. Activate the plugin through the 'Plugins' menu in WordPress +3. And yer done! + +Visit the Disable Emojis plugin for more information. + + +== Changelog == + += 1.7.7 = +* Confirmed support for newer WordPress versions. + += 1.7.6 = +* Confirmed support for newer WordPress versions. + += 1.7.5 = +* Added Composer support. + += 1.7.4 = +* Fixing typos. + += 1.7.3 = +* Unneeded version bump to shut the WordPress.org notice up. + += 1.7.2 = +* Subtle improvement to code cleanliness. +* Improved documentation regarding GDPR issues. + += 1.7.1 = +* Added GDPR friendly label on advice from Ipstenu. + += 1.7 = +* Removed DNS prefetch URL again. +* This time using simple string check rather than relying on internal WordPress filters. + += 1.6 = +* Removed DNS prefetch URL. Props to Aaron Queen for assisting with this. + += 1.5.3 = +* Catering to new DNS prefetch URL in version 4.7 of core + += 1.5.2 = +* Improved documentation. +* Removed redundant dns prefetching. Thanks to Milan Dinic for the pull request. + += 1.5.1 = +* Updating documentation. + += 1.5 = +* Catering for invalid $plugin array. + += 1.4 = +* Updating to use Otto's code. + += 1.3 = +Removing extraneous styles. + += 1.2 = +Bug fix. + += 1.1 = +Updating to work with latest beta. + += 1.0 = +Initial release. diff --git a/plugins/gilded-wordpress/LICENSE.txt b/plugins/gilded-wordpress/LICENSE.txt new file mode 100644 index 00000000..7e37c759 --- /dev/null +++ b/plugins/gilded-wordpress/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright Scott González http://scottgonzalez.com + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/mu-plugins/grunt-wordpress.php b/plugins/gilded-wordpress/gilded-wordpress.php similarity index 94% rename from mu-plugins/grunt-wordpress.php rename to plugins/gilded-wordpress/gilded-wordpress.php index bdff0546..7a8ba247 100644 --- a/mu-plugins/grunt-wordpress.php +++ b/plugins/gilded-wordpress/gilded-wordpress.php @@ -1,14 +1,17 @@ \ No newline at end of file diff --git a/plugins/jquery-actions.php b/plugins/jquery-actions.php new file mode 100644 index 00000000..b1869e37 --- /dev/null +++ b/plugins/jquery-actions.php @@ -0,0 +1,57 @@ + and sitemap output. +$jq_proto = $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? ''; +if ( $jq_proto == 'https' ) { + $_SERVER['HTTPS'] = '1'; +} elseif ( $jq_proto == 'http' ) { + $_SERVER['HTTPS'] = '0'; +} +unset( $jq_proto ); + +add_filter( 'wp_headers', function ( $headers ) { + if ( isset( $headers['Vary'] ) ) { + $headers['Vary'] .= ',X-Forwarded-Proto'; + } else { + $headers['Vary'] = 'X-Forwarded-Proto'; + } + return $headers; +}, 10, 1 ); + +/** + * Add rel=me link to HTML head for Mastodon domain verification + * + * Usage: + * + * Put one or more comma-separated URLs in the 'jquery_xfn_rel_me' WordPress option. + * + * Example: + * + * 'jquery_xfn_rel_me' => 'https://example.org/@foo,https://social.example/@bar' + * + * See also: + * + * - https://docs.joinmastodon.org/user/profile/#verification + * - https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/me + * - https://microformats.org/wiki/rel-me + * - https://gmpg.org/xfn/ + */ +function jquery_xfnrelme_wp_head() { + $option = get_option( 'jquery_xfn_rel_me' , '' ); + $links = $option !== '' ? explode( ',', $option ) : array(); + foreach ( $links as $url ) { + // We use esc_attr instead of esc_url, as the latter would shorten + // the URL to be scheme-less as "//example" instead of "https://example", + // which prevents relation verification. + echo '' . "\n"; + } +} + +add_action('wp_head', 'jquery_xfnrelme_wp_head'); diff --git a/mu-plugins/api-sites/category-listings.php b/plugins/jquery-api-category-listing.php similarity index 78% rename from mu-plugins/api-sites/category-listings.php rename to plugins/jquery-api-category-listing.php index cd514f6e..4d737b04 100644 --- a/mu-plugins/api-sites/category-listings.php +++ b/plugins/jquery-api-category-listing.php @@ -1,4 +1,8 @@ $value ) { + // Skip these on live sites (both production and staging), + // where they are managed by puppet. + // Local testing with a fresh database does not + // currently work if these are skipped. + if ( JQUERY_STAGING !== 'local' ) { + if ( $option === 'stylesheet' || $option === 'template' ) { + // Don't mess with themes for now. + continue; + } + if ( $option === 'active_plugins' ) { + // On live sites (including staging ones), + // Puppet manages activation of per-site plugins. + continue; + } + } + add_filter( 'pre_option_' . $option, function () use ( $value ) { + return $value; + } ); +} +unset( $sites, $options, $option ); + +// Ensure that the local port is used for template assets, if it exists. +add_filter( 'theme_root_uri', function( $value ) { + // All environment variables are set either in the local wp-config.php or via puppet. + // Staging sites set JQUERY_STAGING to the boolean `true` instead of 'local'. + // Production sites set it to false. + if ( JQUERY_STAGING === 'local' ) { + // Don't specify http vs https here, as the site may be accessed via either. + $siteurl = '//' . strtr( JQUERY_STAGING_FORMAT, [ '%s' => JQUERY_LIVE_SITE ] ); + $value = $siteurl . '/wp-content/themes'; + } + return $value; +}); + +// Remove misc links from on non-blog sites +if ( !get_option( 'jquery_is_blog' ) ) { + remove_action( 'wp_head', 'feed_links', 2 ); + remove_action( 'wp_head', 'feed_links_extra', 3 ); + remove_action( 'wp_head', 'rsd_link' ); + remove_action( 'wp_head', 'wlwmanifest_link' ); + remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); + + // Remove shortlink and header. + remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 ); + remove_action( 'template_redirect', 'wp_shortlink_header', 11 ); + + // Disable WordPress auto-paragraphing for posts, except on actual blog sites + remove_filter( 'the_content', 'wpautop' ); + + add_filter( 'option_uploads_use_yearmonth_folders', '__return_false' ); + + add_filter( 'upload_dir', function( $upload_dir ) { + if ( defined( 'UPLOADS' ) ) { + $upload_dir['path'] = $upload_dir['basedir'] = UPLOADS; + } else { + $upload_dir['path'] = $upload_dir['basedir'] = WP_CONTENT_DIR . '/uploads'; + } + + return $upload_dir; + }); +} + +/** + * Content Security Policy + * https://github.com/jquery/infrastructure-puppet/issues/54 + */ +add_action( 'send_headers', function() { + $nonce = bin2hex( random_bytes( 8 ) ); + $report_url = 'https://csp-report-api.openjs-foundation.workers.dev/'; + $policy = array( + 'default-src' => "'self'", + 'script-src' => "'self' 'nonce-$nonce' code.jquery.com", + // The nonce is here so inline scripts can be used in the theme + 'style-src' => "'self' 'nonce-$nonce' code.jquery.com", + // Allow style="" attributes in blog posts and markdown. + 'style-src-attr' => "'unsafe-inline'", + // data: SVG images are used in typesense + // Allow gravatars in wordpress admins + 'img-src' => "'self' data: secure.gravatar.com code.jquery.com", + 'connect-src' => "'self' typesense.jquery.com", + // Allow data fonts for the wordpress admins + 'font-src' => "'self' data:", + 'object-src' => "'none'", + 'frame-ancestors' => "'none'", + 'base-uri' => "'self'", + 'block-all-mixed-content' => '', + 'report-to' => 'csp-endpoint', + // Add report-uri for Firefox, which + // does not yet support report-to + 'report-uri' => $report_url, + ); + + $policy = apply_filters( 'jq_content_security_policy', $policy ); + + if ( is_admin() ) { + // wp-admin (as used by blogs) requires inline scripts, inline styles, + // and workers from blob: URLs + $policy[ 'script-src' ] = "'self' 'unsafe-inline' blob: code.jquery.com"; + $policy[ 'style-src' ] = "'self' 'unsafe-inline' code.jquery.com"; + } + + $policy_string = ''; + foreach ( $policy as $key => $value ) { + $policy_string .= $key . ' ' . $value . '; '; + } + + header( 'Reporting-Endpoints: csp-endpoint="' . $report_url . '"' ); + header( 'Content-Security-Policy: ' . $policy_string ); +} ); + +// Disable WordPress text transformations (smart quotes, etc.) for posts. +remove_filter( 'the_content', 'wptexturize' ); + +// Disable more restrictive multisite upload settings. +remove_filter( 'upload_mimes', 'check_upload_mimes' ); +// Give unfiltered upload ability to super admins. +define( 'ALLOW_UNFILTERED_UPLOADS', true ); +// Until unfiltered uploads make it into XML-RPC: +add_filter( 'upload_mimes', function( $mimes ) { + $mimes['eot'] = 'application/vnd.ms-fontobject'; + $mimes['svg'] = 'image/svg+xml'; + $mimes['ttf'] = 'application/x-font-ttf'; + $mimes['woff'] = 'application/font-woff'; + $mimes['xml'] = 'text/xml'; + $mimes['php'] = 'application/x-php'; + $mimes['json'] = 'application/json'; + return $mimes; +} ); + +// Increase file size limit to 1GB +add_filter( 'pre_site_option_fileupload_maxk', function() { + return 1024 * 1024; +} ); + +// Disable the new image sizes feature. +// It adds a style tag that would require a CSP exception. +add_filter( 'wp_img_tag_add_auto_sizes', '__return_false' ); + +// Allow full HTML in term descriptions. +add_action( 'init', 'jquery_unfiltered_html_for_term_descriptions' ); +add_action( 'set_current_user', 'jquery_unfiltered_html_for_term_descriptions' ); +function jquery_unfiltered_html_for_term_descriptions() { + remove_filter( 'pre_term_description', 'wp_filter_kses' ); + remove_filter( 'pre_term_description', 'wp_filter_post_kses' ); + if ( ! current_user_can( 'unfiltered_html' ) ) + add_filter( 'pre_term_description', 'wp_filter_post_kses' ); +} + +// Bypass multisite checks. +add_filter( 'ms_site_check', '__return_true' ); + +// Add body classes found in postmeta. +add_filter( 'body_class', function( $classes ) { + $body_class_setting = get_option( 'jquery_body_class' ); + if ( $body_class_setting ) { + array_unshift( $classes, $body_class_setting ); + } + if ( strpos( JQUERY_LIVE_SITE, 'api.' ) === 0 ) { + array_unshift( $classes, 'api' ); + } + + if ( is_page() ) { + $classes[] = 'page-slug-' . sanitize_html_class( strtolower( get_queried_object()->post_name ) ); + } + if ( is_singular() && $post_classes = get_post_meta( get_queried_object_id(), 'body_class', true ) ) { + $classes = array_merge( $classes, explode( ' ', $post_classes ) ); + } + if ( is_archive() || is_search() ) { + $classes[] = 'listing'; + } + + return $classes; +}); + +add_filter( 'get_terms', function( $terms, $taxonomies, $args ) { + if ( !isset( $args[ 'orderby' ] ) || $args[ 'orderby' ] !== 'natural' ) { + return $terms; + } + + $sortedTerms = array(); + foreach( $terms as $term ) { + $sortedTerms[ $term->name ] = $term; + } + uksort( $sortedTerms, 'strnatcasecmp' ); + + if ( strtolower( $args[ 'order' ] ) === 'desc' ) { + $sortedTerms = array_reverse( $sortedTerms ); + } + + return $sortedTerms; +}, 20, 3 ); + +add_filter( 'xmlrpc_wp_insert_post_data', function ( $post_data, $content_struct ) { + if ( $post_data['post_type'] !== 'page' ) { + return $post_data; + } + + if ( isset( $content_struct['page_template'] ) ) { + $post_data['page_template'] = $content_struct['page_template']; + } + + if ( isset( $content_struct['menu_order'] ) ) { + $post_data['menu_order'] = $content_struct['menu_order']; + } + + return $post_data; +}, 10, 2 ); + +if ( JQUERY_STAGING && !defined( 'XMLRPC_REQUEST' ) ) { + ob_start( 'jquery_com_ob_local_urls' ); +} +function jquery_com_ob_local_urls( $content ) { + $pairs = []; + foreach ( jquery_sites() as $site => $_ ) { + // Replace HTTPS with protocol-relative so navigation stays within HTTP locally. + $pairs[ 'https://' . $site ] = '//' . jquery_site_expand( $site ); + // Update any remaining HTTP or protocol-relative urls. + $pairs[ '//' . $site ] = '//' . jquery_site_expand( $site ); + } + return strtr( $content, $pairs ); +} diff --git a/mu-plugins/jquery-tags-on-pages.php b/plugins/jquery-tags-on-pages.php similarity index 100% rename from mu-plugins/jquery-tags-on-pages.php rename to plugins/jquery-tags-on-pages.php diff --git a/plugins/memcached/LICENSE b/plugins/memcached/LICENSE new file mode 100644 index 00000000..4e41786d --- /dev/null +++ b/plugins/memcached/LICENSE @@ -0,0 +1,348 @@ +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + 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. + +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/plugins/memcached/object-cache.php b/plugins/memcached/object-cache.php new file mode 100644 index 00000000..b8c645eb --- /dev/null +++ b/plugins/memcached/object-cache.php @@ -0,0 +1,1208 @@ +add( $key, $data, $group, $expire ); +} + +function wp_cache_add_multiple( array $data, $group = '', $expire = 0 ) { + global $wp_object_cache; + + return $wp_object_cache->add_multiple( $data, $group, $expire ); +} + +function wp_cache_incr( $key, $n = 1, $group = '' ) { + global $wp_object_cache; + + return $wp_object_cache->incr( $key, $n, $group ); +} + +function wp_cache_decr( $key, $n = 1, $group = '' ) { + global $wp_object_cache; + + return $wp_object_cache->decr( $key, $n, $group ); +} + +function wp_cache_close() { + global $wp_object_cache; + + return $wp_object_cache->close(); +} + +function wp_cache_delete( $key, $group = '' ) { + global $wp_object_cache; + + return $wp_object_cache->delete( $key, $group ); +} + +function wp_cache_delete_multiple( array $keys, $group = '' ) { + global $wp_object_cache; + + return $wp_object_cache->delete_multiple( $keys, $group ); +} + +function wp_cache_flush() { + global $wp_object_cache; + + return $wp_object_cache->flush(); +} + +function wp_cache_flush_runtime() { + global $wp_object_cache; + + return $wp_object_cache->flush_runtime(); +} + +function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { + global $wp_object_cache; + + $value = apply_filters( 'pre_wp_cache_get', false, $key, $group, $force ); + if ( false !== $value ) { + $found = true; + return $value; + } + + return $wp_object_cache->get( $key, $group, $force, $found ); +} + +function wp_cache_get_multiple( $keys, $group = '', $force = false ) { + global $wp_object_cache; + + return $wp_object_cache->get_multiple( $keys, $group, $force ); +} + +/** + * Retrieve multiple cache entries + * + * @param array $groups Array of arrays, of groups and keys to retrieve + * @return mixed + */ +function wp_cache_get_multi( $groups ) { + global $wp_object_cache; + + return $wp_object_cache->get_multi( $groups ); +} + +function wp_cache_init() { + global $wp_object_cache; + + $wp_object_cache = new WP_Object_Cache(); +} + +function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) { + global $wp_object_cache; + + return $wp_object_cache->replace( $key, $data, $group, $expire ); +} + +function wp_cache_set( $key, $data, $group = '', $expire = 0 ) { + global $wp_object_cache; + + if ( defined( 'WP_INSTALLING' ) === false ) { + return $wp_object_cache->set( $key, $data, $group, $expire ); + } else { + return $wp_object_cache->delete( $key, $group ); + } +} + +function wp_cache_set_multiple( array $data, $group = '', $expire = 0 ) { + global $wp_object_cache; + + return $wp_object_cache->set_multiple( $data, $group, $expire ); +} + +function wp_cache_switch_to_blog( $blog_id ) { + global $wp_object_cache; + + return $wp_object_cache->switch_to_blog( $blog_id ); +} + +function wp_cache_add_global_groups( $groups ) { + global $wp_object_cache; + + $wp_object_cache->add_global_groups( $groups ); +} + +function wp_cache_add_non_persistent_groups( $groups ) { + global $wp_object_cache; + + $wp_object_cache->add_non_persistent_groups( $groups ); +} + +/** + * Determines whether the object cache implementation supports a particular feature. + * + * @param string $feature Name of the feature to check for. Possible values include: + * 'add_multiple', 'set_multiple', 'get_multiple', 'delete_multiple', + * 'flush_runtime', 'flush_group'. + * @return bool True if the feature is supported, false otherwise. + */ +function wp_cache_supports( $feature ) { + switch ( $feature ) { + case 'get_multiple': + case 'flush_runtime': + return true; + + default: + return false; + } +} + +class WP_Object_Cache { + var $global_groups = array( 'WP_Object_Cache_global' ); + + var $no_mc_groups = array(); + + var $cache = array(); + /** @var Memcache[] */ + var $mc = array(); + var $default_mcs = array(); + var $stats = array( + 'get' => 0, + 'get_local' => 0, + 'get_multi' => 0, + 'set' => 0, + 'set_local' => 0, + 'add' => 0, + 'delete' => 0, + 'delete_local' => 0, + 'slow-ops' => 0, + ); + var $group_ops = array(); + var $cache_hits = 0; + var $cache_misses = 0; + var $global_prefix = ''; + var $blog_prefix = ''; + var $key_salt = ''; + + var $flush_group = 'WP_Object_Cache'; + var $global_flush_group = 'WP_Object_Cache_global'; + var $flush_key = "flush_number_v4"; + var $old_flush_key = "flush_number"; + var $flush_number = array(); + var $global_flush_number = null; + + var $cache_enabled = true; + var $default_expiration = 0; + var $max_expiration = 2592000; // 30 days + + var $stats_callback = null; + + var $connection_errors = array(); + + var $time_start = 0; + var $time_total = 0; + var $size_total = 0; + var $slow_op_microseconds = 0.005; // 5 ms + + function add( $id, $data, $group = 'default', $expire = 0 ) { + $key = $this->key( $id, $group ); + + if ( is_object( $data ) ) { + $data = clone $data; + } + + if ( in_array( $group, $this->no_mc_groups ) ) { + if ( ! isset( $this->cache[ $key ] ) ) { + $this->cache[ $key ] = [ + 'value' => $data, + 'found' => false, + ]; + + return true; + } + + return false; + } + + if ( isset( $this->cache[ $key ][ 'value' ] ) && false !== $this->cache[ $key ][ 'value' ] ) { + return false; + } + + $mc = $this->get_mc( $group ); + + $expire = intval( $expire ); + if ( 0 === $expire || $expire > $this->max_expiration ) { + $expire = $this->default_expiration; + } + + $size = $this->get_data_size( $data ); + $this->timer_start(); + $result = $mc->add( $key, $data, false, $expire ); + $elapsed = $this->timer_stop(); + + $comment = ''; + if ( isset( $this->cache[ $key ] ) ) { + $comment .= ' [lc already]'; + } + if ( false === $result ) { + $comment .= ' [mc already]'; + } + + $this->group_ops_stats( 'add', $key, $group, $size, $elapsed, $comment ); + + if ( false !== $result ) { + $this->cache[ $key ] = [ + 'value' => $data, + 'found' => true, + ]; + } else if ( false === $result && true === isset( $this->cache[$key][ 'value' ] ) && false === $this->cache[$key][ 'value' ] ) { + /* + * Here we unset local cache if remote add failed and local cache value is equal to `false` in order + * to update the local cache anytime we get a new information from remote server. This way, the next + * cache get will go to remote server and will fetch recent data. + */ + unset( $this->cache[$key] ); + } + + return $result; + } + + public function add_multiple( array $data, $group = '', $expire = 0 ) { + $values = array(); + + foreach ( $data as $key => $value ) { + $values[ $key ] = $this->add( $key, $value, $group, $expire ); + } + + return $values; + } + + function add_global_groups( $groups ) { + if ( ! is_array( $groups ) ) { + $groups = (array) $groups; + } + + $this->global_groups = array_merge( $this->global_groups, $groups ); + $this->global_groups = array_unique( $this->global_groups ); + } + + function add_non_persistent_groups( $groups ) { + if ( ! is_array( $groups ) ) { + $groups = (array) $groups; + } + + $this->no_mc_groups = array_merge( $this->no_mc_groups, $groups ); + $this->no_mc_groups = array_unique( $this->no_mc_groups ); + } + + function incr( $id, $n = 1, $group = 'default' ) { + $key = $this->key( $id, $group ); + $mc = $this->get_mc( $group ); + + $incremented = $mc->increment( $key, $n ); + + $this->cache[ $key ] = [ + 'value' => $incremented, + 'found' => false !== $incremented, + ]; + + return $this->cache[ $key ][ 'value' ]; + } + + function decr( $id, $n = 1, $group = 'default' ) { + $key = $this->key( $id, $group ); + $mc = $this->get_mc( $group ); + + $decremented = $mc->decrement( $key, $n ); + $this->cache[ $key ] = [ + 'value' => $decremented, + 'found' => false !== $decremented, + ]; + + return $this->cache[ $key ][ 'value' ]; + } + + function close() { + foreach ( $this->mc as $bucket => $mc ) { + $mc->close(); + } + } + + function delete( $id, $group = 'default' ) { + $key = $this->key( $id, $group ); + + if ( in_array( $group, $this->no_mc_groups ) ) { + unset( $this->cache[ $key ] ); + + return true; + } + + $mc = $this->get_mc( $group ); + + $this->timer_start(); + $result = $mc->delete( $key ); + $elapsed = $this->timer_stop(); + + $this->group_ops_stats( 'delete', $key, $group, null, $elapsed ); + + if ( false !== $result ) { + unset( $this->cache[ $key ] ); + } + + return $result; + } + + public function delete_multiple( array $keys, $group = '' ) { + $values = array(); + + foreach ( $keys as $key ) { + $values[ $key ] = $this->delete( $key, $group ); + } + + return $values; + } + + // Gets number from all default servers, replicating if needed + function get_max_flush_number( $group ) { + $key = $this->key( $this->flush_key, $group ); + + $values = array(); + $size = 19; // size of microsecond timestamp serialized + foreach ( $this->default_mcs as $i => $mc ) { + $flags = false; + $this->timer_start(); + $values[ $i ] = $mc->get( $key, $flags ); + $elapsed = $this->timer_stop(); + + if ( empty( $values[ $i ] ) ) { + $this->group_ops_stats( 'get_flush_number', $key, $group, null, $elapsed, 'not_in_memcache' ); + } else { + $this->group_ops_stats( 'get_flush_number', $key, $group, $size, $elapsed, 'memcache' ); + } + } + + $max = max( $values ); + + if ( ! $max > 0 ) { + return false; + } + + // Replicate to servers not having the max. + $expire = 0; + foreach ( $this->default_mcs as $i => $mc ) { + if ( $values[ $i ] < $max ) { + $this->timer_start(); + $mc->set( $key, $max, false, $expire ); + $elapsed = $this->timer_stop(); + $this->group_ops_stats( 'set_flush_number', $key, $group, $size, $elapsed, 'replication_repair' ); + } + } + + return $max; + } + + function set_flush_number( $value, $group ) { + $key = $this->key( $this->flush_key, $group ); + $expire = 0; + $size = 19; + foreach ( $this->default_mcs as $i => $mc ) { + $this->timer_start(); + $mc->set( $key, $value, false, $expire ); + $elapsed = $this->timer_stop(); + $this->group_ops_stats( 'set_flush_number', $key, $group, $size, $elapsed, 'replication' ); + } + } + + function get_flush_number( $group ) { + $flush_number = $this->get_max_flush_number( $group ); + // What if there is no v4 flush number? + if ( empty( $flush_number ) ) { + // Look for the v3 flush number key. + $flush_number = intval( $this->get( $this->old_flush_key, $group ) ); + if ( !empty( $flush_number ) ) { + // Found v3 flush number. Upgrade to v4 with replication. + $this->set_flush_number( $flush_number, $group ); + // Delete v3 key so we can't later restore it and find stale keys. + } else { + // No flush number found anywhere. Make a new one. This flushes the cache. + $flush_number = $this->new_flush_number(); + $this->set_flush_number( $flush_number, $group ); + } + } + + return $flush_number; + } + + function get_global_flush_number() { + if ( ! isset( $this->global_flush_number ) ) { + $this->global_flush_number = $this->get_flush_number( $this->global_flush_group ); + } + return $this->global_flush_number; + } + + function get_blog_flush_number() { + if ( ! isset( $this->flush_number[ $this->blog_prefix ] ) ) { + $this->flush_number[ $this->blog_prefix ] = $this->get_flush_number( $this->flush_group ); + } + return $this->flush_number[ $this->blog_prefix ]; + } + + function flush_runtime() { + $this->cache = array(); + $this->group_ops = array(); + + return true; + } + + function flush() { + // Do not use the memcached flush method. It acts on an + // entire memcached server, affecting all sites. + // Flush is also unusable in some setups, e.g. twemproxy. + // Instead, rotate the key prefix for the current site. + // Global keys are rotated when flushing on any network's + // main site. + $this->cache = array(); + + $flush_number = $this->new_flush_number(); + + $this->rotate_site_keys( $flush_number ); + + if ( is_main_site() ) { + $this->rotate_global_keys( $flush_number ); + } + + return true; + } + + function rotate_site_keys( $flush_number = null ) { + if ( is_null( $flush_number ) ) { + $flush_number = $this->new_flush_number(); + } + + $this->set_flush_number( $flush_number, $this->flush_group ); + + $this->flush_number[ $this->blog_prefix ] = $flush_number; + } + + function rotate_global_keys( $flush_number = null ) { + if ( is_null( $flush_number ) ) { + $flush_number = $this->new_flush_number(); + } + + $this->set_flush_number( $flush_number, $this->global_flush_group ); + + $this->global_flush_number = $flush_number; + } + + function new_flush_number() { + return intval( microtime( true ) * 1e6 ); + } + + function get( $id, $group = 'default', $force = false, &$found = null ) { + $key = $this->key( $id, $group ); + $mc = $this->get_mc( $group ); + $found = true; + + if ( isset( $this->cache[ $key ] ) && ( ! $force || in_array( $group, $this->no_mc_groups ) ) ) { + if ( isset( $this->cache[ $key ][ 'value' ] ) && is_object( $this->cache[ $key ][ 'value' ] ) ) { + $value = clone $this->cache[ $key ][ 'value' ]; + } else { + $value = $this->cache[ $key ][ 'value' ]; + } + $found = $this->cache[ $key ][ 'found' ]; + + $this->group_ops_stats( 'get_local', $key, $group, null, null, 'local' ); + } else if ( in_array( $group, $this->no_mc_groups ) ) { + $this->cache[ $key ] = [ + 'value' => $value = false, + 'found' => false, + ]; + + $found = false; + + $this->group_ops_stats( 'get_local', $key, $group, null, null, 'not_in_local' ); + } else { + $flags = false; + $this->timer_start(); + $value = $mc->get( $key, $flags ); + $elapsed = $this->timer_stop(); + + // Value will be unchanged if the key doesn't exist. + if ( false === $flags ) { + $found = false; + $value = false; + } elseif ( false === $value && ( $flags & 0xFF01 ) === 0x01 ) { + /* + * The lowest byte is used for flags. + * 0x01 means the value is serialized (MMC_SERIALIZED). + * The second lowest indicates data type: 0 is string, 1 is bool, 3 is long, 7 is double. + * `null` is serialized into a string, thus $flags is 0x0001 + * Empty string will correspond to $flags = 0x0000 (not serialized). + * For `false` or `true` $flags will be 0x0100 + * + * See: + * - https://github.com/websupport-sk/pecl-memcache/blob/2a5de3c5d9c0bd0acbcf7e6e0b7570f15f89f55b/php7/memcache_pool.h#L61-L76 - PHP 7.x + * - https://github.com/websupport-sk/pecl-memcache/blob/ccf702b14b18fce18a1863e115a7b4c964df952e/src/memcache_pool.h#L57-L76 - PHP 8.x + * + * In PHP 8, they changed the way memcache_get() handles `null`: + * https://github.com/websupport-sk/pecl-memcache/blob/ccf702b14b18fce18a1863e115a7b4c964df952e/src/memcache.c#L2175-L2177 + * + * If the return value is `null`, it is silently converted to `false`. We can only rely upon $flags to find out whether `false` is real. + */ + $value = null; + } + + $this->cache[ $key ] = [ + 'value' => $value, + 'found' => $found, + ]; + + if ( is_null( $value ) || $value === false ) { + $this->group_ops_stats( 'get', $key, $group, null, $elapsed, 'not_in_memcache' ); + } else if ( 'checkthedatabaseplease' === $value ) { + $this->group_ops_stats( 'get', $key, $group, null, $elapsed, 'checkthedatabaseplease' ); + } else { + $size = $this->get_data_size( $value ); + $this->group_ops_stats( 'get', $key, $group, $size, $elapsed, 'memcache' ); + } + } + + if ( 'checkthedatabaseplease' === $value ) { + unset( $this->cache[ $key ] ); + + $found = false; + $value = false; + } + + return $value; + } + + function get_multi( $groups ) { + /* + format: $get['group-name'] = array( 'key1', 'key2' ); + */ + $return = array(); + $return_cache = array( + 'value' => false, + 'found' => false, + ); + + foreach ( $groups as $group => $ids ) { + $mc = $this->get_mc( $group ); + $keys = array(); + $this->timer_start(); + + foreach ( $ids as $id ) { + $key = $this->key( $id, $group ); + $keys[] = $key; + + if ( isset( $this->cache[ $key ] ) ) { + if ( is_object( $this->cache[ $key ][ 'value'] ) ) { + $return[ $key ] = clone $this->cache[ $key ][ 'value']; + $return_cache[ $key ] = [ + 'value' => clone $this->cache[ $key ][ 'value'], + 'found' => $this->cache[ $key ][ 'found'], + ]; + } else { + $return[ $key ] = $this->cache[ $key ][ 'value']; + $return_cache[ $key ] = [ + 'value' => $this->cache[ $key ][ 'value' ], + 'found' => $this->cache[ $key ][ 'found' ], + ]; + } + + continue; + } else if ( in_array( $group, $this->no_mc_groups ) ) { + $return[ $key ] = false; + $return_cache[ $key ] = [ + 'value' => false, + 'found' => false, + ]; + + continue; + } else { + $fresh_get = $mc->get( $key ); + $return[ $key ] = $fresh_get; + $return_cache[ $key ] = [ + 'value' => $fresh_get, + 'found' => false !== $fresh_get, + ]; + } + } + + $elapsed = $this->timer_stop(); + $this->group_ops_stats( 'get_multi', $keys, $group, null, $elapsed ); + } + + $this->cache = array_merge( $this->cache, $return_cache ); + + return $return; + } + + public function get_multiple( $keys, $group = 'default', $force = false ) { + $mc = $this->get_mc( $group ); + + $no_mc = in_array( $group, $this->no_mc_groups, true ); + + $uncached_keys = array(); + $return = array(); + $return_cache = array(); + + foreach ( $keys as $id ) { + $key = $this->key( $id, $group ); + + if ( isset( $this->cache[ $key ] ) && ( ! $force || $no_mc ) ) { + $value = $this->cache[ $key ]['found'] ? $this->cache[ $key ]['value'] : false; + $return[ $id ] = is_object( $value ) ? clone $value : $value; + } else if ( $no_mc ) { + $return[ $id ] = false; + $return_cache[ $key ] = [ + 'value' => false, + 'found' => false, + ]; + } else { + $uncached_keys[ $id ] = $key; + } + } + + if ( $uncached_keys ) { + $this->timer_start(); + $uncached_keys_list = array_values( $uncached_keys ); + $values = $mc->get( $uncached_keys_list ); + $elapsed = $this->timer_stop(); + + $this->group_ops_stats( 'get_multiple', $uncached_keys_list, $group, null, $elapsed ); + + foreach ( $uncached_keys as $id => $key ) { + $found = array_key_exists( $key, $values ); + $value = $found ? $values[ $key ] : false; + + $return[ $id ] = $value; + $return_cache[ $key ] = [ + 'value' => $value, + 'found' => $found, + ]; + } + } + + $this->cache = array_merge( $this->cache, $return_cache ); + + return $return; + } + + function flush_prefix( $group ) { + if ( $group === $this->flush_group || $group === $this->global_flush_group ) { + // Never flush the flush numbers. + $number = '_'; + } elseif ( false !== array_search( $group, $this->global_groups ) ) { + $number = $this->get_global_flush_number(); + } else { + $number = $this->get_blog_flush_number(); + } + return $number . ':'; + } + + function key( $key, $group ) { + if ( empty( $group ) ) { + $group = 'default'; + } + + $prefix = $this->key_salt; + + $prefix .= $this->flush_prefix( $group ); + + if ( false !== array_search( $group, $this->global_groups ) ) { + $prefix .= $this->global_prefix; + } else { + $prefix .= $this->blog_prefix; + } + + return preg_replace( '/\s+/', '', "$prefix:$group:$key" ); + } + + function replace( $id, $data, $group = 'default', $expire = 0 ) { + $key = $this->key( $id, $group ); + $expire = intval( $expire ); + if ( 0 === $expire || $expire > $this->max_expiration ) { + $expire = $this->default_expiration; + } + $mc = $this->get_mc( $group ); + + if ( is_object( $data ) ) { + $data = clone $data; + } + + $size = $this->get_data_size( $data ); + $this->timer_start(); + $result = $mc->replace( $key, $data, false, $expire ); + $elapsed = $this->timer_stop(); + $this->group_ops_stats( 'replace', $key, $group, $size, $elapsed ); + + if ( false !== $result ) { + $this->cache[ $key ] = [ + 'value' => $data, + 'found' => true, + ]; + } + + return $result; + } + + function set( $id, $data, $group = 'default', $expire = 0 ) { + $key = $this->key( $id, $group ); + + if ( isset( $this->cache[ $key ] ) && ( 'checkthedatabaseplease' === $this->cache[ $key ][ 'value' ] ) ) { + return false; + } + + if ( is_object( $data ) ) { + $data = clone $data; + } + + $this->cache[ $key ] = [ + 'value' => $data, + 'found' => false, // Set to false as not technically found in memcache at this point. + ]; + + if ( in_array( $group, $this->no_mc_groups ) ) { + $this->group_ops_stats( 'set_local', $key, $group, null, null ); + + return true; + } + + $expire = intval( $expire ); + if ( 0 === $expire || $expire > $this->max_expiration ) { + $expire = $this->default_expiration; + } + + $mc = $this->get_mc( $group ); + + $size = $this->get_data_size( $data ); + $this->timer_start(); + $result = $mc->set( $key, $data, false, $expire ); + $elapsed = $this->timer_stop(); + $this->group_ops_stats( 'set', $key, $group, $size, $elapsed ); + + // Update the found cache value with the result of the set in memcache. + $this->cache[ $key ][ 'found' ] = $result; + + return $result; + } + + public function set_multiple( array $data, $group = '', $expire = 0 ) { + $values = array(); + + foreach ( $data as $key => $value ) { + $values[ $key ] = $this->set( $key, $value, $group, $expire ); + } + + return $values; + } + + function switch_to_blog( $blog_id ) { + global $table_prefix; + + $blog_id = (int) $blog_id; + + $this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ); + } + + function colorize_debug_line( $line, $trailing_html = '' ) { + $colors = array( + 'get' => 'green', + 'get_local' => 'lightgreen', + 'get_multi' => 'fuchsia', + 'get_multiple' => 'navy', + 'set' => 'purple', + 'set_local' => 'orchid', + 'add' => 'blue', + 'delete' => 'red', + 'delete_local' => 'tomato', + 'slow-ops' => 'crimson', + ); + + $cmd = substr( $line, 0, strpos( $line, ' ' ) ); + + // Start off with a neutral default color... + $color_for_cmd = 'brown'; + // And if the cmd has a specific color, use that instead + if ( isset( $colors[ $cmd ] ) ) { + $color_for_cmd = $colors[ $cmd ]; + } + + $cmd2 = "" . esc_html( $cmd ) . ""; + + return $cmd2 . esc_html( substr( $line, strlen( $cmd ) ) ) . "$trailing_html\n"; + } + + function js_toggle() { + echo " + + "; + } + + /** + * Returns the collected raw stats. + * + * @return array $stats + */ + function get_stats() { + $stats = []; + $stats['totals'] = [ + 'query_time' => $this->time_total, + 'size' => $this->size_total, + ]; + $stats['operation_counts'] = $this->stats; + $stats['operations'] = []; + $stats['groups'] = []; + $stats['slow-ops'] = []; + $stats['slow-ops-groups'] = []; + foreach ( $this->group_ops as $cache_group => $dataset ) { + if ( empty( $cache_group ) ) { + $cache_group = 'default'; + } + + foreach ( $dataset as $data ) { + $operation = $data[0]; + $op = [ + 'key' => $data[1], + 'size' => $data[2], + 'time' => $data[3], + 'group' => $cache_group, + 'result' => $data[4], + ]; + + if ( $cache_group === 'slow-ops' ) { + $key = 'slow-ops'; + $groups_key = 'slow-ops-groups'; + $op['group'] = $data[5]; + $op['backtrace'] = $data[6]; + } else { + $key = 'operations'; + $groups_key = 'groups'; + } + + $stats[ $key ][ $operation ][] = $op; + + if ( ! in_array( $op['group'], $stats[ $groups_key ] ) ) { + $stats[ $groups_key ][] = $op['group']; + } + } + } + + return $stats; + } + + + function stats() { + $this->js_toggle(); + + echo '

Total memcache query time:' . number_format_i18n( sprintf( '%0.1f', $this->time_total * 1000 ), 1 ) . ' ms

'; + echo "\n"; + echo '

Total memcache size:' . esc_html( size_format( $this->size_total, 2 ) ) . '

'; + echo "\n"; + + foreach ( $this->stats as $stat => $n ) { + if ( empty( $n ) ) { + continue; + } + + echo '

'; + echo $this->colorize_debug_line( "$stat $n" ); + echo '

'; + } + + echo "\n"; + + echo "
\n"; + foreach ( $groups as $group ) { + $group_name = $group; + if ( empty( $group_name ) ) { + $group_name = 'default'; + } + $current = $active_group == $group ? 'style="display: block"' : 'style="display: none"'; + echo "
\n"; + echo '

' . esc_html( $group_titles[ $group ] ) . '

' . "\n"; + echo "
\n";
+			foreach ( $this->group_ops[ $group ] as $index => $arr ) {
+				printf( '%3d ', $index );
+				echo $this->get_group_ops_line( $index, $arr );
+			}
+			echo "
\n"; + echo "
"; + } + + echo "
"; + } + + function get_group_ops_line( $index, $arr ) { + // operation + $line = "{$arr[0]} "; + + // key + $json_encoded_key = json_encode( $arr[1] ); + $line .= $json_encoded_key . " "; + + // comment + if ( ! empty( $arr[4] ) ) { + $line .= "{$arr[4]} "; + } + + // size + if ( isset( $arr[2] ) ) { + $line .= '(' . size_format( $arr[2], 2 ) . ') '; + } + + // time + if ( isset( $arr[3] ) ) { + $line .= '(' . number_format_i18n( sprintf( '%0.1f', $arr[3] * 1000 ), 1 ) . ' ms)'; + } + + // backtrace + $bt_link = ''; + if ( isset( $arr[6] ) ) { + $key_hash = md5( $index . $json_encoded_key ); + $bt_link = " Toggle Backtrace"; + $bt_link .= ""; + } + + return $this->colorize_debug_line( $line, $bt_link ); + } + + /** + * @param int|string $group + * @return Memcache + */ + function get_mc( $group ) { + if ( isset( $this->mc[ $group ] ) ) { + return $this->mc[ $group ]; + } + + return $this->mc['default']; + } + + function failure_callback( $host, $port ) { + $this->connection_errors[] = array( + 'host' => $host, + 'port' => $port, + ); + } + + function salt_keys( $key_salt ) { + if ( strlen( $key_salt ) ) { + $this->key_salt = $key_salt . ':'; + } else { + $this->key_salt = ''; + } + } + + function __construct() { + global $memcached_servers; + + if ( isset( $memcached_servers ) ) { + $buckets = $memcached_servers; + } else { + $buckets = array( '127.0.0.1:11211' ); + } + + reset( $buckets ); + + if ( is_int( key( $buckets ) ) ) { + $buckets = array( 'default' => $buckets ); + } + + foreach ( $buckets as $bucket => $servers ) { + $this->mc[ $bucket ] = new Memcache(); + + foreach ( $servers as $i => $server ) { + if ( 'unix://' == substr( $server, 0, 7 ) ) { + $node = $server; + $port = 0; + } else { + if ( false === strpos( $server, ':' ) ) { + $node = $server; + $port = ini_get( 'memcache.default_port' ); + } else { + list ( $node, $port ) = explode( ':', $server, 2 ); + } + + $port = intval( $port ); + + if ( ! $port ) { + $port = 11211; + } + } + + $this->mc[ $bucket ]->addServer( $node, $port, true, 1, 1, 15, true, array( $this, 'failure_callback' ) ); + $this->mc[ $bucket ]->setCompressThreshold( 20000, 0.2 ); + + // Prepare individual connections to servers in default bucket for flush_number redundancy + if ( 'default' === $bucket ) { + $this->default_mcs[ $i ] = new Memcache(); + $this->default_mcs[ $i ]->addServer( $node, $port, true, 1, 1, 15, true, array( $this, 'failure_callback' ) ); + } + } + } + + global $blog_id, $table_prefix; + + $this->global_prefix = ''; + $this->blog_prefix = ''; + + if ( function_exists( 'is_multisite' ) ) { + $this->global_prefix = ( is_multisite() || defined( 'CUSTOM_USER_TABLE' ) && defined( 'CUSTOM_USER_META_TABLE' ) ) ? '' : $table_prefix; + $this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ); + } + + $this->salt_keys( WP_CACHE_KEY_SALT ); + + $this->cache_hits =& $this->stats['get']; + $this->cache_misses =& $this->stats['add']; + } + + function increment_stat( $field, $num = 1 ) { + if ( ! isset( $this->stats[ $field ] ) ) { + $this->stats[ $field ] = $num; + } else { + $this->stats[ $field ] += $num; + } + } + + function group_ops_stats( $op, $keys, $group, $size, $time, $comment = '' ) { + $this->increment_stat( $op ); + + // we have no use of the local ops details for now + if ( strpos( $op, '_local' ) ) { + return; + } + + $this->size_total += $size; + + $keys = $this->strip_memcached_keys( $keys ); + + // @codeCoverageIgnoreStart + if ( $time > $this->slow_op_microseconds && 'get_multi' !== $op ) { + $this->increment_stat( 'slow-ops' ); + $backtrace = null; + if ( function_exists( 'wp_debug_backtrace_summary' ) ) { + $backtrace = wp_debug_backtrace_summary(); + } + $this->group_ops['slow-ops'][] = array( $op, $keys, $size, $time, $comment, $group, $backtrace ); + } + // @codeCoverageIgnoreEnd + + $this->group_ops[ $group ][] = array( $op, $keys, $size, $time, $comment ); + } + + /** + * Key format: key_salt:flush_number:table_prefix:key_name + * + * We want to strip the `key_salt:flush_number` part to not leak the memcached keys. + * If `key_salt` is set we strip `'key_salt:flush_number`, otherwise just strip the `flush_number` part. + */ + function strip_memcached_keys( $keys ) { + if ( ! is_array( $keys ) ) { + $keys = [ $keys ]; + } + + foreach ( $keys as $key => $value ) { + $offset = 0; + if ( ! empty( $this->key_salt ) ) { + $offset = strpos( $value, ':' ) + 1; + } + + $start = strpos( $value, ':', $offset ); + $keys[ $key ] = substr( $value, $start + 1 ); + } + + if ( 1 === count( $keys ) ) { + return $keys[0]; + } + + return $keys; + } + + function timer_start() { + $this->time_start = microtime( true ); + + return true; + } + + function timer_stop() { + $time_total = microtime( true ) - $this->time_start; + $this->time_total += $time_total; + + return $time_total; + } + + function get_data_size( $data ) { + if ( is_string( $data ) ) { + return strlen( $data ); + } + + $serialized = serialize( $data ); + + return strlen( $serialized ); + } +} diff --git a/plugins/memcached/readme.txt b/plugins/memcached/readme.txt new file mode 100644 index 00000000..84d1304d --- /dev/null +++ b/plugins/memcached/readme.txt @@ -0,0 +1,140 @@ +=== Memcached Object Cache === +Contributors: ryan, sivel, andy, nacin, barry, ethitter, nickdaugherty, batmoo, simonwheatley, jenkoian, bor0, aidvu +Tags: cache, memcached +Requires at least: 5.3 +Tested up to: 6.0 +Stable tag: 4.0.0 +Requires PHP: 7.4.0 + +Use memcached and the PECL memcache extension to provide a backing store for the WordPress object cache. + +== Description == +Memcached Object Cache provides a persistent backend for the WordPress object cache. A memcached server and the PECL memcache extension are required. + +== Installation == +1. Install [memcached](http://danga.com/memcached) on at least one server. Note the connection info. The default is `127.0.0.1:11211`. + +1. Install the [PECL memcache extension](http://pecl.php.net/package/memcache) + +1. Copy object-cache.php to wp-content + +1. Add the `WP_CACHE_KEY_SALT` constant to the `wp-config.php`: + +```php +define( 'WP_CACHE_KEY_SALT', '...long random string...' ); +``` + +This helps prevent cache pollution when multiplte WordPress installs are using the same Memcached server. The value must be unique for each WordPress install. + +== Frequently Asked Questions == + += How can I manually specify the memcached server(s)? = + +Add something similar to the following to wp-config.php above `/* That's all, stop editing! Happy blogging. */`: + +` +$memcached_servers = array( + 'default' => array( + '10.10.10.20:11211', + '10.10.10.30:11211' + ) +); +` + +The top level array keys, are cache groups, where 'default' corresponds to any cache group that is not explicitly defined. This allows for specifying memcached servers that only handle certain cache groups. The most common use is only specifying 'default'. + +Possible cache groups are: + +` +{$taxonomy}_relationships +{$meta_type}_meta +{$taxonomy}_relationships +blog-details +blog-id-cache +blog-lookup +bookmark +calendar +category +comment +counts +general +global-posts +options +plugins +post_ancestors +post_meta +posts +rss +site-lookup +site-options +site-transient +terms +themes +timeinfo +transient +user_meta +useremail +userlogins +usermeta +users +userslugs +widget +` + +== Changelog == + += 4.0.0 = +* Add preemptive filter pre_wp_cache_get +* Add flush_number replication to prevent accidental flush due to flush_number eviction, server rotation, etc. + += 3.2.2 = +* Remove filter, and base key stripping on presence of `key_salt` + += 3.2.1 = +* Fix bug allowing **slow-ops** entries to have the same key, so toggling doesn't work + += 3.2.0 = +* Better stats(). Now shows cache group/individual calls with size of the payload and timings. +* PHP 5.6.20 is now required +* Fix **get_multi** to show per group calls +* Added filter **(memcached_strip_keys)** to bypass memcached key stripping +* Special group for **slow-ops** ( > 5ms ) with backtrace + += 3.1.0 = +* Add **wp_cache_get_multi** +* Add support for the **$found** parameter +* Set a variable for $max_expiration to 30 days +* Code style changes +* Different coloring for unknown stats group +* Store host/port on failure_callback +* Default stats counts + += 3.0.2 = +* Better output of HTML + += 3.0.1 = +* Fix key generation error in switch_to_blog() + += 3.0.0 = +* Flush site cache by rotating keys +* Flush global cache when flushing main site + += 2.0.6 = +* Flush the local cache on wp_cache_flush() + += 2.0.5 = +* Fix missing global in switch_to_blog + += 2.0.4 = +* Remove deprecated constructor + += 2.0.3 = +* Support for unix sockets + += 2.0.2 = +* Break references by cloning objects +* Keep local cache in sync with memcached when using incr and decr +* Handle limited environments where is_multisite() is not defined +* Fix setting and getting 0 +* PHP 5.2.4 is now required +* Use the WP_CACHE_KEY_SALT constant if available to guarantee uniqueness of keys diff --git a/plugins/redirects.php b/plugins/redirects.php new file mode 100644 index 00000000..d637ddff --- /dev/null +++ b/plugins/redirects.php @@ -0,0 +1,43 @@ +login( $username, $password ) ) { + return $wp_xmlrpc_server->error; + } + + // Store redirects + return update_option( 'jquery_redirects', json_decode( $args[ 3 ], true ) ); +} diff --git a/plugins/vaultpress/class.vaultpress-database.php b/plugins/vaultpress/class.vaultpress-database.php deleted file mode 100644 index 4068dfe8..00000000 --- a/plugins/vaultpress/class.vaultpress-database.php +++ /dev/null @@ -1,140 +0,0 @@ -__construct(); - } - - function __construct() { - } - - function attach( $table ) { - $this->table=$table; - } - - function get_tables( $filter=null ) { - global $wpdb; - $rval = $wpdb->get_col( 'SHOW TABLES' ); - if ( $filter ) - $rval = preg_grep( $filter, $rval ); - return $rval; - } - - function show_create() { - global $wpdb; - if ( !$this->table ) - return false; - $table = $wpdb->escape( $this->table ); - $results = $wpdb->get_row( "SHOW CREATE TABLE `$table`" ); - $want = 'Create Table'; - if ( $results ) - $results = $results->$want; - return $results; - } - - function explain() { - global $wpdb; - if ( !$this->table ) - return false; - $table = $wpdb->escape( $this->table ); - return $wpdb->get_results( "EXPLAIN `$table`" ); - } - - function diff( $signatures ) { - global $wpdb; - if ( !is_array( $signatures ) || !count( $signatures ) ) - return false; - if ( !$this->table ) - return false; - $table = $wpdb->escape( $this->table ); - $diff = array(); - foreach ( $signatures as $where => $signature ) { - $pksig = md5( $where ); - unset( $wpdb->queries ); - $row = $wpdb->get_row( "SELECT * FROM `$table` WHERE $where" ); - if ( !$row ) { - $diff[$pksig] = array ( 'change' => 'deleted', 'where' => $where ); - continue; - } - $row = serialize( $row ); - $hash = md5( $row ); - if ( $hash != $signature ) - $diff[$pksig] = array( 'change' => 'modified', 'where' => $where, 'signature' => $hash, 'row' => $row ); - } - return $diff; - } - - function count( $columns ) { - global $wpdb; - if ( !is_array( $columns ) || !count( $columns ) ) - return false; - if ( !$this->table ) - return false; - $table = $wpdb->escape( $this->table ); - $column = $wpdb->escape( array_shift( $columns ) ); - return $wpdb->get_var( "SELECT COUNT( $column ) FROM `$table`" ); - } - - function wpdb( $query, $function='get_results' ) { - global $wpdb; - - if ( !is_callable( array( $wpdb, $function ) ) ) - return false; - - $res = $wpdb->$function( $query ); - if ( !$res ) - return $res; - switch ( $function ) { - case 'get_results': - foreach ( $res as $idx => $row ) { - if ( isset( $row->option_name ) && $row->option_name == 'cron' ) - $res[$idx]->option_value = serialize( array() ); - } - break; - case 'get_row': - if ( isset( $res->option_name ) && $res->option_name == 'cron' ) - $res->option_value = serialize( array() ); - break; - } - return $res; - } - - function get_cols( $columns, $limit=false, $offset=false, $where=false ) { - global $wpdb; - if ( !is_array( $columns ) || !count( $columns ) ) - return false; - if ( !$this->table ) - return false; - $table = $wpdb->escape( $this->table ); - $limitsql = ''; - $offsetsql = ''; - $wheresql = ''; - if ( $limit ) - $limitsql = ' LIMIT ' . intval( $limit ); - if ( $offset ) - $offsetsql = ' OFFSET ' . intval( $offset ); - if ( $where ) - $wheresql = ' WHERE ' . base64_decode($where); - $rval = array(); - foreach ( $wpdb->get_results( "SELECT * FROM `$this->table` $wheresql $limitsql $offsetsql" ) as $row ) { - // We don't need to actually record a real cron option value, just an empty array - if ( isset( $row->option_name ) && $row->option_name == 'cron' ) - $row->option_value = serialize( array() ); - $keys = array(); - $vals = array(); - foreach ( get_object_vars( $row ) as $i => $v ) { - $keys[] = sprintf( "`%s`", $wpdb->escape( $i ) ); - $vals[] = sprintf( "'%s'", $wpdb->escape( $v ) ); - if ( !in_array( $i, $columns ) ) - unset( $row->$i ); - } - $row->hash = md5( sprintf( "(%s) VALUES(%s)", implode( ',',$keys ), implode( ',',$vals ) ) ); - $rval[]=$row; - } - return $rval; - } -} \ No newline at end of file diff --git a/plugins/vaultpress/class.vaultpress-filesystem.php b/plugins/vaultpress/class.vaultpress-filesystem.php deleted file mode 100644 index 67427b66..00000000 --- a/plugins/vaultpress/class.vaultpress-filesystem.php +++ /dev/null @@ -1,217 +0,0 @@ -__construct(); - } - - function __construct() { - } - - function want( $type ) { - $vp = VaultPress::init(); - - if ( $type == 'plugins' ) { - $this->dir = realpath( $vp->resolve_content_dir() . 'plugins' ); - $this->type = 'p'; - return true; - } - if ( $type == 'themes' ) { - $this->dir = realpath( $vp->resolve_content_dir() . 'themes' ); - $this->type = 't'; - return true; - } - if ( $type == 'uploads' ) { - $this->dir = realpath( $vp->resolve_upload_path() ); - $this->type = 'u'; - return true; - } - if ( $type == 'content' ) { - $this->dir = realpath( $vp->resolve_content_dir() ); - $this->type = 'c'; - return true; - } - if ( $type == 'root' ) { - $this->dir = realpath( ABSPATH ); - $this->type = 'r'; - return true; - } - die( 'naughty naughty' ); - } - - function fdump( $file ) { - header("Content-Type: application/octet-stream;"); - header("Content-Transfer-Encoding: binary"); - @ob_end_clean(); - if ( !file_exists( $file ) || !is_readable( $file ) ) - die( "no such file" ); - if ( !is_file( $file ) && !is_link( $file ) ) - die( "can only dump files" ); - $fp = @fopen( $file, 'rb' ); - if ( !$fp ) - die( "could not open file" ); - while ( !feof( $fp ) ) - echo @fread( $fp, 8192 ); - @fclose( $fp ); - die(); - } - - function stat( $file, $md5=true, $sha1=true ) { - $rval = array(); - foreach ( stat( $file ) as $i => $v ) { - if ( is_numeric( $i ) ) - continue; - $rval[$i] = $v; - } - $rval['type'] = filetype( $file ); - if ( $rval['type'] == 'file' ) { - if ( $md5 ) - $rval['md5'] = md5_file( $file ); - if ( $sha1 ) - $rval['sha1'] = sha1_file( $file ); - } - $rval['path'] = str_replace( $this->dir, '', $file ); - return $rval; - } - - function ls( $what, $md5=false, $sha1=false, $limit=null, $offset=null ) { - clearstatcache(); - $path = realpath($this->dir . $what); - if ( is_file($path) ) - return $this->stat( $path, $md5, $sha1 ); - if ( is_dir($path) ) { - $entries = array(); - $current = 0; - $offset = (int)$offset; - $orig_limit = (int)$limit; - $limit = $offset + (int)$limit; - foreach ( (array)$this->scan_dir( $path ) as $i ) { - $current++; - if ( $offset >= $current ) - continue; - if ( $limit && $limit < $current ) - break; - - // don't sha1 files over 100MB if we are batching due to memory consumption - if ( $sha1 && $orig_limit > 1 && is_file( $i ) && (int)@filesize( $i ) > 104857600 ) - $sha1 = false; - - $entries[] = $this->stat( $i, $md5, $sha1 ); - } - return $entries; - } - } - - function validate( $file ) { - $rpath = realpath( $this->dir.$file ); - if ( !$rpath ) - die( serialize( array( 'type' => 'null', 'path' => $file ) ) ); - if ( is_dir( $rpath ) ) - $rpath = "$rpath/"; - if ( strpos( $rpath, $this->dir ) !== 0 ) - return false; - return true; - } - - function dir_examine( $subdir='', $recursive=true, $origin=false ) { - $res = array(); - if ( !$subdir ) - $subdir='/'; - $dir = $this->dir . $subdir; - if ( $origin === false ) - $origin = $this->dir . $subdir; - if ( is_file($dir) ) { - if ( $origin == $dir ) - $name = str_replace( $this->dir, '/', $subdir ); - else - $name = str_replace( $origin, '/', $dir ); - $res[$name] = $this->stat( $dir.$entry ); - return $res; - } - $d = dir( $dir ); - if ( !$d ) - return $res; - while ( false !== ( $entry = $d->read() ) ) { - $rpath = realpath( $dir.$entry ); - $bname = basename( $rpath ); - if ( is_link( $dir.$entry ) ) - continue; - if ( $entry == '.' || $entry == '..' || $entry == '...' ) - continue; - if ( !$this->validate( $subdir.$entry ) ) - continue; - $name = str_replace( $origin, '/', $dir.$entry ); - $res[$name] = $this->stat( $dir.$entry ); - if ( $recursive && is_dir( $this->dir.$subdir.'/'.$entry ) ) { - $res = array_merge( $res, $this->dir_examine( $subdir.$entry.'/', $recursive, $origin ) ); - } - } - return $res; - } - - function dir_checksum( $base, &$list, $recursive=true ) { - if ( $list == null ) - $list = array(); - - if ( 0 !== strpos( $base, $this->dir ) ) - $base = $this->dir . rtrim( $base, '/' ); - - $shortbase = substr( $base, strlen( $this->dir ) ); - if ( !$shortbase ) - $shortbase = '/'; - $stat = stat( $base ); - $directories = array(); - $files = (array)$this->scan_dir( $base ); - array_push( $files, $base ); - foreach ( $files as $file ) { - if ( $file !== $base && @is_dir( $file ) ) { - $directories[] = $file; - continue; - } - $stat = @stat( $file ); - if ( !$stat ) - continue; - $shortstat = array(); - foreach( $this->keys as $key ) { - if ( isset( $stat[$key] ) ) - $shortstat[$key] = $stat[$key]; - } - $list[$shortbase][basename( $file )] = $shortstat; - } - $list[$shortbase] = md5( serialize( $list[$shortbase] ) ); - if ( !$recursive ) - return $list; - foreach ( $directories as $dir ) { - $this->dir_checksum( $dir, $list, $recursive ); - } - return $list; - } - - function scan_dir( $path ) { - $files = array(); - - if ( false === is_readable( $path ) ) { - return array(); - } - - $dh = opendir( $path ); - - if ( false === $dh ) { - return array(); - } - - while ( false !== ( $file = readdir( $dh ) ) ) { - if ( $file == '.' || $file == '..' ) continue; - $files[] = "$path/$file"; - } - - closedir( $dh ); - sort( $files ); - return $files; - } -} diff --git a/plugins/vaultpress/class.vaultpress-hotfixes.php b/plugins/vaultpress/class.vaultpress-hotfixes.php deleted file mode 100644 index bd1ca836..00000000 --- a/plugins/vaultpress/class.vaultpress-hotfixes.php +++ /dev/null @@ -1,837 +0,0 @@ -__construct(); - } - - function __construct() { - global $wp_version; - - if ( version_compare( $wp_version, '3.0.2', '<' ) ) - add_filter( 'query', array( $this, 'r16625' ) ); - - if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST && version_compare( $wp_version, '3.0.3', '<' ) ) - add_action( 'xmlrpc_call', array( $this, 'r16803' ) ); - - if ( version_compare( $wp_version, '3.3.2', '<' ) ) { - add_filter( 'pre_kses', array( $this, 'r17172_wp_kses' ), 1, 3 ); - add_filter( 'clean_url', array( $this, 'r17172_esc_url' ), 1, 3 ); - } - - if ( version_compare( $wp_version, '3.1.3', '<' ) ) { - add_filter( 'sanitize_file_name', array( $this, 'r17990' ) ); - - if ( !empty( $_POST ) ) - $this->r17994( $_POST ); - // Protect add_meta, update_meta used by the XML-RPC API - add_filter( 'wp_xmlrpc_server_class', create_function( '$class', 'return \'VaultPress_XMLRPC_Server_r17994\';' ) ); - - // clean post_mime_type and guid (r17994) - add_filter( 'pre_post_mime_type', array( $this, 'r17994_sanitize_mime_type' ) ); - add_filter( 'post_mime_type', array( $this, 'r17994_sanitize_mime_type' ) ); - add_filter( 'pre_post_guid', 'esc_url_raw' ); - add_filter( 'post_guid', 'esc_url' ); - } - - if ( version_compare( $wp_version, '3.1.4', '<' ) ) { - add_filter( 'wp_insert_post_data', array( $this, 'r18368' ), 1, 2 ); - - // Add click jacking protection - // login_init does not exist before 17826. - $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login'; - add_action( 'login_form_' . $action, array( $this, 'r17826_send_frame_options_header' ), 10, 0 ); - add_action( 'admin_init', array( $this, 'r17826_send_frame_options_header' ), 10, 0 ); - - add_filter( 'sanitize_option_WPLANG', array( $this, 'r18346_sanitize_lang_on_save' ) ); - add_filter( 'sanitize_option_new_admin_email', array( $this, 'r18346_sanitize_admin_email_on_save' ) ); - } - add_filter( 'option_new_admin_email', array( $this, 'r18346_sanitize_admin_email' ) ); - - if ( version_compare( $wp_version, '3.3.2', '<' ) ) { - remove_filter( 'comment_text', 'make_clickable' ); - add_filter( 'comment_text', array( $this, 'r20493_make_clickable' ), 9 ); - - add_filter( 'comment_post_redirect', array( $this, 'r20486_comment_post_redirect' ) ); - } - - // WooThemes < 3.8.3, foxypress, asset-manager, wordpress-member-private-conversation. - $end_execution = false; - if ( isset( $_SERVER['SCRIPT_FILENAME'] ) ) - foreach ( array( 'preview-shortcode-external.php', 'uploadify.php', 'doupload.php', 'cef-upload.php', 'upload.php' ) as $vulnerable_script ) - if ( $vulnerable_script == basename( $_SERVER['SCRIPT_FILENAME'] ) ) { - switch( $vulnerable_script ) { - case 'upload.php': - $pma_config_file = realpath( dirname( $_SERVER['SCRIPT_FILENAME'] ) . DIRECTORY_SEPARATOR . 'paam-config-ajax.php' ); - if ( !in_array( $pma_config_file, get_included_files() ) ) - break; - default: - $end_execution = true; - break 2; - } - } - if ( $end_execution ) - die( 'Disabled for security reasons' ); - - if ( version_compare( $wp_version, '3.3.2', '>') && version_compare( $wp_version, '3.4.1', '<' ) ) { - add_filter( 'map_meta_cap', array( $this, 'r21138_xmlrpc_edit_posts' ), 10, 4 ); - add_action( 'map_meta_cap', array( $this, 'r21152_unfiltered_html' ), 10, 4 ); - } - - // https://core.trac.wordpress.org/changeset/21083 - if ( version_compare( $wp_version, '3.3', '>=') && version_compare( $wp_version, '3.3.3', '<' ) ) - add_filter( 'editable_slug', 'esc_textarea' ); - - add_filter( 'get_pagenum_link', array( $this, 'get_pagenum_link' ) ); - } - - function r21138_xmlrpc_edit_posts( $caps, $cap, $user_id, $args ) { - if ( ! isset( $args[0] ) || isset( $args[1] ) && $args[1] === 'hotfixed' ) - return $caps; - foreach ( get_post_types( array(), 'objects' ) as $post_type_object ) { - if ( $cap === $post_type_object->cap->edit_posts ) - return map_meta_cap( $post_type_object->cap->edit_post, $user_id, $args[0], 'hotfixed' ); - } - return $caps; - } - - function r21152_unfiltered_html( $caps, $cap, $user_id, $args ) { - if ( $cap !== 'unfiltered_html' ) - return $caps; - if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) - return $caps; - $key = array_search( 'do_not_allow', $caps ); - if ( false !== $key ) - return $caps; - if ( is_multisite() && ! is_super_admin( $user_id ) ) - $caps[$key] = 'do_not_allow'; - return $caps; - } - - function get_pagenum_link( $url ) { - return esc_url_raw( $url ); - } - - function r20486_comment_post_redirect( $location ) { - $location = wp_sanitize_redirect( $location ); - $location = wp_validate_redirect( $location, admin_url() ); - - return $location; - } - - function r20493_make_clickable( $text ) { - $r = ''; - $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags - foreach ( $textarr as $piece ) { - if ( empty( $piece ) || ( $piece[0] == '<' && ! preg_match('|^<\s*[\w]{1,20}+://|', $piece) ) ) { - $r .= $piece; - continue; - } - - // Long strings might contain expensive edge cases ... - if ( 10000 < strlen( $piece ) ) { - // ... break it up - foreach ( $this->r20493_split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses - if ( 2101 < strlen( $chunk ) ) { - $r .= $chunk; // Too big, no whitespace: bail. - } else { - $r .= $this->r20493_make_clickable( $chunk ); - } - } - } else { - $ret = " $piece "; // Pad with whitespace to simplify the regexes - - $url_clickable = '~ - ([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation - ( # 2: URL - [\\w]{1,20}+:// # Scheme and hier-part prefix - (?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long - [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character - (?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character - [\'.,;:!?)] # Punctuation URL character - [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character - )* - ) - (\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing) - ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character. - // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. - - $ret = preg_replace_callback( $url_clickable, array( $this, 'r20493_make_url_clickable_cb') , $ret ); - - $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); - $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); - - $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. - $r .= $ret; - } - } - - // Cleanup of accidental links within links - $r = preg_replace( '#(]+?>|>))]+?>([^>]+?)#i', "$1$3", $r ); - return $r; - } - - function r20493_make_url_clickable_cb($matches) { - $url = $matches[2]; - - if ( ')' == $matches[3] && strpos( $url, '(' ) ) { - // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL. - // Then we can let the parenthesis balancer do its thing below. - $url .= $matches[3]; - $suffix = ''; - } else { - $suffix = $matches[3]; - } - - // Include parentheses in the URL only if paired - while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { - $suffix = strrchr( $url, ')' ) . $suffix; - $url = substr( $url, 0, strrpos( $url, ')' ) ); - } - - $url = esc_url($url); - if ( empty($url) ) - return $matches[0]; - - return $matches[1] . "$url" . $suffix; - } - - function r20493_split_str_by_whitespace( $string, $goal ) { - $chunks = array(); - - $string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" ); - - while ( $goal < strlen( $string_nullspace ) ) { - $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" ); - - if ( false === $pos ) { - $pos = strpos( $string_nullspace, "\000", $goal + 1 ); - if ( false === $pos ) { - break; - } - } - - $chunks[] = substr( $string, 0, $pos + 1 ); - $string = substr( $string, $pos + 1 ); - $string_nullspace = substr( $string_nullspace, $pos + 1 ); - } - - if ( $string ) { - $chunks[] = $string; - } - - return $chunks; - } - - function r16625( $query ) { - // Hotfixes: http://core.trac.wordpress.org/changeset/16625 - - // Punt as fast as possible if this isn't an UPDATE - if ( substr( $query, 0, 6 ) != "UPDATE" ) - return $query; - global $wpdb; - - // Determine what the prefix of the bad query would look like and punt if this query doesn't match - $badstring = "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '"; - if ( substr( $query, 0, strlen( $badstring ) ) != $badstring ) - return $query; - - // Pull the post_id which is the last thing in the origin query, after a space, no quotes - $post_id = array_pop( explode( " ", $query ) ); - - // Chop off the beginning and end of the original query to get our unsanitized $tb_ping - $tb_ping = substr( - $query, - strlen( $badstring ), - ( - strlen( $query ) - ( - strlen( $badstring ) + strlen( sprintf( "', '')) WHERE ID = %d", $post_id ) ) - ) - ) - ); - - // Return the fixed query - return $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id ); - } - - function r16803( $xmlrpc_method ) { - // Hotfixes: http://core.trac.wordpress.org/changeset/16803 - global $wp_xmlrpc_server; - // Pretend that we are an xmlrpc method, freshly called - $args = $wp_xmlrpc_server->message->params; - $error_code = 401; - switch( $xmlrpc_method ) { - case 'metaWeblog.newPost': - $content_struct = $args[3]; - $publish = isset( $args[4] ) ? $args[4] : 0; - if ( !empty( $content_struct['post_type'] ) ) { - if ( $content_struct['post_type'] == 'page' ) { - if ( $publish || '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.' ); - } elseif ( $content_struct['post_type'] == 'post' ) { - if ( $publish || '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.' ); - } else { - $error_message = __( 'Invalid post type.' ); - } - } else { - if ( $publish || '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.' ); - } - if ( current_user_can( $cap ) ) - return true; - break; - case 'metaWeblog.editPost': - $post_ID = (int) $args[0]; - $content_struct = $args[3]; - $publish = $args[4]; - $cap = ( $publish ) ? 'publish_posts' : 'edit_posts'; - $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); - if ( !empty( $content_struct['post_type'] ) ) { - if ( $content_struct['post_type'] == 'page' ) { - if ( $publish || '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.' ); - } elseif ( $content_struct['post_type'] == 'post' ) { - if ( $publish || '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.' ); - } else { - $error_message = __( 'Invalid post type.' ); - } - } else { - if ( $publish || '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.' ); - } - if ( current_user_can( $cap ) ) - return true; - break; - case 'mt.publishPost': - $post_ID = (int) $args[0]; - if ( current_user_can( 'publish_posts' ) && current_user_can( 'edit_post', $post_ID ) ) - return true; - $error_message = __( 'Sorry, you cannot edit this post.' ); - break; - case 'blogger.deletePost': - $post_ID = (int) $args[1]; - if ( current_user_can( 'delete_post', $post_ID ) ) - return true; - $error_message = __( 'Sorry, you do not have the right to delete this post.' ); - break; - case 'wp.getPageStatusList': - if ( current_user_can( 'edit_pages' ) ) - return true; - $error_code = 403; - $error_message = __( 'You are not allowed access to details about this site.' ); - break; - case 'wp.deleteComment': - case 'wp.editComment': - $comment_ID = (int) $args[3]; - if ( !$comment = get_comment( $comment_ID ) ) - return true; // This will be handled in the calling function explicitly - if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) - return true; - $error_code = 403; - $error_message = __( 'You are not allowed to moderate comments on this site.' ); - break; - default: - return true; - } - // If we are here then this was a handlable xmlrpc call and the capability checks above all failed - // ( otherwise they would have returned to the do_action from the switch statement above ) so it's - // time to exit with whatever error we've determined is the problem (thus short circuiting the - // original XMLRPC method call, and enforcing the above capability checks -- with an ax. We'll - // mimic the behavior from the end of IXR_Server::serve() - $r = new IXR_Error( $error_code, $error_message ); - $resultxml = $r->getXml(); - $xml = << - - - - $resultxml - - - - -EOD; - $wp_xmlrpc_server->output( $xml ); - // For good measure... - die(); - } - - function r17172_esc_url( $url, $original_url, $_context ) { - $url = $original_url; - - if ( '' == $url ) - return $url; - $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url); - $strip = array('%0d', '%0a', '%0D', '%0A'); - $url = _deep_replace($strip, $url); - $url = str_replace(';//', '://', $url); - /* If the URL doesn't appear to contain a scheme, we - * presume it needs http:// appended (unless a relative - * link starting with /, # or ? or a php file). - */ - if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) && - ! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) - $url = 'http://' . $url; - - // Replace ampersands and single quotes only when displaying. - if ( 'display' == $_context ) { - $url = wp_kses_normalize_entities( $url ); - $url = str_replace( '&', '&', $url ); - $url = str_replace( "'", ''', $url ); - } - - $protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn'); - if ( VaultPress_kses::wp_kses_bad_protocol( $url, $protocols ) != $url ) - return ''; - return $url; - } - - // http://core.trac.wordpress.org/changeset/17172 - // http://core.trac.wordpress.org/changeset/20541 - function r17172_wp_kses( $string, $html, $protocols ) { - return VaultPress_kses::wp_kses( $string, $html, $protocols ); - } - - // http://core.trac.wordpress.org/changeset/17990 - function r17990( $filename ) { - $parts = explode('.', $filename); - $filename = array_shift($parts); - $extension = array_pop($parts); - $mimes = get_allowed_mime_types(); - - // Loop over any intermediate extensions. Munge them with a trailing underscore if they are a 2 - 5 character - // long alpha string not in the extension whitelist. - foreach ( (array) $parts as $part) { - $filename .= '.' . $part; - - if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) { - $allowed = false; - foreach ( $mimes as $ext_preg => $mime_match ) { - $ext_preg = '!^(' . $ext_preg . ')$!i'; - if ( preg_match( $ext_preg, $part ) ) { - $allowed = true; - break; - } - } - if ( !$allowed ) - $filename .= '_'; - } - } - $filename .= '.' . $extension; - return $filename; - } - - /* - * Hotfixes: http://core.trac.wordpress.org/changeset/18368 - */ - function r18368( $post, $raw_post ) { - if ( isset( $post['filter'] ) || isset ( $raw_post['filter'] ) ) { - unset( $post['filter'], $raw_post['filter'] ); // to ensure the post is properly sanitized - $post = sanitize_post($post, 'db'); - } - if ( empty( $post['ID'] ) ) - unset( $post['ID'] ); // sanitize_post - unset( $post['filter'] ); // sanitize_post - return $post; - } - - /** - * Protect WordPress internal metadata. - * - * The post data is passed as a parameter to (unit) test this method. - * @param $post_data|array the $_POST array. - */ - function r17994( &$post_data ) { - // Protect admin-ajax add_meta - $metakeyselect = isset( $post_data['metakeyselect'] ) ? stripslashes( trim( $post_data['metakeyselect'] ) ) : ''; - $metakeyinput = isset( $post_data['metakeyinput'] ) ? stripslashes( trim( $post_data['metakeyinput'] ) ) : ''; - - if ( ( $metakeyselect && '_' == $metakeyselect[0] ) || ( $metakeyinput && '_' == $metakeyinput[0] ) ) { - unset( $_POST['metakeyselect'], $_POST['metakeyinput'] ); - } - - // Protect admin-ajax update_meta - if ( isset( $post_data['meta'] ) ) { - foreach ( (array)$post_data['meta'] as $mid => $value ) { - $key = stripslashes( $post_data['meta'][$mid]['key'] ); - if ( $key && '_' == $key[0] ) - unset( $post_data['meta'][$mid] ); - } - } - } - - function r17994_sanitize_mime_type( $mime_type ) { - $sani_mime_type = preg_replace( '/[^\-*.a-zA-Z0-9\/+]/', '', $mime_type ); - return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type ); - } - - function r17826_send_frame_options_header() { - @header( 'X-Frame-Options: SAMEORIGIN' ); - } - - function r18346_sanitize_admin_email_on_save($value) { - $value = sanitize_email( $value ); - if ( !is_email( $value ) ) { - $value = get_option( 'new_admin_email' ); // Resets option to stored value in the case of failed sanitization - if ( function_exists( 'add_settings_error' ) ) - add_settings_error( 'new_admin_email', 'invalid_admin_email', __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' ) ); - } - return $value; - } - - function r18346_sanitize_admin_email( $value ) { - return sanitize_email( $value ); // Is it enough ? - } - - function r18346_sanitize_lang_on_save( $value ) { - $value = $this->r18346_sanitize_lang( $value ); // sanitize the new value. - if ( empty( $value ) ) - $value = get_option( 'WPLANG' ); - return $value; - } - - function r18346_sanitize_lang( $value ) { - $allowed = apply_filters( 'available_languages', get_available_languages() ); // add a filter to unit test - if ( !empty( $value ) && !in_array( $value, $allowed ) ) - return false; - else - return $value; - } -} - -global $wp_version; -$needs_class_fix = version_compare( $wp_version, '3.1', '>=') && version_compare( $wp_version, '3.1.3', '<' ); -if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST && $needs_class_fix ) { - include_once( ABSPATH . WPINC . '/class-IXR.php' ); - include_once( ABSPATH . WPINC . '/class-wp-xmlrpc-server.php' ); - - class VaultPress_XMLRPC_Server_r17994 extends wp_xmlrpc_server { - function set_custom_fields( $post_id, $fields ) { - foreach( $fields as $k => $meta ) { - $key = stripslashes( trim( $meta['key'] ) ); - if ( $key && '_' == $key[0] ) - unset( $fields[$k] ); - } - parent::set_custom_fields( $post_id, $fields ); - } - } -} - -class VaultPress_kses { - static function wp_kses($string, $allowed_html, $allowed_protocols = array ()) { - $string = wp_kses_no_null($string); - $string = wp_kses_js_entities($string); - $string = wp_kses_normalize_entities($string); - return VaultPress_kses::wp_kses_split($string, $allowed_html, $allowed_protocols); - } - - static function wp_kses_split($string, $allowed_html, $allowed_protocols) { - global $pass_allowed_html, $pass_allowed_protocols; - $pass_allowed_html = $allowed_html; - $pass_allowed_protocols = $allowed_protocols; - return preg_replace_callback( '%(|$))|(<[^>]*(>|$)|>)%', 'VaultPress_kses::_vp_kses_split_callback', $string ); - } - - static function _vp_kses_split_callback( $match ) { - global $pass_allowed_html, $pass_allowed_protocols; - return VaultPress_kses::wp_kses_split2( $match[0], $pass_allowed_html, $pass_allowed_protocols ); - } - - static function wp_kses_split2($string, $allowed_html, $allowed_protocols) { - $string = wp_kses_stripslashes($string); - - if (substr($string, 0, 1) != '<') - return '>'; - # It matched a ">" character - - if ( ''), '', $string ); - while ( $string != ($newstring = VaultPress_kses::wp_kses($string, $allowed_html, $allowed_protocols)) ) - $string = $newstring; - if ( $string == '' ) - return ''; - // prevent multiple dashes in comments - $string = preg_replace('/--+/', '-', $string); - // prevent three dashes closing a comment - $string = preg_replace('/-$/', '', $string); - return ""; - } - # Allow HTML comments - - if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) - return ''; - # It's seriously malformed - - $slash = trim($matches[1]); - $elem = $matches[2]; - $attrlist = $matches[3]; - - if ( ! isset($allowed_html[strtolower($elem)]) ) - return ''; - # They are using a not allowed HTML element - - if ($slash != '') - return ""; - # No attributes are allowed for closing elements - - return VaultPress_kses::wp_kses_attr( $elem, $attrlist, $allowed_html, $allowed_protocols ); - } - - static function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) { - # Is there a closing XHTML slash at the end of the attributes? - - $xhtml_slash = ''; - if (preg_match('%\s*/\s*$%', $attr)) - $xhtml_slash = ' /'; - - # Are any attributes allowed at all for this element? - if ( ! isset($allowed_html[strtolower($element)]) || count($allowed_html[strtolower($element)]) == 0 ) - return "<$element$xhtml_slash>"; - - # Split it - $attrarr = VaultPress_kses::wp_kses_hair($attr, $allowed_protocols); - - # Go through $attrarr, and save the allowed attributes for this element - # in $attr2 - $attr2 = ''; - - $allowed_attr = $allowed_html[strtolower($element)]; - foreach ($attrarr as $arreach) { - if ( ! isset( $allowed_attr[strtolower($arreach['name'])] ) ) - continue; # the attribute is not allowed - - $current = $allowed_attr[strtolower($arreach['name'])]; - if ( $current == '' ) - continue; # the attribute is not allowed - - if ( strtolower( $arreach['name'] ) == 'style' ) { - $orig_value = $arreach['value']; - $value = safecss_filter_attr( $orig_value ); - - if ( empty( $value ) ) - continue; - - $arreach['value'] = $value; - $arreach['whole'] = str_replace( $orig_value, $value, $arreach['whole'] ); - } - - if ( ! is_array($current) ) { - $attr2 .= ' '.$arreach['whole']; - # there are no checks - - } else { - # there are some checks - $ok = true; - foreach ($current as $currkey => $currval) { - if ( ! wp_kses_check_attr_val($arreach['value'], $arreach['vless'], $currkey, $currval) ) { - $ok = false; - break; - } - } - - if ( $ok ) - $attr2 .= ' '.$arreach['whole']; # it passed them - } # if !is_array($current) - } # foreach - - # Remove any "<" or ">" characters - $attr2 = preg_replace('/[<>]/', '', $attr2); - - return "<$element$attr2$xhtml_slash>"; - } - - static function wp_kses_hair($attr, $allowed_protocols) { - $attrarr = array (); - $mode = 0; - $attrname = ''; - $uris = array('xmlns', 'profile', 'href', 'src', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action'); - - # Loop through the whole attribute list - - while (strlen($attr) != 0) { - $working = 0; # Was the last operation successful? - - switch ($mode) { - case 0 : # attribute name, href for instance - - if (preg_match('/^([-a-zA-Z]+)/', $attr, $match)) { - $attrname = $match[1]; - $working = $mode = 1; - $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr); - } - - break; - - case 1 : # equals sign or valueless ("selected") - - if (preg_match('/^\s*=\s*/', $attr)) # equals sign - { - $working = 1; - $mode = 2; - $attr = preg_replace('/^\s*=\s*/', '', $attr); - break; - } - - if (preg_match('/^\s+/', $attr)) # valueless - { - $working = 1; - $mode = 0; - if(false === array_key_exists($attrname, $attrarr)) { - $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); - } - $attr = preg_replace('/^\s+/', '', $attr); - } - - break; - - case 2 : # attribute value, a URL after href= for instance - - if (preg_match('%^"([^"]*)"(\s+|/?$)%', $attr, $match)) - # "value" - { - $thisval = $match[1]; - if ( in_array(strtolower($attrname), $uris) ) - $thisval = VaultPress_kses::wp_kses_bad_protocol($thisval, $allowed_protocols); - - if(false === array_key_exists($attrname, $attrarr)) { - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); - } - $working = 1; - $mode = 0; - $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr); - break; - } - - if (preg_match("%^'([^']*)'(\s+|/?$)%", $attr, $match)) - # 'value' - { - $thisval = $match[1]; - if ( in_array(strtolower($attrname), $uris) ) - $thisval = VaultPress_kses::wp_kses_bad_protocol($thisval, $allowed_protocols); - - if(false === array_key_exists($attrname, $attrarr)) { - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n'); - } - $working = 1; - $mode = 0; - $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr); - break; - } - - if (preg_match("%^([^\s\"']+)(\s+|/?$)%", $attr, $match)) - # value - { - $thisval = $match[1]; - if ( in_array(strtolower($attrname), $uris) ) - $thisval = VaultPress_kses::wp_kses_bad_protocol($thisval, $allowed_protocols); - - if(false === array_key_exists($attrname, $attrarr)) { - $attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n'); - } - # We add quotes to conform to W3C's HTML spec. - $working = 1; - $mode = 0; - $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr); - } - - break; - } # switch - - if ($working == 0) # not well formed, remove and try again - { - $attr = wp_kses_html_error($attr); - $mode = 0; - } - } # while - - if ($mode == 1 && false === array_key_exists($attrname, $attrarr)) - # special case, for when the attribute list ends with a valueless - # attribute like "selected" - $attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y'); - - return $attrarr; - } - - static function wp_kses_bad_protocol($string, $allowed_protocols) { - $string = wp_kses_no_null($string); - $iterations = 0; - - do { - $original_string = $string; - $string = VaultPress_kses::wp_kses_bad_protocol_once($string, $allowed_protocols); - } while ( $original_string != $string && ++$iterations < 6 ); - - if ( $original_string != $string ) - return ''; - - return $string; - } - - static function wp_kses_bad_protocol_once($string, $allowed_protocols, $count = 1) { - $string2 = preg_split( '/:|�*58;|�*3a;/i', $string, 2 ); - if ( isset($string2[1]) && ! preg_match('%/\?%', $string2[0]) ) { - $string = trim( $string2[1] ); - $protocol = VaultPress_kses::wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ); - if ( 'feed:' == $protocol ) { - if ( $count > 2 ) - return ''; - $string = VaultPress_kses::wp_kses_bad_protocol_once( $string, $allowed_protocols, ++$count ); - if ( empty( $string ) ) - return $string; - } - $string = $protocol . $string; - } - - return $string; - } - - static function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) { - $string2 = wp_kses_decode_entities($string); - $string2 = preg_replace('/\s/', '', $string2); - $string2 = wp_kses_no_null($string2); - $string2 = strtolower($string2); - - $allowed = false; - foreach ( (array) $allowed_protocols as $one_protocol ) - if ( strtolower($one_protocol) == $string2 ) { - $allowed = true; - break; - } - - if ($allowed) - return "$string2:"; - else - return ''; - } - -} - -if ( !function_exists( 'get_available_languages' ) ) { - function get_available_languages( $dir = null ) { - $languages = array(); - foreach( glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) - if ( false === strpos( $lang_file, 'continents-cities' ) ) - $languages[] = basename($lang_file, '.mo'); - return $languages; - } -} diff --git a/plugins/vaultpress/class.vaultpress-ixr-ssl-client.php b/plugins/vaultpress/class.vaultpress-ixr-ssl-client.php deleted file mode 100644 index 65e340ea..00000000 --- a/plugins/vaultpress/class.vaultpress-ixr-ssl-client.php +++ /dev/null @@ -1,132 +0,0 @@ -IXR_Client( $server, $path, $port, $timeout ); - } - function ssl( $port=443 ) { - if ( !extension_loaded( 'openssl' ) ) - return; - - $this->ssl = true; - if ( $port ) - $this->port = $port; - } - 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"; - - $this->headers['Host'] = preg_replace( '#^ssl://#', '', $this->server ); - $this->headers['Content-Type'] = 'text/xml'; - $this->headers['User-Agent'] = $this->useragent; - $this->headers['Content-Length'] = $length; - - if ( class_exists( 'WP_Http' ) ) { - $args = array( - 'method' => 'POST', - 'body' => $xml, - 'headers' => $this->headers, - 'sslverify' => false, - ); - if ( $this->timeout ) - $args['timeout'] = $this->timeout; - - $http = new WP_Http(); - if ( $this->ssl ) - $url = sprintf( 'https://%s%s', $this->server, $this->path ); - else - $url = sprintf( 'http://%s%s', $this->server, $this->path ); - - $result = $http->request( $url, $args ); - if ( is_wp_error( $result ) ) { - foreach( $result->errors as $type => $messages ) { - $this->error = new IXR_Error( - -32702, - sprintf( 'WP_Http error: %s, %s', $type, $messages[0] ) - ); - break; - } - return false; - } else if ( $result['response']['code'] > 299 || $result['response']['code'] < 200 ) { - $this->error = new IXR_Error( - -32701, - sprintf( 'Server rejected request (HTTP response: %s %s)', $result['response']['code'], $result['response']['message']) - ); - return false; - } - // Now parse what we've got back - $this->message = new IXR_Message( $result['body'] ); - } else { - foreach( $this->headers as $header => $value ) { - $request .= "{$header}: {$value}{$r}"; - } - $request .= $r; - - $request .= $xml; - // Now send the request - if ( $this->ssl ) - $host = 'ssl://'.$this->server; - else - $host = $this->server; - if ($this->timeout) { - $fp = @fsockopen( $host, $this->port, $errno, $errstr, $this->timeout ); - } else { - $fp = @fsockopen( $host, $this->port, $errno, $errstr ); - } - if (!$fp) { - $this->error = new IXR_Error( -32300, "Transport error - could not open socket: $errno $errstr" ); - return false; - } - fputs( $fp, $request ); - - $contents = ''; - $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( -32301, 'transport error - HTTP status code was not 200' ); - return false; - } - $gotFirstLine = true; - } - if ( trim($line) == '' ) { - $gettingHeaders = false; - } - if ( !$gettingHeaders ) { - $contents .= trim( $line ); - } - } - // 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; - } -} \ No newline at end of file diff --git a/plugins/vaultpress/cron-tasks.php b/plugins/vaultpress/cron-tasks.php deleted file mode 100644 index 00aac6a1..00000000 --- a/plugins/vaultpress/cron-tasks.php +++ /dev/null @@ -1,152 +0,0 @@ - 300, - 'display' => __( 'Once every five minutes' , 'vaultpress'), - ); - return $schedules; - } - - function _scan_site() { - if ( !get_option( '_vp_current_scan' ) ) { - $paths = array( 'root' => new VP_FileScan( ABSPATH ) ); - - // Is WP_CONTENT_DIR inside ABSPATH? - if ( is_dir( WP_CONTENT_DIR ) && strpos( realpath( WP_CONTENT_DIR ), realpath( ABSPATH ) . DIRECTORY_SEPARATOR ) !== 0 ) - $paths['content'] = new VP_FileScan( WP_CONTENT_DIR ); - - // Is WP_PLUGIN_DIR inside ABSPATH or WP_CONTENT_DIR? - if ( is_dir( WP_PLUGIN_DIR ) && strpos( realpath( WP_PLUGIN_DIR ), realpath( WP_CONTENT_DIR ) . DIRECTORY_SEPARATOR ) !== 0 && strpos( realpath( WP_PLUGIN_DIR ), realpath( ABSPATH ) . DIRECTORY_SEPARATOR ) !== 0 ) - $paths['plugins'] = new VP_FileScan( WP_PLUGIN_DIR ); - - // Is WPMU_PLUGIN_DIR inside ABSPATH or WP_CONTENT_DIR? - if ( is_dir( WPMU_PLUGIN_DIR ) && strpos( realpath( WPMU_PLUGIN_DIR ), realpath( WP_CONTENT_DIR ) . DIRECTORY_SEPARATOR ) !== 0 && strpos( realpath( WPMU_PLUGIN_DIR ), realpath( ABSPATH ) . DIRECTORY_SEPARATOR ) !== 0 ) - $paths['mu-plugins'] = new VP_FileScan( WPMU_PLUGIN_DIR ); - - update_option( '_vp_current_scan', $paths ); - } - } - - function _scan_clean_up( &$paths, $type = null ) { - if( is_array( $paths ) ) - unset( $paths[$type] ); - if ( empty( $paths ) || !is_array( $paths ) ) { - delete_option( '_vp_current_scan' ); - return true; - } - return false; - } - - function _scan_batch() { - $paths = get_option( '_vp_current_scan' ); - if ( empty( $paths ) || $this->_scan_clean_up( $paths ) ) - return false; - - reset( $paths ); - list( $type, $current ) = each( $paths ); - if ( !is_object( $current ) || empty( $current->last_dir ) ) - return $this->_scan_clean_up( $paths, $type ); - - $default_batch_limit = 400; - if ( function_exists( 'set_time_limit' ) ) - set_time_limit(0); - else - $default_batch_limit = 100; // avoid timeouts - - $GLOBALS['vp_signatures'] = get_option( '_vp_signatures' ); - if ( empty( $GLOBALS['vp_signatures'] ) ) - return false; - - $limit = get_option( '_vp_batch_file_size', $default_batch_limit ); - $files = $current->get_files( $limit ); - - // No more files to scan. - if ( !$current->last_dir || count( $files ) < $limit ) - unset( $paths[$type] ); - - update_option( '_vp_current_scan', $paths ); - $results = array(); - foreach ( $files as $file ) { - $verdict = vp_scan_file( $file ); - if ( !empty( $verdict ) ) - $results[$file] = array( 'hash' => @md5_file( $file ), 'verdict' => $verdict ); - } - - if ( !empty( $results ) ) { - $vaultpress = VaultPress::init(); - $vaultpress->add_ping( 'security', array( 'suspicious_v2' => $results ) ); - } - } - - function &init() { - static $instance = false; - if ( !$instance ) - $instance = new VP_Site_Scanner(); - return $instance; - } -} -VP_Site_Scanner::init(); diff --git a/plugins/vaultpress/vaultpress.php b/plugins/vaultpress/vaultpress.php deleted file mode 100644 index 9914934e..00000000 --- a/plugins/vaultpress/vaultpress.php +++ /dev/null @@ -1,2001 +0,0 @@ -realtime backup and automated security scanning from VaultPress. Activate, enter your registration key, and never worry again. Need some help? - * Version: 1.3.9 - * Author: Automattic - * Author URI: http://vaultpress.com/?utm_source=author-uri&utm_medium=plugin-description&utm_campaign=1.0 - * License: GPL2+ - * Text Domain: vaultpress - * Domain Path: /languages/ - */ - -// don't call the file directly -if ( !defined( 'ABSPATH' ) ) - return; - -class VaultPress { - var $option_name = 'vaultpress'; - var $db_version = 2; - var $plugin_version = '1.3.8'; - - function VaultPress() { - $this->__construct(); - } - - function __construct() { - register_activation_hook( __FILE__, array( $this, 'activate' ) ); - register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) ); - - $options = get_option( $this->option_name ); - if ( !is_array( $options ) ) - $options = array(); - - $defaults = array( - 'db_version' => 0, - 'key' => '', - 'secret' => '', - 'connection' => false, - 'service_ips' => false - ); - - $this->options = wp_parse_args( $options, $defaults ); - $this->reset_pings(); - - $this->upgrade(); - - if ( is_admin() ) - $this->add_admin_actions_and_filters(); - - if ( $this->is_registered() ) { - $do_not_backup = $this->get_option( 'do_not_backup' ); - if ( $do_not_backup ) - $this->add_vp_required_filters(); - else - $this->add_listener_actions_and_filters(); - } - } - - function &init() { - static $instance = false; - - if ( !$instance ) { - $instance = new VaultPress(); - } - - return $instance; - } - - function activate( $network_wide ) { - $type = $network_wide ? 'network' : 'single'; - $this->update_option( 'activated', $type ); - - // force a connection check after an activation - $this->clear_connection(); - } - - function deactivate() { - if ( $this->is_registered() ) - $this->contact_service( 'plugin_status', array( 'vp_plugin_status' => 'deactivated' ) ); - } - - function upgrade() { - $current_db_version = $this->get_option( 'db_version' ); - - if ( $current_db_version < 1 ) { - $this->options['connection'] = get_option( 'vaultpress_connection' ); - $this->options['key'] = get_option( 'vaultpress_key' ); - $this->options['secret'] = get_option( 'vaultpress_secret' ); - $this->options['service_ips'] = get_option( 'vaultpress_service_ips' ); - - // remove old options - $old_options = array( - 'vaultpress_connection', - 'vaultpress_hostname', - 'vaultpress_key', - 'vaultpress_secret', - 'vaultpress_service_ips', - 'vaultpress_timeout', - 'vp_allow_remote_execution', - 'vp_debug_request_signing', - 'vp_disable_firewall', - ); - - foreach ( $old_options as $option ) - delete_option( $option ); - - $this->options['db_version'] = $this->db_version; - $this->update_options(); - } - - if ( $current_db_version < 2 ) { - $this->delete_option( 'timeout' ); - $this->delete_option( 'disable_firewall' ); - $this->update_option( 'db_version', $this->db_version ); - $this->clear_connection(); - } - } - - function get_option( $key ) { - if ( 'hostname' == $key ) { - if ( defined( 'VAULTPRESS_HOSTNAME' ) ) - return VAULTPRESS_HOSTNAME; - else - return 'vaultpress.com'; - } - - if ( 'timeout' == $key ) { - if ( defined( 'VAULTPRESS_TIMEOUT' ) ) - return VAULTPRESS_TIMEOUT; - else - return 60; - } - - if ( 'disable_firewall' == $key ) { - if ( defined( 'VAULTPRESS_DISABLE_FIREWALL' ) ) - return VAULTPRESS_DISABLE_FIREWALL; - else - return false; - } - - if ( isset( $this->options[$key] ) ) - return $this->options[$key]; - - return false; - } - - function update_option( $key, $value ) { - $this->options[$key] = $value; - $this->update_options(); - } - - function delete_option( $key ) { - unset( $this->options[$key] ); - $this->update_options(); - } - - function update_options() { - update_option( $this->option_name, $this->options ); - } - - function admin_init() { - if ( !current_user_can( 'manage_options' ) ) - return; - - load_plugin_textdomain( 'vaultpress', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); - } - - function admin_head() { - if ( !current_user_can( 'manage_options' ) ) - return; - - if ( $activated = $this->get_option( 'activated' ) ) { - if ( 'network' == $activated ) { - add_action( 'network_admin_notices', array( $this, 'activated_notice' ) ); - } else { - foreach ( array( 'user_admin_notices', 'admin_notices' ) as $filter ) - add_action( $filter, array( $this, 'activated_notice' ) ); - } - } - - // ask the user to connect their site w/ VP - if ( !$this->is_registered() ) { - foreach ( array( 'user_admin_notices', 'admin_notices' ) as $filter ) - add_action( $filter, array( $this, 'connect_notice' ) ); - - // if we have an error make sure to let the user know about it - } else { - $error_code = $this->get_option( 'connection_error_code' ); - if ( !empty( $error_code ) ) { - foreach ( array( 'user_admin_notices', 'admin_notices' ) as $filter ) - add_action( $filter, array( $this, 'error_notice' ) ); - } - } - ?> - - - - load_menu(); - } - - function load_menu() { - if ( class_exists( 'Jetpack' ) ) { - $hook = add_submenu_page( 'jetpack', 'VaultPress', 'VaultPress', 'manage_options', 'vaultpress', array( $this, 'ui' ) ); - } else { - $hook = add_menu_page( 'VaultPress', 'VaultPress', 'manage_options', 'vaultpress', array( $this, 'ui' ), 'div' ); - } - - add_action( "load-$hook", array( $this, 'ui_load' ) ); - add_action( 'admin_print_styles', array( $this, 'styles' ) ); - } - - function styles() { - if ( !current_user_can( 'manage_options' ) ) - return; - - // force the cache to bust every day - wp_enqueue_style( 'vaultpress', $this->server_url() . 'css/plugin.css' , false, date( 'Ymd' ) ); - } - - // display a security threat notice if one exists - function toolbar( $wp_admin_bar ) { - global $wp_version; - - // these new toolbar functions were introduced in 3.3 - // http://codex.wordpress.org/Function_Reference/add_node - if ( version_compare( $wp_version, '3.3', '<') ) - return; - - if ( !current_user_can( 'manage_options' ) ) - return; - - $messages = $this->get_messages(); - if ( !empty( $messages['security_notice_count'] ) ) { - $count = (int)$messages['security_notice_count']; - if ( $count > 0 ) { - $count = number_format( $count, 0 ); - $wp_admin_bar->add_node( array( - 'id' => 'vp-notice', - 'title' => '' . - sprintf( _n( '%s Security Threat', '%s Security Threats', $count , 'vaultpress'), $count ) . - ' ', - 'parent' => 'top-secondary', - 'href' => sprintf( 'https://dashboard.vaultpress.com/%d/security/', $messages['site_id'] ), - 'meta' => array( - 'title' => __( 'Visit VaultPress Security' , 'vaultpress'), - 'onclick' => 'window.open( this.href ); return false;', - 'class' => 'error' - ), - ) ); - } - } - } - - // get any messages from the VP servers - function get_messages( $force_reload = false ) { - $last_contact = $this->get_option( 'messages_last_contact' ); - - // only run the messages check every 30 minutes - if ( ( time() - (int)$last_contact ) > 1800 || $force_reload ) { - $messages = base64_decode( $this->contact_service( 'messages', array() ) ); - $messages = unserialize( $messages ); - $this->update_option( 'messages_last_contact', time() ); - $this->update_option( 'messages', $messages ); - } else { - $messages = $this->get_option( 'messages' ); - } - - return $messages; - } - - function server_url() { - if ( !isset( $this->_server_url ) ) { - $scheme = is_ssl() ? 'https' : 'http'; - $this->_server_url = sprintf( '%s://%s/', $scheme, $this->get_option( 'hostname' ) ); - } - - return $this->_server_url; - } - - // show message if plugin is activated but not connected to VaultPress - function connect_notice() { - if ( isset( $_GET['page'] ) && 'vaultpress' == $_GET['page'] ) - return; - - $message = sprintf( - __( 'You must enter your registration key before VaultPress can back up and secure your site. Register VaultPress', 'vaultpress' ), - admin_url( 'admin.php?page=vaultpress' ) - ); - $this->ui_message( $message, 'notice', __( 'VaultPress needs your attention!', 'vaultpress' ) ); - } - - // show message after activation - function activated_notice() { - if ( 'network' == $this->get_option( 'activated' ) ) { - $message = sprintf( - __( 'Each site will need to be registered with VaultPress separately. You can purchase new keys from your VaultPress Dashboard.', 'vaultpress' ), - 'https://dashboard.vaultpress.com/' - ); - $this->ui_message( $message, 'activated', __( 'VaultPress has been activated across your network!', 'vaultpress' ) ); - - // key and secret already exist in db - } elseif ( $this->is_registered() ) { - if ( $this->check_connection() ) { - $message = sprintf( - __( 'VaultPress has been registered and is currently backing up your site. View Backup Status', 'vaultpress' ), - admin_url( 'admin.php?page=vaultpress' ) - ); - $this->ui_message( $message, 'registered', __( 'VaultPress has been activated!', 'vaultpress' ) ); - } - } - - $this->delete_option( 'activated' ); - } - - function error_notice() { - $error_message = $this->get_option( 'connection_error_message' ); - - // link to the VaultPress page if we're not already there - if ( !isset( $_GET['page'] ) || 'vaultpress' != $_GET['page'] ) - $error_message .= ' ' . sprintf( '%s', admin_url( 'admin.php?page=vaultpress' ), __( 'Visit the VaultPress page' , 'vaultpress') ); - - if ( !empty( $error_message ) ) - $this->ui_message( $error_message, 'error' ); - } - - function ui() { - if ( !empty( $_GET['error'] ) ) { - $this->error_notice(); - $this->clear_connection(); - } - - if ( !$this->is_registered() ) { - $this->ui_register(); - return; - } - - $status = $this->contact_service( 'status' ); - if ( !$status ) { - $error_code = $this->get_option( 'connection_error_code' ); - if ( 0 == $error_code ) - $this->ui_fatal_error(); - else - $this->ui_register(); - return; - } - - $ticker = $this->contact_service( 'ticker' ); - if ( is_array( $ticker ) && isset( $ticker['faultCode'] ) ) { - $this->error_notice(); - $this->ui_register(); - return; - } - - $this->ui_main(); - } - - function ui_load() { - if ( !current_user_can( 'manage_options' ) ) - return; - - // run code that might be updating the registration key - if ( isset( $_POST['action'] ) && 'register' == $_POST['action'] ) { - check_admin_referer( 'vaultpress_register' ); - - // reset the connection info so messages don't cross - $this->clear_connection(); - - $registration_key = trim( $_POST[ 'registration_key' ] ); - if ( empty( $registration_key ) ) { - $this->update_option( 'connection_error_code', 1 ); - $this->update_option( - 'connection_error_message', - sprintf( - __( 'That\'s not a valid registration key. Head over to the VaultPress Dashboard to find your key.', 'vaultpress' ), - 'https://dashboard.vaultpress.com/' - ) - ); - wp_redirect( admin_url( 'admin.php?page=vaultpress&error=true' ) ); - exit(); - } - - // try to register the plugin - $nonce = wp_create_nonce( 'vp_register_' . $registration_key ); - $args = array( 'registration_key' => $registration_key, 'nonce' => $nonce ); - $response = $this->contact_service( 'register', $args ); - - // we received an error from the VaultPress servers - if ( !empty( $response['faultCode'] ) ) { - $this->update_option( 'connection_error_code', $response['faultCode'] ); - $this->update_option( 'connection_error_message', $response['faultString'] ); - wp_redirect( admin_url( 'admin.php?page=vaultpress&error=true' ) ); - exit(); - } - - // make sure the returned data looks valid - if ( empty( $response['key'] ) || empty( $response['secret'] ) || empty( $response['nonce'] ) || $nonce != $response['nonce'] ) { - $this->update_option( 'connection_error_code', 1 ); - $this->update_option( 'connection_error_message', sprintf( __( 'There was a problem trying to register your subscription. Please try again. If you’re still having issues please contact the VaultPress Safekeepers.', 'vaultpress' ), 'http://vaultpress.com/contact/' ) ); - wp_redirect( admin_url( 'admin.php?page=vaultpress&error=true' ) ); - exit(); - } - - // need to update these values in the db so the servers can try connecting to the plugin - $this->update_option( 'key', $response['key'] ); - $this->update_option( 'secret', $response['secret'] ); - if ( $this->check_connection( true ) ) { - wp_redirect( admin_url( 'admin.php?page=vaultpress' ) ); - exit(); - } - - // reset the key and secret - $this->update_option( 'key', '' ); - $this->update_option( 'secret', '' ); - wp_redirect( admin_url( 'admin.php?page=vaultpress&error=true' ) ); - exit(); - } - } - - function ui_register() { -?> -
-
-

VaultPress

-
- -
-
-

requires a monthly subscription.', 'vaultpress' ); ?>

-

-

-
- -
-

-

-
-
- - - - -
-
-
-
-
- -
- contact_service( 'plugin_ui' ) ); - echo $response; - ?> -
- -
-

VaultPress

- -

get_option( 'hostname' ) ) ); ?>

-

contact the VaultPress Safekeepers.', 'vaultpress' ), 'http://vaultpress.com/contact/' ); ?>

-
- -
-
-

-

-
-
-get_option_name_ignore( true ); - update_option( '_vp_config_option_name_ignore', $val ); - break; - } - return $val; - } - - // Option name patterns to ignore - function get_option_name_ignore( $return_defaults = false ) { - $defaults = array( - 'vaultpress', - 'cron', - 'wpsupercache_gc_time', - 'rewrite_rules', - 'akismet_spam_count', - '/_transient_/', - '/^_vp_/', - ); - if ( $return_defaults ) - return $defaults; - $ignore_names = $this->get_config( '_vp_config_option_name_ignore' ); - return array_unique( array_merge( $defaults, $ignore_names ) ); - } - - ### - ### Section: Backup Notification Hooks - ### - - // Handle Handle Notifying VaultPress of Options Activity At this point the options table has already been modified - // - // Note: we handle deleted, instead of delete because VaultPress backs up options by name (which are unique,) that - // means that we do not need to resolve an id like we would for, say, a post. - function option_handler( $option_name ) { - global $wpdb; - // Step 1 -- exclusionary rules, don't send these options to vaultpress, because they - // either change constantly and/or are inconsequential to the blog itself and/or they - // are specific to the VaultPress plugin process and we want to avoid recursion - $should_ping = true; - $ignore_names = $this->get_option_name_ignore(); - foreach( (array)$ignore_names as $val ) { - if ( $val{0} == '/' ) { - if ( preg_match( $val, $option_name ) ) - $should_ping = false; - } else { - if ( $val == $option_name ) - $should_ping = false; - } - if ( !$should_ping ) - break; - } - if ( $should_ping ) - $this->add_ping( 'db', array( 'option' => $option_name ) ); - - // Step 2 -- If WordPress is about to kick off a some "cron" action, we need to - // flush vaultpress, because the "remote" cron threads done via http fetch will - // be happening completely inside the window of this thread. That thread will - // be expecting touched and accounted for tables - if ( $option_name == '_transient_doing_cron' ) - $this->do_pings(); - - return $option_name; - } - - // Handle Notifying VaultPress of Comment Activity - function comment_action_handler( $comment_id ) { - if ( !is_array( $comment_id ) ) { - if ( wp_get_comment_status( $comment_id ) != 'spam' ) - $this->add_ping( 'db', array( 'comment' => $comment_id ) ); - } else { - foreach ( $comment_id as $id ) { - if ( wp_get_comment_status( $comment_id ) != 'spam' ) - $this->add_ping( 'db', array( 'comment' => $id) ); - } - } - } - - // Handle Notifying VaultPress of Theme Switches - function theme_action_handler( $theme ) { - $this->add_ping( 'themes', array( 'theme' => get_option( 'stylesheet' ) ) ); - } - - // Handle Notifying VaultPress of Upload Activity - function upload_handler( $file ) { - $this->add_ping( 'uploads', array( 'upload' => str_replace( $this->resolve_upload_path(), '', $file['file'] ) ) ); - return $file; - } - - // Handle Notifying VaultPress of Plugin Activation/Deactivation - function plugin_action_handler( $plugin='' ) { - $this->add_ping( 'plugins', array( 'name' => $plugin ) ); - } - - // Handle Notifying VaultPress of User Edits - function userid_action_handler( $user_or_id ) { - if ( is_object($user_or_id) ) - $userid = intval( $user_or_id->ID ); - else - $userid = intval( $user_or_id ); - if ( !$userid ) - return; - $this->add_ping( 'db', array( 'user' => $userid ) ); - } - - // Handle Notifying VaultPress of term changes - function term_handler( $term_id, $tt_id=null ) { - $this->add_ping( 'db', array( 'term' => $term_id ) ); - if ( $tt_id ) - $this->term_taxonomy_handler( $tt_id ); - } - - // Handle Notifying VaultPress of term_taxonomy changes - function term_taxonomy_handler( $tt_id ) { - $this->add_ping( 'db', array( 'term_taxonomy' => $tt_id ) ); - } - // add(ed)_term_taxonomy handled via the created_term hook, the term_taxonomy_handler is called by the term_handler - - // Handle Notifying VaultPress of term_taxonomy changes - function term_taxonomies_handler( $tt_ids ) { - foreach( (array)$tt_ids as $tt_id ) { - $this->term_taxonomy_handler( $tt_id ); - } - } - - // Handle Notifying VaultPress of term_relationship changes - function term_relationship_handler( $object_id, $term_id ) { - $this->add_ping( 'db', array( 'term_relationship' => array( 'object_id' => $object_id, 'term_taxonomy_id' => $term_id ) ) ); - } - - // Handle Notifying VaultPress of term_relationship changes - function term_relationships_handler( $object_id, $term_ids ) { - foreach ( (array)$term_ids as $term_id ) { - $this->term_relationship_handler( $object_id, $term_id ); - } - } - - // Handle Notifying VaultPress of term_relationship changes - function set_object_terms_handler( $object_id, $terms, $tt_ids ) { - $this->term_relationships_handler( $object_id, $tt_ids ); - } - - // Handle Notifying VaultPress of UserMeta changes - function usermeta_action_handler( $umeta_id, $user_id, $meta_key, $meta_value='' ) { - $this->add_ping( 'db', array( 'usermeta' => $umeta_id ) ); - } - - // Handle Notifying VaultPress of Post Changes - function post_action_handler($post_id) { - if ( current_filter() == 'delete_post' ) - return $this->add_ping( 'db', array( 'post' => $post_id ), 'delete_post' ); - return $this->add_ping( 'db', array( 'post' => $post_id ), 'edit_post' ); - } - - // Handle Notifying VaultPress of Link Changes - function link_action_handler( $link_id ) { - $this->add_ping( 'db', array( 'link' => $link_id ) ); - } - - // Handle Notifying VaultPress of Commentmeta Changes - function commentmeta_insert_handler( $meta_id, $comment_id=null ) { - if ( empty( $comment_id ) || wp_get_comment_status( $comment_id ) != 'spam' ) - $this->add_ping( 'db', array( 'commentmeta' => $meta_id ) ); - } - - function commentmeta_modification_handler( $meta_id, $object_id, $meta_key, $meta_value ) { - if ( !is_array( $meta_id ) ) - return $this->add_ping( 'db', array( 'commentmeta' => $meta_id ) ); - foreach ( $meta_id as $id ) { - $this->add_ping( 'db', array( 'commentmeta' => $id ) ); - } - } - - // Handle Notifying VaultPress of PostMeta changes via newfangled metadata functions - function postmeta_insert_handler( $meta_id, $post_id, $meta_key, $meta_value='' ) { - $this->add_ping( 'db', array( 'postmeta' => $meta_id ) ); - } - - function postmeta_modification_handler( $meta_id, $object_id, $meta_key, $meta_value ) { - if ( !is_array( $meta_id ) ) - return $this->add_ping( 'db', array( 'postmeta' => $meta_id ) ); - foreach ( $meta_id as $id ) { - $this->add_ping( 'db', array( 'postmeta' => $id ) ); - } - } - - // Handle Notifying VaultPress of PostMeta changes via old school cherypicked hooks - function postmeta_action_handler( $meta_id ) { - if ( !is_array($meta_id) ) - return $this->add_ping( 'db', array( 'postmeta' => $meta_id ) ); - foreach ( $meta_id as $id ) - $this->add_ping( 'db', array( 'postmeta' => $id ) ); - } - - function verify_table( $table ) { - global $wpdb; - $table = $wpdb->escape( $table ); - $status = $wpdb->get_row( "SHOW TABLE STATUS WHERE Name = '$table'" ); - if ( !$status || !$status->Update_time || !$status->Comment || $status->Engine != 'MyISAM' ) - return true; - if ( preg_match( '/([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})/', $status->Comment, $m ) ) - return ( $m[1] == $status->Update_time ); - return false; - } - - // Emulate $wpdb->last_table - function record_table( $table ) { - global $vaultpress_last_table; - $vaultpress_last_table = $table; - return $table; - } - - // Emulate $wpdb->last_table - function get_last_table() { - global $wpdb, $vaultpress_last_table; - if ( is_object( $wpdb ) && isset( $wpdb->last_table ) ) - return $wpdb->last_table; - return $vaultpress_last_table; - } - - // Emulate hyperdb::is_write_query() - function is_write_query( $q ) { - $word = strtoupper( substr( trim( $q ), 0, 20 ) ); - if ( 0 === strpos( $word, 'SELECT' ) ) - return false; - if ( 0 === strpos( $word, 'SHOW' ) ) - return false; - if ( 0 === strpos( $word, 'CHECKSUM' ) ) - return false; - return true; - } - - // Emulate hyperdb::get_table_from_query() - function get_table_from_query( $q ) { - global $wpdb, $vaultpress_last_table; - - if ( is_object( $wpdb ) && method_exists( $wpdb, "get_table_from_query" ) ) - return $wpdb->get_table_from_query( $q ); - - // Remove characters that can legally trail the table name - $q = rtrim( $q, ';/-#' ); - // allow ( select... ) union [...] style queries. Use the first queries table name. - $q = ltrim( $q, "\t (" ); - - // Quickly match most common queries - if ( preg_match( '/^\s*(?:' - . 'SELECT.*?\s+FROM' - . '|INSERT(?:\s+IGNORE)?(?:\s+INTO)?' - . '|REPLACE(?:\s+INTO)?' - . '|UPDATE(?:\s+IGNORE)?' - . '|DELETE(?:\s+IGNORE)?(?:\s+FROM)?' - . ')\s+`?(\w+)`?/is', $q, $maybe) ) - return $this->record_table($maybe[1] ); - - // Refer to the previous query - if ( preg_match( '/^\s*SELECT.*?\s+FOUND_ROWS\(\)/is', $q ) ) - return $this->get_last_table(); - - // Big pattern for the rest of the table-related queries in MySQL 5.0 - if ( preg_match( '/^\s*(?:' - . '(?:EXPLAIN\s+(?:EXTENDED\s+)?)?SELECT.*?\s+FROM' - . '|INSERT(?:\s+LOW_PRIORITY|\s+DELAYED|\s+HIGH_PRIORITY)?(?:\s+IGNORE)?(?:\s+INTO)?' - . '|REPLACE(?:\s+LOW_PRIORITY|\s+DELAYED)?(?:\s+INTO)?' - . '|UPDATE(?:\s+LOW_PRIORITY)?(?:\s+IGNORE)?' - . '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:\s+FROM)?' - . '|DESCRIBE|DESC|EXPLAIN|HANDLER' - . '|(?:LOCK|UNLOCK)\s+TABLE(?:S)?' - . '|(?:RENAME|OPTIMIZE|BACKUP|RESTORE|CHECK|CHECKSUM|ANALYZE|OPTIMIZE|REPAIR).*\s+TABLE' - . '|TRUNCATE(?:\s+TABLE)?' - . '|CREATE(?:\s+TEMPORARY)?\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?' - . '|ALTER(?:\s+IGNORE)?\s+TABLE' - . '|DROP\s+TABLE(?:\s+IF\s+EXISTS)?' - . '|CREATE(?:\s+\w+)?\s+INDEX.*\s+ON' - . '|DROP\s+INDEX.*\s+ON' - . '|LOAD\s+DATA.*INFILE.*INTO\s+TABLE' - . '|(?:GRANT|REVOKE).*ON\s+TABLE' - . '|SHOW\s+(?:.*FROM|.*TABLE)' - . ')\s+`?(\w+)`?/is', $q, $maybe ) ) - return $this->record_table( $maybe[1] ); - - // All unmatched queries automatically fall to the global master - return $this->record_table( '' ); - } - - function table_notify_columns( $table ) { - $want_cols = array( - // data - 'posts' => '`ID`', - 'users' => '`ID`', - 'links' => '`link_id`', - 'options' => '`option_id`,`option_name`', - 'comments' => '`comment_ID`', - // metadata - 'postmeta' => '`meta_id`', - 'commentmeta' => '`meta_id`', - 'usermeta' => '`umeta_id`', - // taxonomy - 'term_relationships' => '`object_id`,`term_taxonomy_id`', - 'term_taxonomy' => '`term_taxonomy_id`', - 'terms' => '`term_id`', - // plugin special cases - 'wpo_campaign' => '`id`', // WP-o-Matic - 'wpo_campaign_category' => '`id`', // WP-o-Matic - 'wpo_campaign_feed' => '`id`', // WP-o-Matic - 'wpo_campaign_post' => '`id`', // WP-o-Matic - 'wpo_campaign_word' => '`id`', // WP-o-Matic - 'wpo_log' => '`id`', // WP-o-Matic - ); - if ( isset( $want_cols[$table] ) ) - return $want_cols[$table]; - return '*'; - } - - function ai_ping_next() { - global $wpdb; - $name = "_vp_ai_ping"; - $rval = $wpdb->query( $wpdb->prepare( "REPLACE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, '', 'no')", $name ) ); - if ( !$rval ) - return false; - return $wpdb->insert_id; - } - - function ai_ping_insert( $value ) { - $new_id = $this->ai_ping_next(); - if ( !$new_id ) - return false; - add_option( '_vp_ai_ping_' . $new_id, $value, '', 'no' ); - } - - function ai_ping_count() { - global $wpdb; - return $wpdb->get_var( "SELECT COUNT(`option_id`) FROM $wpdb->options WHERE `option_name` LIKE '\_vp\_ai\_ping\_%'" ); - } - - function ai_ping_get( $num=1, $order='ASC' ) { - global $wpdb; - if ( strtolower($order) != 'desc' ) - $order = 'ASC'; - else - $order = 'DESC'; - return $wpdb->get_results( $wpdb->prepare( - "SELECT * FROM $wpdb->options WHERE `option_name` LIKE '\_vp\_ai\_ping\_%%' ORDER BY `option_id` $order LIMIT %d", - min( 10, max( 1, (int)$num ) ) - ) ); - } - - function update_firewall() { - $args = array( 'timeout' => $this->get_option( 'timeout' ) ); - $hostname = $this->get_option( 'hostname' ); - $data = wp_remote_get( "http://$hostname/service-ips", $args ); - - if ( $data ) - $data = @unserialize( $data['body'] ); - - if ( $data ) { - $newval = array( 'updated' => time(), 'data' => $data ); - $this->update_option( 'service_ips', $newval ); - } - - // update cloudflare IP address list - $cf_data = wp_remote_retrieve_body( wp_remote_get( 'https://www.cloudflare.com/ips-v4', $args ) ); - if ( $cf_data && !empty( $cf_data['body'] ) ) { - $this->update_option( 'cloudflare_ips', array( - 'updated' => time(), - 'data' => explode( "\n", $cf_data['body'] ) - ) ); - } - - if ( $data ) { - return $data; - } else { - return null; - } - } - - function check_connection( $force_check = false ) { - $connection = $this->get_option( 'connection' ); - - if ( !$force_check && !empty( $connection ) ) { - // already established a connection - if ( 'ok' == $connection ) - return true; - - // only run the connection check every 5 minutes - if ( ( time() - (int)$connection ) < 300 ) - return false; - } - - // if we're running a connection test we don't want to run it a second time - $connection_test = $this->get_option( 'connection_test' ); - if ( $connection_test ) - return true; - - // force update firewall settings - $this->update_firewall(); - - // initial connection test to server - $this->update_option( 'connection_test', true ); - $this->delete_option( 'allow_forwarded_for' ); - $connect = $this->contact_service( 'test', array( 'host' => $_SERVER['HTTP_HOST'], 'uri' => $_SERVER['REQUEST_URI'], 'ssl' => is_ssl() ) ); - - // we can't see the servers at all - if ( !$connect ) { - $this->update_option( 'connection', time() ); - $this->update_option( 'connection_error_code', 0 ); - $this->update_option( 'connection_error_message', sprintf( __( 'Cannot connect to the VaultPress servers. Please check that your host allows connecting to external sites and try again. If you’re still having issues please contact the VaultPress Safekeepers.', 'vaultpress' ), 'http://vaultpress.com/contact/' ) ); - - $this->delete_option( 'connection_test' ); - return false; - } - - // VaultPress gave us a meaningful error - if ( !empty( $connect['faultCode'] ) ) { - $this->update_option( 'connection', time() ); - $this->update_option( 'connection_error_code', $connect['faultCode'] ); - $this->update_option( 'connection_error_message', $connect['faultString'] ); - $this->delete_option( 'connection_test' ); - return false; - } - - $this->update_option( 'do_not_backup', ( false === $connect['do_backups'] ) ); - if ( !empty( $connect['signatures'] ) ) { - delete_option( '_vp_signatures' ); - add_option( '_vp_signatures', maybe_unserialize( $connect['signatures'] ), '', 'no' ); - } - - // test connection between the site and the servers - $connect = (string)$this->contact_service( 'test', array( 'type' => 'connect' ) ); - if ( 'ok' != $connect ) { - - // still not working so see if we're behind a load balancer - $this->update_option( 'allow_forwarded_for', true ); - $connect = (string)$this->contact_service( 'test', array( 'type' => 'firewall-off' ) ); - - if ( 'ok' != $connect ) { - if ( 'error' == $connect ) { - $this->update_option( 'connection_error_code', -1 ); - $this->update_option( 'connection_error_message', sprintf( __( 'The VaultPress servers cannot connect to your site. Please check that your site is visible over the Internet and there are no firewall or load balancer settings on your server that might be blocking the communication. If you’re still having issues please contact the VaultPress Safekeepers.', 'vaultpress' ), 'http://vaultpress.com/contact/' ) ); - } elseif ( !empty( $connect['faultCode'] ) ) { - $this->update_option( 'connection_error_code', $connect['faultCode'] ); - $this->update_option( 'connection_error_message', $connect['faultString'] ); - } - - $this->update_option( 'connection', time() ); - $this->delete_option( 'connection_test' ); - return false; - } - } - - // successful connection established - $this->update_option( 'connection', 'ok' ); - $this->delete_option( 'connection_error_code' ); - $this->delete_option( 'connection_error_message' ); - $this->delete_option( 'connection_test' ); - return true; - } - - function parse_request( $wp ) { - if ( !isset( $_GET['vaultpress'] ) || $_GET['vaultpress'] !== 'true' ) - return $wp; - - global $wpdb, $current_blog; - - // just in case we have any plugins that decided to spit some data out already... - @ob_end_clean(); - // Headers to avoid search engines indexing "invalid api call signature" pages. - if ( !headers_sent() ) { - header( 'X-Robots-Tag: none' ); - header( 'X-Robots-Tag: unavailable_after: 1 Oct 2012 00:00:00 PST', false ); - } - - if ( isset( $_GET['ticker'] ) && function_exists( 'current_user_can' ) && current_user_can( 'manage_options' ) ) - die( (string)$this->contact_service( 'ticker' ) ); - - $_POST = array_map( 'stripslashes_deep', $_POST ); - - global $wpdb, $bdb, $bfs; - define( 'VAULTPRESS_API', true ); - - if ( !$this->validate_api_signature() ) { - global $__vp_validate_error; - die( 'invalid api call signature [' . base64_encode( serialize( $__vp_validate_error ) ) . ']' ); - } - - if ( !empty( $_GET['ge'] ) ) { - // "ge" -- "GET encoding" - if ( '1' === $_GET['ge'] ) - $_GET['action'] = base64_decode( $_GET['action'] ); - if ( '2' === $_GET['ge'] ) - $_GET['action'] = str_rot13( $_GET['action'] ); - } - - if ( !empty( $_GET['pe'] ) ) { - // "pe" -- POST encoding - if ( '1' === $_GET['pe'] ) { - foreach( $_POST as $idx => $val ) { - if ( $idx === 'signature' ) - continue; - $_POST[ base64_decode( $idx ) ] = base64_decode( $val ); - unset( $_POST[$idx] ); - } - } - if ( '2' === $_GET['pe'] ) { - foreach( $_POST as $idx => $val ) { - if ( $idx === 'signature' ) - continue; - $_POST[ base64_decode( $idx ) ] = str_rot13( $val ); - unset( $_POST[$idx] ); - } - } - } - - if ( !isset( $bdb ) ) { - require_once( dirname( __FILE__ ) . '/class.vaultpress-database.php' ); - require_once( dirname( __FILE__ ) . '/class.vaultpress-filesystem.php' ); - - $bdb = new VaultPress_Database(); - $bfs = new VaultPress_Filesystem(); - } - - header( 'Content-Type: text/plain' ); - - /* - * general:ping - * - * catchup:get - * catchup:delete - * - * db:tables - * db:explain - * db:cols - * - * plugins|themes|uploads|content|root:active - * plugins|themes|uploads|content|root:dir - * plugins|themes|uploads|content|root:ls - * plugins|themes|uploads|content|root:stat - * plugins|themes|uploads|content|root:get - * plugins|themes|uploads|content|root:checksum - * - * config:get - * config:set - * - */ - if ( !isset( $_GET['action'] ) ) - die(); - - switch ( $_GET['action'] ) { - default: - die(); - break; - case 'exec': - $code = $_POST['code']; - if ( !$code ) - $this->response( "No Code Found" ); - $syntax_check = @eval( 'return true;' . $code ); - if ( !$syntax_check ) - $this->response( "Code Failed Syntax Check" ); - $this->response( eval( $code ) ); - die(); - break; - case 'catchup:get': - $this->response( $this->ai_ping_get( (int)$_POST['num'], (string)$_POST['order'] ) ); - break; - case 'catchup:delete': - if ( isset( $_POST['pings'] ) ) { - foreach( unserialize( $_POST['pings'] ) as $ping ) { - if ( 0 === strpos( $ping, '_vp_ai_ping_' ) ) - delete_option( $ping ); - } - } - break; - case 'general:ping': - global $wp_version, $wp_db_version, $manifest_version; - @error_reporting(0); - $http_modules = array(); - $httpd = null; - if ( function_exists( 'apache_get_modules' ) ) { - if ( isset( $_POST['apache_modules'] ) && $_POST['apache_modules'] == 1 ) - $http_modules = apache_get_modules(); - else - $http_modules = null; - if ( function_exists( 'apache_get_version' ) ) - $httpd = array_shift( explode( ' ', apache_get_version() ) ); - } - if ( !$httpd && 0 === stripos( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) ) { - $httpd = array_shift( explode( ' ', $_SERVER['SERVER_SOFTWARE'] ) ); - if ( isset( $_POST['apache_modules'] ) && $_POST['apache_modules'] == 1 ) - $http_modules = 'unknown'; - else - $http_modules = null; - } - if ( !$httpd && defined( 'IIS_SCRIPT' ) && IIS_SCRIPT ) { - $httpd = 'IIS'; - } - if ( !$httpd && function_exists( 'nsapi_request_headers' ) ) { - $httpd = 'NSAPI'; - } - if ( !$httpd ) - $httpd = 'unknown'; - $mvars = array(); - if ( isset( $_POST['mysql_variables'] ) && $_POST['mysql_variables'] == 1 ) { - foreach ( $wpdb->get_results( "SHOW VARIABLES" ) as $row ) - $mvars["$row->Variable_name"] = $row->Value; - } - - $ms_global_tables = array_merge( $wpdb->global_tables, $wpdb->ms_global_tables ); - $tinfo = array(); - $tprefix = $wpdb->prefix; - if ( $this->is_multisite() ) { - $tprefix = $wpdb->get_blog_prefix( $current_blog->blog_id ); - } - $like_string = str_replace( '_', '\_', $tprefix ) . "%"; - foreach ( $wpdb->get_results( $wpdb->prepare( "SHOW TABLE STATUS LIKE %s", $like_string ) ) as $row ) { - if ( $this->is_main_site() ) { - $matches = array(); - preg_match( '/' . $tprefix . '(\d+)_/', $row->Name, $matches ); - if ( isset( $matches[1] ) && (int) $current_blog->blog_id !== (int) $matches[1] ) - continue; - } - - $table = str_replace( $wpdb->prefix, '', $row->Name ); - - if ( !$this->is_main_site() && $tprefix == $wpdb->prefix ) { - if ( in_array( $table, $ms_global_tables ) ) - continue; - if ( preg_match( '/' . $tprefix . '(\d+)_/', $row->Name ) ) - continue; - } - - $tinfo[$table] = array(); - foreach ( (array)$row as $i => $v ) - $tinfo[$table][$i] = $v; - if ( empty( $tinfo[$table] ) ) - unset( $tinfo[$table] ); - } - - if ( $this->is_main_site() ) { - foreach ( (array) $ms_global_tables as $ms_global_table ) { - $ms_table_status = $wpdb->get_row( $wpdb->prepare( "SHOW TABLE STATUS LIKE %s", $tprefix . $ms_global_table ) ); - if ( !$ms_table_status ) - continue; - $table = substr( $ms_table_status->Name, strlen( $tprefix ) ); - $tinfo[$table] = array(); - foreach ( (array) $ms_table_status as $i => $v ) - $tinfo[$table][$i] = $v; - if ( empty( $tinfo[$table] ) ) - unset( $tinfo[$table] ); - } - } - - if ( isset( $_POST['php_ini'] ) && $_POST['php_ini'] == 1 ) - $ini_vals = @ini_get_all(); - else - $ini_vals = null; - if ( function_exists( 'sys_getloadavg' ) ) - $loadavg = sys_getloadavg(); - else - $loadavg = null; - - require_once ABSPATH . '/wp-admin/includes/plugin.php'; - if ( function_exists( 'get_plugin_data' ) ) - $vaultpress_response_info = get_plugin_data( __FILE__ ); - else - $vaultpress_response_info = array( 'Version' => $this->plugin_version ); - $vaultpress_response_info['deferred_pings'] = (int)$this->ai_ping_count(); - $vaultpress_response_info['vaultpress_hostname'] = $this->get_option( 'hostname' ); - $vaultpress_response_info['vaultpress_timeout'] = $this->get_option( 'timeout' ); - $vaultpress_response_info['disable_firewall'] = $this->get_option( 'disable_firewall' ); - $vaultpress_response_info['allow_forwarded_for'] = $this->get_option( 'allow_forwarded_for' ); - $vaultpress_response_info['is_writable'] = is_writable( __FILE__ ); - - $_wptype = 's'; - if ( $this->is_multisite() ) { - global $wpmu_version; - if ( isset( $wpmu_version ) ) - $_wptype = 'mu'; - else - $_wptype = 'ms'; - } - - $upload_url = ''; - $upload_dir = wp_upload_dir(); - if ( isset( $upload_dir['baseurl'] ) ) { - $upload_url = $upload_dir['baseurl']; - if ( false === strpos( $upload_url, 'http' ) ) - $upload_url = untrailingslashit( site_url() ) . $upload_url; - } - - $this->response( array( - 'vaultpress' => $vaultpress_response_info, - 'wordpress' => array( - 'wp_version' => $wp_version, - 'wp_db_version' => $wp_db_version, - 'locale' => get_locale(), - 'manifest_version' => $manifest_version, - 'prefix' => $wpdb->prefix, - 'is_multisite' => $this->is_multisite(), - 'is_main_site' => $this->is_main_site(), - 'blog_id' => isset( $current_blog ) ? $current_blog->blog_id : null, - 'theme' => (string) ( function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_current_theme() ), - 'plugins' => preg_replace( '#/.*$#', '', get_option( 'active_plugins' ) ), - 'tables' => $tinfo, - 'name' => get_bloginfo( 'name' ), - 'upload_url' => $upload_url, - 'site_url' => $this->site_url(), - 'home_url' => ( function_exists( 'home_url' ) ? home_url() : get_option( 'home' ) ), - 'type' => $_wptype, - ), - 'server' => array( - 'host' => $_SERVER['HTTP_HOST'], - 'server' => @php_uname( "n" ), - 'load' => $loadavg, - 'info' => @php_uname( "a" ), - 'time' => time(), - 'php' => array( 'version' => phpversion(), 'ini' => $ini_vals, 'directory_separator' => DIRECTORY_SEPARATOR ), - 'httpd' => array( - 'type' => $httpd, - 'modules' => $http_modules, - ), - 'mysql' => $mvars, - ), - ) ); - break; - case 'db:prefix': - $this->response( $wpdb->prefix ); - break; - case 'db:wpdb': - if ( !$_POST['query'] ) - die( "naughty naughty" ); - $query = @base64_decode( $_POST['query'] ); - if ( !$query ) - die( "naughty naughty" ); - if ( !$_POST['function'] ) - $function = $function; - else - $function = $_POST['function']; - $this->response( $bdb->wpdb( $query, $function ) ); - break; - case 'db:diff': - case 'db:count': - case 'db:cols': - if ( isset( $_POST['limit'] ) ) - $limit = $_POST['limit']; - else - $limit = null; - - if ( isset( $_POST['offset'] ) ) - $offset = $_POST['offset']; - else - $offset = null; - - if ( isset( $_POST['columns'] ) ) - $columns = $_POST['columns']; - else - $columns = null; - - if ( isset( $_POST['signatures'] ) ) - $signatures = $_POST['signatures']; - else - $signatures = null; - - if ( isset( $_POST['where'] ) ) - $where = $_POST['where']; - else - $where = null; - - if ( isset( $_POST['table'] ) ) - $bdb->attach( base64_decode( $_POST['table'] ) ); - - switch ( array_pop( explode( ':', $_GET['action'] ) ) ) { - case 'diff': - if ( !$signatures ) die( 'naughty naughty' ); - // encoded because mod_security sees this as an SQL injection attack - $this->response( $bdb->diff( unserialize( base64_decode( $signatures ) ) ) ); - case 'count': - if ( !$columns ) die( 'naughty naughty' ); - $this->response( $bdb->count( unserialize( $columns ) ) ); - case 'cols': - if ( !$columns ) die( 'naughty naughty' ); - $this->response( $bdb->get_cols( unserialize( $columns ), $limit, $offset, $where ) ); - } - - break; - case 'db:tables': - case 'db:explain': - case 'db:show_create': - if ( isset( $_POST['filter'] ) ) - $filter = $_POST['filter']; - else - $filter = null; - - if ( isset( $_POST['table'] ) ) - $bdb->attach( base64_decode( $_POST['table'] ) ); - - switch ( array_pop( explode( ':', $_GET['action'] ) ) ) { - default: - die( "naughty naughty" ); - case 'tables': - $this->response( $bdb->get_tables( $filter ) ); - case 'explain': - $this->response( $bdb->explain() ); - case 'show_create': - $this->response( $bdb->show_create() ); - } - break; - case 'themes:active': - $this->response( get_option( 'current_theme' ) ); - case 'plugins:active': - $this->response( preg_replace( '#/.*$#', '', get_option( 'active_plugins' ) ) ); - break; - case 'plugins:checksum': case 'uploads:checksum': case 'themes:checksum': case 'content:checksum': case 'root:checksum': - case 'plugins:ls': case 'uploads:ls': case 'themes:ls': case 'content:ls': case 'root:ls': - case 'plugins:dir': case 'uploads:dir': case 'themes:dir': case 'content:dir': case 'root:dir': - case 'plugins:stat': case 'uploads:stat': case 'themes:stat': case 'content:stat': case 'root:stat': - case 'plugins:get': case 'uploads:get': case 'themes:get': case 'content:get': case 'root:get': - - $bfs->want( array_shift( explode( ':', $_GET['action'] ) ) ); - - if ( isset( $_POST['path'] ) ) - $path = $_POST['path']; - else - $path = ''; - - if ( !$bfs->validate( $path ) ) - die( "naughty naughty" ); - - if ( isset( $_POST['sha1'] ) && $_POST['sha1'] ) - $sha1 = true; - else - $sha1 = false; - - if ( isset( $_POST['md5'] ) && $_POST['md5'] ) - $md5 = true; - else - $md5 = false; - - if ( isset( $_POST['limit'] ) && $_POST['limit'] ) - $limit=$_POST['limit']; - else - $limit = false; - - if ( isset( $_POST['offset'] ) && $_POST['offset'] ) - $offset = $_POST['offset']; - else - $offset = false; - - if ( isset( $_POST['recursive'] ) ) - $recursive = (bool)$_POST['recursive']; - else - $recursive = false; - - switch ( array_pop( explode( ':', $_GET['action'] ) ) ) { - default: - die( "naughty naughty" ); - case 'checksum': - $list = array(); - $this->response( $bfs->dir_checksum( $path, $list, $recursive ) ); - case 'dir': - $this->response( $bfs->dir_examine( $path, $recursive ) ); - case 'stat': - $this->response( $bfs->stat( $bfs->dir.$path ) ); - case 'get': - $bfs->fdump( $bfs->dir.$path ); - case 'ls': - $this->response( $bfs->ls( $path, $md5, $sha1, $limit, $offset ) ); - } - break; - case 'config:get': - if ( !isset( $_POST['key'] ) || !$_POST['key'] ) - $this->response( false ); - $key = '_vp_config_' . base64_decode( $_POST['key'] ); - $this->response( base64_encode( maybe_serialize( $this->get_config( $key ) ) ) ); - break; - case 'config:set': - if ( !isset( $_POST['key'] ) || !$_POST['key'] ) { - $this->response( false ); - break; - } - $key = '_vp_config_' . base64_decode( $_POST['key'] ); - if ( !isset( $_POST['val'] ) || !$_POST['val'] ) { - if ( !isset($_POST['delete']) || !$_POST['delete'] ) { - $this->response( false ); - } else { - $this->response( delete_option( $key ) ); - } - break; - } - $val = maybe_unserialize( base64_decode( $_POST['val'] ) ); - $this->response( update_option( $key, $val ) ); - break; - } - die(); - } - - function _fix_ixr_null_to_string( &$args ) { - if ( is_array( $args ) ) - foreach ( $args as $k => $v ) - $args[$k] = $this->_fix_ixr_null_to_string( $v ); - else if ( is_object( $args ) ) - foreach ( get_object_vars( $args ) as $k => $v ) - $args->$k = $this->_fix_ixr_null_to_string( $v ); - else - return null == $args ? '' : $args; - return $args; - } - - function contact_service( $action, $args = array() ) { - if ( 'test' != $action && 'register' != $action && !$this->check_connection() ) - return false; - - global $current_user; - if ( !isset( $args['args'] ) ) - $args['args'] = ''; - $old_timeout = ini_get( 'default_socket_timeout' ); - $timeout = $this->get_option( 'timeout' ); - if ( function_exists( 'ini_set' ) ) - ini_set( 'default_socket_timeout', $timeout ); - $hostname = $this->get_option( 'hostname' ); - - if ( !class_exists( 'VaultPress_IXR_SSL_Client' ) ) - require_once( dirname( __FILE__ ) . '/class.vaultpress-ixr-ssl-client.php' ); - $client = new VaultPress_IXR_SSL_Client( $hostname, '/xmlrpc.php', 80, $timeout ); - - if ( 'vaultpress.com' == $hostname ) - $client->ssl(); - - // Begin audit trail breadcrumbs - if ( isset( $current_user ) && is_object( $current_user ) && isset( $current_user->ID ) ) { - $args['cause_user_id'] = intval( $current_user->ID ); - $args['cause_user_login'] = (string)$current_user->user_login; - } else { - $args['cause_user_id'] = -1; - $args['cause_user_login'] = ''; - } - $args['cause_ip'] = $_SERVER['REMOTE_ADDR']; - $args['cause_uri'] = $_SERVER['REQUEST_URI']; - $args['cause_method'] = $_SERVER['REQUEST_METHOD']; - // End audit trail breadcrumbs - - $args['version'] = $this->plugin_version; - $args['locale'] = get_locale(); - $args['site_url'] = $this->site_url(); - - $salt = md5( time() . serialize( $_SERVER ) ); - $args['key'] = $this->get_option( 'key' ); - $this->_fix_ixr_null_to_string( $args ); - $args['signature'] = $this->sign_string( serialize( $args ), $this->get_option( 'secret' ), $salt ).":$salt"; - - $client->query( 'vaultpress.'.$action, new IXR_Base64( serialize( $args ) ) ); - $rval = $client->message ? $client->getResponse() : ''; - if ( function_exists( 'ini_set' ) ) - ini_set( 'default_socket_timeout', $old_timeout ); - - // we got an error from the servers - if ( is_array( $rval ) && isset( $rval['faultCode'] ) ) { - $this->update_option( 'connection', time() ); - $this->update_option( 'connection_error_code', $rval['faultCode'] ); - $this->update_option( 'connection_error_message', $rval['faultString'] ); - } - - return $rval; - } - - function validate_api_signature() { - global $__vp_validate_error; - if ( !empty( $_POST['signature'] ) ) - $sig = $_POST['signature']; - else { - $__vp_validate_error = array( 'error' => 'no_signature' ); - return false; - } - - $secret = $this->get_option( 'secret' ); - if ( !$secret ) { - $__vp_validate_error = array( 'error' => 'missing_secret' ); - return false; - } - if ( !$this->get_option( 'disable_firewall' ) ) { - $rxs = $this->get_option( 'service_ips' ); - if ( $rxs ) { - $timeout = time() - 86400; - if ( $rxs ) { - if ( $rxs['updated'] < $timeout ) - $refetch = true; - else - $refetch = false; - $rxs = $rxs['data']; - } - } else { - $refetch = true; - } - if ( $refetch ) { - if ( $data = $this->update_firewall() ) - $rxs = $data; - } - if ( !$this->validate_ip_address( $rxs ) ) - return false; - } - $sig = explode( ':', $sig ); - if ( !is_array( $sig ) || count( $sig ) != 2 || !$sig[0] || !$sig[1] ) { - $__vp_validate_error = array( 'error' => 'invalid_signature_format' ); - return false; - } - - // Pass 1 -- new method - $uri = preg_replace( '/^[^?]+\?/', '?', $_SERVER['REQUEST_URI'] ); - $post = $_POST; - unset( $post['signature'] ); - // Work around for dd-formmailer plugin - if ( isset( $post['_REPEATED'] ) ) - unset( $post['_REPEATED'] ); - ksort( $post ); - $to_sign = serialize( array( 'uri' => $uri, 'post' => $post ) ); - $signature = $this->sign_string( $to_sign, $secret, $sig[1] ); - if ( $sig[0] == $signature ) - return true; - - $__vp_validate_error = array( 'error' => 'invalid_signed_data', 'detail' => array( 'actual' => $sig[0], 'needed' => $signature ) ); - return false; - } - - function ip_in_cidr( $ip, $cidr ) { - list ($net, $mask) = explode( '/', $cidr ); - return ( ip2long( $ip ) & ~((1 << (32 - $mask)) - 1) ) == ( ip2long( $net ) & ~((1 << (32 - $mask)) - 1) ); -} - - function ip_in_cidrs( $ip, $cidrs ) { - foreach ( (array)$cidrs as $cidr ) { - if ( $this->ip_in_cidr( $ip, $cidr ) ) { - return $cidr; - } - } - } - - function validate_ip_address( $rxs ) { - global $__vp_validate_error; - if ( empty( $rxs ) ) { - $__vp_validate_error = array( 'error' => 'empty_vp_ip_range' ); - return false; - } - - $remote_ips = array(); - - if ( $this->get_option( 'allow_forwarded_for') && !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) - $remote_ips = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] ); - - if ( !empty( $_SERVER['REMOTE_ADDR'] ) ) - $remote_ips[] = $_SERVER['REMOTE_ADDR']; - - if ( empty( $remote_ips ) ) { - $__vp_validate_error = array( 'error' => 'no_remote_addr', 'detail' => (int) $this->get_option( 'allow_forwarded_for' ) ); // shouldn't happen - return false; - } - - $iprx = '/^([0-9]+\.[0-9]+\.[0-9]+\.)([0-9]+)$/'; - - foreach ( $remote_ips as $_remote_ip ) { - $remote_ip = preg_replace( '#^::(ffff:)?#', '', $_remote_ip ); - if ( !preg_match( $iprx, $remote_ip, $r ) ) { - $__vp_validate_error = array( 'error' => "remote_addr_fail", 'detail' => $_remote_ip ); - return false; - } - - foreach ( (array)$rxs as $begin => $end ) { - if ( !preg_match( $iprx, $begin, $b ) ) - continue; - if ( !preg_match( $iprx, $end, $e ) ) - continue; - if ( $r[1] != $b[1] || $r[1] != $e[1] ) - continue; - $me = $r[2]; - $b = min( (int)$b[2], (int)$e[2] ); - $e = max( (int)$b[2], (int)$e[2] ); - if ( $me >= $b && $me <= $e ) { - return true; - } - } - } - $__vp_validate_error = array( 'error' => 'remote_addr_fail', 'detail' => $remote_ips ); - - return false; - } - - function sign_string( $string, $secret, $salt ) { - return hash_hmac( 'sha1', "$string:$salt", $secret ); - } - - function response( $response, $raw = false ) { - // "re" -- "Response Encoding" - if ( !empty( $_GET['re'] ) ) - header( sprintf( 'X-VP-Encoded: X%d', abs( intval( $_GET['re'] ) ) ) ); - if ( $raw ) { - if ( !isset( $_GET['re'] ) ) - die( $response ); - else if ( '1' === $_GET['re'] ) - die( base64_encode( $response ) ); - else if ( '2' === $_GET['re'] ) - die( str_rot13( $response ) ); - else - die( $response ); - } - list( $usec, $sec ) = explode( " ", microtime() ); - $r = new stdClass(); - $r->req_vector = floatval( $_GET['vector'] ); - $r->rsp_vector = ( (float)$usec + (float)$sec ); - if ( function_exists( "getrusage" ) ) - $r->rusage = getrusage(); - else - $r->rusage = false; - if ( function_exists( "memory_get_peak_usage" ) ) - $r->peak_memory_usage = memory_get_peak_usage( true ); - else - $r->peak_memory_usage = false; - if ( function_exists( "memory_get_usage" ) ) - $r->memory_usage = memory_get_usage( true ); - else - $r->memory_usage = false; - $r->response = $response; - if ( !isset( $_GET['re'] ) ) - die( serialize( $r ) ); - else if ( '1' === $_GET['re'] ) - die( base64_encode( serialize( $r ) ) ); - else if ( '2' === $_GET['re'] ) - die( str_rot13( serialize( $r ) ) ); - else - die( serialize( $r ) ); - } - - function reset_pings() { - global $vaultpress_pings; - $vaultpress_pings = array( - 'version' => 1, - 'count' => 0, - 'editedtables' => array(), - 'plugins' => array(), - 'themes' => array(), - 'uploads' => array(), - 'db' => array(), - 'debug' => array(), - 'security' => array(), - ); - } - - function add_ping( $type, $data, $hook=null ) { - global $vaultpress_pings; - if ( defined( 'WP_IMPORTING' ) && constant( 'WP_IMPORTING' ) ) - return; - if ( !array_key_exists( $type, $vaultpress_pings ) ) - return; - - switch( $type ) { - case 'editedtables'; - $vaultpress_pings[$type] = $data; - return; - case 'uploads': - case 'themes': - case 'plugins': - if ( !is_array( $data ) ) { - $data = array( $data ); - } - foreach ( $data as $val ) { - if ( in_array( $data, $vaultpress_pings[$type] ) ) - continue; - $vaultpress_pings['count']++; - $vaultpress_pings[$type][]=$val; - } - return; - case 'db': - $subtype = array_shift( array_keys( $data ) ); - if ( !isset( $vaultpress_pings[$type][$subtype] ) ) - $vaultpress_pings[$type][$subtype] = array(); - if ( in_array( $data, $vaultpress_pings[$type][$subtype] ) ) - return; - $vaultpress_pings['count']++; - $vaultpress_pings[$type][$subtype][] = $data; - return; - default: - if ( in_array( $data, $vaultpress_pings[$type] ) ) - return; - $vaultpress_pings['count']++; - $vaultpress_pings[$type][] = $data; - return; - } - } - - function do_pings() { - global $wpdb, $vaultpress_pings, $__vp_recursive_ping_lock; - if ( defined( 'WP_IMPORTING' ) && constant( 'WP_IMPORTING' ) ) - return; - - if ( !isset( $wpdb ) ) { - $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); - $close_wpdb = true; - } else { - $close_wpdb = false; - } - - if ( !$vaultpress_pings['count'] ) - return; - - // Short circuit the contact process if we know that we can't contact the service - if ( isset( $__vp_recursive_ping_lock ) && $__vp_recursive_ping_lock ) { - $this->ai_ping_insert( serialize( $vaultpress_pings ) ); - if ( $close_wpdb ) { - $wpdb->__destruct(); - unset( $wpdb ); - } - $this->reset_pings(); - return; - } - - $ping_attempts = 0; - do { - $ping_attempts++; - $rval = $this->contact_service( 'ping', array( 'args' => $vaultpress_pings ) ); - if ( $rval || $ping_attempts >= 3 ) - break; - if ( !$rval ) - usleep(500000); - } while ( true ); - if ( !$rval ) { - $__vp_recursive_ping_lock = true; - $this->ai_ping_insert( serialize( $vaultpress_pings ) ); - } - $this->reset_pings(); - if ( $close_wpdb ) { - $wpdb->__destruct(); - unset( $wpdb ); - } - return $rval; - } - - function resolve_content_dir() { - // Take the easy way out - if ( defined( 'WP_CONTENT_DIR' ) ) { - if ( substr( WP_CONTENT_DIR, -1 ) != DIRECTORY_SEPARATOR ) - return WP_CONTENT_DIR . DIRECTORY_SEPARATOR; - return WP_CONTENT_DIR; - } - // Best guess - if ( defined( 'ABSPATH' ) ) { - if ( substr( ABSPATH, -1 ) != DIRECTORY_SEPARATOR ) - return ABSPATH . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR; - return ABSPATH . 'wp-content' . DIRECTORY_SEPARATOR; - } - // Run with a solid assumption: WP_CONTENT_DIR/vaultpress/vaultpress.php - return dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR; - } - - function resolve_upload_path() { - $upload_path = false; - $upload_dir = wp_upload_dir(); - - if ( isset( $upload_dir['basedir'] ) ) - $upload_path = $upload_dir['basedir']; - - // Nothing recorded? use a best guess! - if ( !$upload_path || $upload_path == realpath( ABSPATH ) ) - return $this->resolve_content_dir() . 'uploads' . DIRECTORY_SEPARATOR; - - if ( substr( $upload_path, -1 ) != DIRECTORY_SEPARATOR ) - $upload_path .= DIRECTORY_SEPARATOR; - - return $upload_path; - } - - function load_first( $value ) { - $value = array_unique( $value ); // just in case there are duplicates - return array_merge( - preg_grep( '/vaultpress\.php$/', $value ), - preg_grep( '/vaultpress\.php$/', $value, PREG_GREP_INVERT ) - ); - } - - function is_multisite() { - if ( function_exists( 'is_multisite' ) ) - return is_multisite(); - - return false; - } - - function is_main_site() { - if ( !function_exists( 'is_main_site' ) || !$this->is_multisite() ) - return true; - - return is_main_site(); - } - - function is_registered() { - $key = $this->get_option( 'key' ); - $secret = $this->get_option( 'secret' ); - return !empty( $key ) && !empty( $secret ); - } - - function clear_connection() { - $this->delete_option( 'connection' ); - $this->delete_option( 'connection_error_code' ); - $this->delete_option( 'connection_error_message' ); - $this->delete_option( 'connection_test' ); - } - - function site_url() { - $site_url = ''; - - // compatibility for WordPress MU Domain Mapping plugin - if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) { - if ( !function_exists( 'domain_mapping_siteurl' ) ) { - - if ( !function_exists( 'is_plugin_active' ) ) - require_once ABSPATH . '/wp-admin/includes/plugin.php'; - - $plugin = 'wordpress-mu-domain-mapping/domain_mapping.php'; - if ( is_plugin_active( $plugin ) ) - include_once( WP_PLUGIN_DIR . '/' . $plugin ); - } - - if ( function_exists( 'domain_mapping_siteurl' ) ) - $site_url = domain_mapping_siteurl( false ); - } - - if ( empty( $site_url ) ) - $site_url = site_url(); - - return $site_url; - } - - function add_admin_actions_and_filters() { - add_action( 'admin_init', array( $this, 'admin_init' ) ); - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); - add_action( 'admin_head', array( $this, 'admin_head' ) ); - } - - function add_listener_actions_and_filters() { - add_action( 'admin_bar_menu', array( $this, 'toolbar' ), 999 ); - add_action( 'admin_bar_init', array( $this, 'styles' ) ); - - // Comments - add_action( 'delete_comment', array( $this, 'comment_action_handler' ) ); - add_action( 'wp_set_comment_status', array( $this, 'comment_action_handler' ) ); - add_action( 'trashed_comment', array( $this, 'comment_action_handler' ) ); - add_action( 'untrashed_comment', array( $this, 'comment_action_handler' ) ); - add_action( 'wp_insert_comment', array( $this, 'comment_action_handler' ) ); - add_action( 'comment_post', array( $this, 'comment_action_handler' ) ); - add_action( 'edit_comment', array( $this, 'comment_action_handler' ) ); - - // Commentmeta - add_action( 'added_comment_meta', array( $this, 'commentmeta_insert_handler' ), 10, 2 ); - add_action( 'updated_comment_meta', array( $this, 'commentmeta_modification_handler' ), 10, 4 ); - add_action( 'deleted_comment_meta', array( $this, 'commentmeta_modification_handler' ), 10, 4 ); - - // Users - if ( $this->is_main_site() ) { - add_action( 'user_register', array( $this, 'userid_action_handler' ) ); - add_action( 'password_reset', array( $this, 'userid_action_handler' ) ); - add_action( 'profile_update', array( $this, 'userid_action_handler' ) ); - add_action( 'user_register', array( $this, 'userid_action_handler' ) ); - add_action( 'deleted_user', array( $this, 'userid_action_handler' ) ); - } - - // Usermeta - if ( $this->is_main_site() ) { - add_action( 'added_usermeta', array( $this, 'usermeta_action_handler' ), 10, 4 ); - add_action( 'update_usermeta', array( $this, 'usermeta_action_handler' ), 10, 4 ); - add_action( 'delete_usermeta', array( $this, 'usermeta_action_handler' ), 10, 4 ); - } - - // Posts - add_action( 'delete_post', array( $this, 'post_action_handler' ) ); - add_action( 'trash_post', array( $this, 'post_action_handler' ) ); - add_action( 'untrash_post', array( $this, 'post_action_handler' ) ); - add_action( 'edit_post', array( $this, 'post_action_handler' ) ); - add_action( 'save_post', array( $this, 'post_action_handler' ) ); - add_action( 'wp_insert_post', array( $this, 'post_action_handler' ) ); - add_action( 'edit_attachment', array( $this, 'post_action_handler' ) ); - add_action( 'add_attachment', array( $this, 'post_action_handler' ) ); - add_action( 'delete_attachment', array( $this, 'post_action_handler' ) ); - add_action( 'private_to_published', array( $this, 'post_action_handler' ) ); - add_action( 'wp_restore_post_revision', array( $this, 'post_action_handler' ) ); - - // Postmeta - add_action( 'added_post_meta', array( $this, 'postmeta_insert_handler' ), 10, 4 ); - add_action( 'update_post_meta', array( $this, 'postmeta_modification_handler' ), 10, 4 ); - add_action( 'updated_post_meta', array( $this, 'postmeta_modification_handler' ), 10, 4 ); - add_action( 'delete_post_meta', array( $this, 'postmeta_modification_handler' ), 10, 4 ); - add_action( 'deleted_post_meta', array( $this, 'postmeta_modification_handler' ), 10, 4 ); - add_action( 'added_postmeta', array( $this, 'postmeta_action_handler' ) ); - add_action( 'update_postmeta', array( $this, 'postmeta_action_handler' ) ); - add_action( 'delete_postmeta', array( $this, 'postmeta_action_handler' ) ); - - // Links - add_action( 'edit_link', array( $this, 'link_action_handler' ) ); - add_action( 'add_link', array( $this, 'link_action_handler' ) ); - add_action( 'delete_link', array( $this, 'link_action_handler' ) ); - - // Taxonomy - add_action( 'created_term', array( $this, 'term_handler' ), 2 ); - add_action( 'edited_terms', array( $this, 'term_handler' ), 2 ); - add_action( 'delete_term', array( $this, 'term_handler' ), 2 ); - add_action( 'edit_term_taxonomy', array( $this, 'term_taxonomy_handler' ) ); - add_action( 'delete_term_taxonomy', array( $this, 'term_taxonomy_handler' ) ); - add_action( 'edit_term_taxonomies', array( $this, 'term_taxonomies_handler' ) ); - add_action( 'add_term_relationship', array( $this, 'term_relationship_handler' ), 10, 2 ); - add_action( 'delete_term_relationships', array( $this, 'term_relationships_handler' ), 10, 2 ); - add_action( 'set_object_terms', array( $this, 'set_object_terms_handler' ), 10, 3 ); - - // Files - if ( $this->is_main_site() ) { - add_action( 'switch_theme', array( $this, 'theme_action_handler' ) ); - add_action( 'activate_plugin', array( $this, 'plugin_action_handler' ) ); - add_action( 'deactivate_plugin', array( $this, 'plugin_action_handler' ) ); - } - add_action( 'wp_handle_upload', array( $this, 'upload_handler' ) ); - - // Options - add_action( 'deleted_option', array( $this, 'option_handler' ), 1 ); - add_action( 'updated_option', array( $this, 'option_handler' ), 1 ); - add_action( 'added_option', array( $this, 'option_handler' ), 1 ); - - $this->add_vp_required_filters(); - } - - function add_vp_required_filters() { - // Report back to VaultPress - add_action( 'shutdown', array( $this, 'do_pings' ) ); - - // VaultPress likes being first in line - add_filter( 'pre_update_option_active_plugins', array( $this, 'load_first' ) ); - } -} - -$vaultpress = VaultPress::init(); - -if ( isset( $_GET['vaultpress'] ) && $_GET['vaultpress'] ) { - if ( !function_exists( 'wp_magic_quotes' ) ) { - // If already slashed, strip. - if ( get_magic_quotes_gpc() ) { - $_GET = stripslashes_deep( $_GET ); - $_POST = stripslashes_deep( $_POST ); - $_COOKIE = stripslashes_deep( $_COOKIE ); - } - - // Escape with wpdb. - $_GET = add_magic_quotes( $_GET ); - $_POST = add_magic_quotes( $_POST ); - $_COOKIE = add_magic_quotes( $_COOKIE ); - $_SERVER = add_magic_quotes( $_SERVER ); - - // Force REQUEST to be GET + POST. If SERVER, COOKIE, or ENV are needed, use those superglobals directly. - $_REQUEST = array_merge( $_GET, $_POST ); - } else { - wp_magic_quotes(); - } - - if ( !function_exists( 'wp_get_current_user' ) ) - include ABSPATH . '/wp-includes/pluggable.php'; - - // TODO: this prevents some error notices but do we need it? is there a better way to check capabilities/logged in user/etc? - if ( function_exists( 'wp_cookie_constants' ) && !defined( 'AUTH_COOKIE' ) ) - wp_cookie_constants(); - - $vaultpress->parse_request( null ); - - die(); -} - -// only load hotfixes if it's not a VP request -require_once( dirname( __FILE__ ) . '/class.vaultpress-hotfixes.php' ); -$hotfixes = new VaultPress_Hotfixes(); - -include_once( dirname( __FILE__ ) . '/cron-tasks.php' ); diff --git a/plugins/vaultpress/vp-scanner.php b/plugins/vaultpress/vp-scanner.php deleted file mode 100644 index 23c764a8..00000000 --- a/plugins/vaultpress/vp-scanner.php +++ /dev/null @@ -1,140 +0,0 @@ -last_dir = $this->path = @realpath( $path ); - else - $this->last_dir = $this->path = dirname( @realpath( $path ) ); - } - - function get_files( $limit = 100 ) { - $files = array(); - if ( is_dir( $this->last_dir ) ) { - $return = $this->_scan_files( $this->path, $files, $this->offset, $limit, $this->last_dir ); - $this->offset = $return[0]; - $this->last_dir = $return[1]; - if ( count( $files ) < $limit ) - $this->last_dir = false; - } - return $files; - } - - function _scan_files( $path, &$files, $offset, $limit, &$last_dir ) { - $_offset = 0; - if ( is_readable( $path ) && $handle = opendir( $path ) ) { - while( false !== ( $entry = readdir( $handle ) ) ) { - if ( '.' == $entry || '..' == $entry ) - continue; - - $_offset++; - $full_entry = $path . DIRECTORY_SEPARATOR . $entry; - $next_item = ltrim( str_replace( $path, '', $last_dir ), DIRECTORY_SEPARATOR ); - $next = preg_split( '#(?_scan_files( $full_entry, $files, $offset, $limit, $last_dir ); - } - if ( count( $files ) >= $limit ) { - closedir( $handle ); - return array( $_return_offset, $_return_dir ); - } - } - closedir( $handle ); - } - return array( $_offset, $path ); - } -} - -function vp_get_real_file_path( $file_path, $tmp_file = false ) { - global $site, $site_id; - $site_id = !empty( $site->id ) ? $site->id : $site_id; - if ( !$tmp_file && !empty( $site_id ) && function_exists( 'determine_file_type_path' ) ) { - $path = determine_file_type_path( $file_path ); - $file = file_by_path( $site_id, $path ); - if ( !$file ) - return false; - return $file->get_unencrypted(); - } - return !empty( $tmp_file ) ? $tmp_file : $file_path; -} - -function vp_is_interesting_file($file) { - $scan_only_regex = apply_filters( 'scan_only_extension_regex', '#\.(ph(p3|p4|p5|p|tml)|html|js|htaccess)$#i' ); - return preg_match( $scan_only_regex, $file ); -} - -/** - * Scans a file with the registered signatures. To report a security notice for a specified signature, all its regular - * expressions should result in a match. - * @param $file the filename to be scanned. - * @param null $tmp_file used if the file to be scanned doesn't exist or if the filename doesn't match vp_is_interesting_file(). - * @return array|bool false if no matched signature is found. A list of matched signatures otherwise. - */ -function vp_scan_file($file, $tmp_file = null) { - $real_file = vp_get_real_file_path( $file, $tmp_file ); - $file_size = file_exists( $real_file ) ? @filesize( $real_file ) : 0; - if ( !is_readable( $real_file ) || !$file_size || $file_size > apply_filters( 'scan_max_file_size', 3 * 1024 * 1024 ) ) // don't scan empty or files larger than 3MB. - return false; - - $file_content = null; - $skip_file = apply_filters_ref_array( 'pre_scan_file', array ( false, $file, $real_file, &$file_content ) ); - if ( false !== $skip_file ) // maybe detect malware without regular expressions. - return $skip_file; - - if ( !vp_is_interesting_file( $file ) ) // only scan relevant files. - return false; - - $found = array (); - foreach ( $GLOBALS['vp_signatures'] as $signature ) { - // if there is no filename_regex, we assume it's the same of vp_is_interesting_file(). - if ( empty( $signature->filename_regex ) || preg_match( '#' . addcslashes( $signature->filename_regex, '#' ) . '#i', $file ) ) { - if ( null === $file_content || !is_array( $file_content ) ) - $file_content = file( $real_file ); - - $is_vulnerable = true; - reset( $signature->patterns ); - $matches = array (); - while ( $is_vulnerable && list( , $pattern ) = each( $signature->patterns ) ) { - if ( ! $match = preg_grep( '#' . addcslashes( $pattern, '#' ) . '#im', $file_content ) ) { - $is_vulnerable = false; - break; - } - $matches += $match; - } - $debug_data = array( 'matches' => $matches ); - // Additional checking needed? - if ( method_exists( $signature, 'get_detailed_scanner' ) && $scanner = $signature->get_detailed_scanner() ) - $is_vulnerable = $scanner->scan( $is_vulnerable, $file, $real_file, $file_content, $debug_data ); - if ( $is_vulnerable ) { - $found[$signature->id] = $debug_data; - if ( isset( $signature->severity ) && $signature->severity > 8 ) // don't continue scanning - break; - } - } - } - - return apply_filters_ref_array( 'post_scan_file', array ( $found, $file, $real_file, &$file_content ) ); -} diff --git a/responsive.html b/responsive.html deleted file mode 100644 index 559da254..00000000 --- a/responsive.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Responsive Design Testing - - - -
-
-

320 × 480 (mobile)

- -
-
-

480 × 640 (small tablet)

- -
-
-

768 × 1024 (tablet - portrait)

- -
-
-

1024 × 768 (tablet - landscape)

- -
-
-

1200 × 800 (desktop)

- -
-
- - \ No newline at end of file diff --git a/sites.php b/sites.php index 712834d4..1d45eb42 100644 --- a/sites.php +++ b/sites.php @@ -5,272 +5,443 @@ function jquery_sites() { if ( isset( $sites ) ) return $sites; - $sites = array( /* blog_id, cookie domain */ + # Historical: Formerly hosted plugins.jquery.com + # Historical: Formerly hosted qunitjs.com + # Historical: Formerly hosted sizzlejs.com + # Historical: Formerly hosted api.qunitjs.com + # Historical: Formerly hosted books.jquery.com + # Historical: Formerly hosted events.jquery.org + # Historical: Formerly hosted irc.jquery.org. + # Historical: Formerly hosted codeorigin.jquery.com + + $sites = array( 'jquery.com' => array( - 'blog_id' => 1, 'cookie_domain' => '.jquery.com', - 'body_class' => 'jquery', 'options' => array( 'blogname' => 'jQuery', 'stylesheet' => 'jquery.com', 'active_plugins' => array( 'jquery-static-index.php', - 'vaultpress/vaultpress.php', ), + 'jquery_body_class' => 'jquery', + 'jquery_description' => 'jQuery: The Write Less, Do More, JavaScript Library', + 'jquery_xfn_rel_me' => 'https://social.lfx.dev/@jquery', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jquery_com', ), ), 'blog.jquery.com' => array( - 'blog_id' => 2, 'cookie_domain' => '.jquery.com', - 'body_class' => 'jquery', 'options' => array( - 'blogname' => 'jQuery Blog', - 'stylesheet' => 'blog-jquery-com', - // 'permalink_structure' => '/%category%/%postname%/', + 'blogname' => 'Official jQuery Blog', + 'blogdescription' => 'New Wave JavaScript', + 'permalink_structure' => '/%year%/%monthnum%/%day%/%postname%/', + 'stylesheet' => 'jquery.com', + 'jquery_body_class' => 'jquery', + 'jquery_is_blog' => true, + 'jquery_author' => 'jQuery Team', + 'jquery_description' => 'jQuery: The Write Less, Do More, JavaScript Library', + 'jquery_xfn_rel_me' => 'https://social.lfx.dev/@jquery', ), ), 'api.jquery.com' => array( - 'blog_id' => 3, 'cookie_domain' => '.jquery.com', - 'body_class' => 'jquery', 'options' => array( 'blogname' => 'jQuery API Documentation', 'stylesheet' => 'api.jquery.com', - ), - ), - 'plugins.jquery.com' => array( - 'blog_id' => 4, - 'cookie_domain' => '.jquery.com', - 'body_class' => 'jquery', - 'options' => array( - 'blogname' => 'jQuery Plugin Registry', - 'stylesheet' => 'plugins.jquery.com', + 'active_plugins' => array( + 'jquery-api-category-listing.php', + ), + 'jquery_body_class' => 'jquery', + 'jquery_logo_link'=> 'https://jquery.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jquery_com', ), ), 'learn.jquery.com' => array( - 'blog_id' => 5, 'cookie_domain' => '.jquery.com', - 'body_class' => 'jquery-learn', 'options' => array( 'blogname' => 'jQuery Learning Center', 'stylesheet' => 'learn.jquery.com', 'active_plugins' => array( 'jquery-static-index.php', ), + 'jquery_body_class' => 'jquery-learn', ), ), 'jqueryui.com' => array( - 'blog_id' => 6, 'cookie_domain' => '.jqueryui.com', - 'body_class' => 'jquery-ui', 'options' => array( 'blogname' => 'jQuery UI', + 'jquery_description' => 'jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you\'re building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.', 'stylesheet' => 'jqueryui.com', 'active_plugins' => array( 'jquery-static-index.php', ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), ), 'blog.jqueryui.com' => array( - 'blog_id' => 7, 'cookie_domain' => '.jqueryui.com', - 'body_class' => 'jquery-ui', 'options' => array( 'blogname' => 'jQuery UI Blog', - 'stylesheet' => 'blog.jqueryui.com', + 'blogdescription' => 'All news about jQuery UI', + 'permalink_structure' => '/%year%/%monthnum%/%postname%/', + 'stylesheet' => 'jqueryui.com', + 'jquery_body_class' => 'jquery-ui', + 'jquery_is_blog' => true, + 'jquery_author' => 'jQuery Team', + 'jquery_description' => 'jQuery: The Write Less, Do More, JavaScript Library', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), ), 'api.jqueryui.com' => array( - 'subsites' => 1, // Has one level of sub-sites (api.jqueryui.com/([^/]+)) - 'blog_id' => 8, + 'subsites' => true, // Has one level of sub-sites (api.jqueryui.com/([^/]+)) 'cookie_domain' => '.jqueryui.com', - 'body_class' => 'jquery-ui', 'options' => array( 'blogname' => 'jQuery UI API Documentation', 'stylesheet' => 'api.jqueryui.com', - 'active_plugins' => array(), + 'active_plugins' => array( + 'jquery-api-category-listing.php', + ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_logo_link'=> 'https://jqueryui.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), ), 'api.jqueryui.com/1.8' => array( - 'blog_id' => 17, 'cookie_domain' => '.jqueryui.com', - 'body_class' => 'jquery-ui', 'options' => array( 'blogname' => 'jQuery UI 1.8 Documentation', 'stylesheet' => 'api.jqueryui.com', - 'active_plugins' => array(), + 'active_plugins' => array( + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', + ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_logo_link'=> 'https://jqueryui.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), ), 'api.jqueryui.com/1.9' => array( - 'blog_id' => 21, 'cookie_domain' => '.jqueryui.com', - 'body_class' => 'jquery-ui', 'options' => array( 'blogname' => 'jQuery UI 1.9 Documentation', 'stylesheet' => 'api.jqueryui.com', - 'active_plugins' => array(), + 'active_plugins' => array( + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', + ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_logo_link'=> 'https://jqueryui.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), ), 'jquery.org' => array( - 'blog_id' => 9, 'cookie_domain' => '.jquery.org', - 'body_class' => 'jquery-foundation', 'options' => array( 'blogname' => 'jQuery Foundation', 'stylesheet' => 'jquery.org', 'active_plugins' => array( 'jquery-static-index.php', ), + 'jquery_body_class' => 'jquery-foundation', ), ), - 'qunitjs.com' => array( - 'blog_id' => 10, - 'cookie_domain' => '.qunitjs.com', - 'body_class' => 'qunitjs', + 'jquerymobile.com' => array( + 'cookie_domain' => '.jquerymobile.com', 'options' => array( - 'blogname' => 'QUnit', - 'stylesheet' => 'qunitjs.com', + 'blogname' => 'jQuery Mobile', + 'stylesheet' => 'jquerymobile.com', 'active_plugins' => array( 'jquery-static-index.php', ), + 'jquery_body_class' => 'jquery-mobile', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jquerymobile_com', + 'jquery_twitter_link' => 'https://twitter.com/jquerymobile', ), ), - 'sizzlejs.com' => array( - 'blog_id' => 11, - 'cookie_domain' => '.sizzlejs.com', - 'body_class' => 'sizzlejs', + 'api.jquerymobile.com' => array( + 'subsites' => true, // Has one level of sub-sites (api.jquerymobile.com/([^/]+)) + 'cookie_domain' => '.jquerymobile.com', 'options' => array( - 'blogname' => 'Sizzle JS', - 'stylesheet' => 'sizzlejs.com', + 'blogname' => 'jQuery Mobile API Documentation', + 'stylesheet' => 'api.jquerymobile.com', 'active_plugins' => array( - 'jquery-static-index.php', + 'jquery-api-category-listing.php', ), + 'jquery_body_class' => 'jquery-mobile', + 'jquery_logo_link'=> 'https://jquerymobile.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jquerymobile_com', + 'jquery_twitter_link' => 'https://twitter.com/jquerymobile', ), ), - 'jquerymobile.com' => array( - 'blog_id' => 12, + 'blog.jquerymobile.com' => array( 'cookie_domain' => '.jquerymobile.com', - 'body_class' => 'jquery-mobile', 'options' => array( - 'blogname' => 'jQuery Mobile', + 'blogname' => 'jQuery Mobile Blog', + 'permalink_structure' => '/%year%/%monthnum%/%day%/%postname%/', 'stylesheet' => 'jquerymobile.com', + 'jquery_body_class' => 'jquery-mobile', + 'jquery_is_blog' => true, + 'jquery_author' => 'jQuery Team', + 'jquery_description' => 'jQuery: The Write Less, Do More, JavaScript Library', + 'jquery_twitter_link' => 'https://twitter.com/jquerymobile', + ), + ), + 'brand.jquery.org' => array( + 'cookie_domain' => '.jquery.org', + 'options' => array( + 'blogname' => 'jQuery Brand Guidelines', + 'stylesheet' => 'brand.jquery.org', 'active_plugins' => array( 'jquery-static-index.php', ), + 'jquery_body_class' => 'jquery-foundation', ), ), - 'api.jquerymobile.com' => array( - 'blog_id' => 13, - 'cookie_domain' => '.jquerymobile.com', - 'body_class' => 'jquery-mobile', + 'contribute.jquery.org' => array( + 'cookie_domain' => '.jquery.org', 'options' => array( - 'blogname' => 'jQuery Mobile API Documentation', - 'stylesheet' => 'api.jquerymobile.com', + 'blogname' => 'Contribute to jQuery', + 'stylesheet' => 'contribute.jquery.org', 'active_plugins' => array( 'jquery-static-index.php', ), + 'jquery_body_class' => 'jquery-foundation', ), ), - 'api.qunitjs.com' => array( - 'blog_id' => 14, - 'cookie_domain' => '.qunitjs.com', - 'body_class' => 'qunitjs', + 'meetings.jquery.org' => array( + 'cookie_domain' => '.jquery.org', 'options' => array( - 'blogname' => 'QUnit API Documentation', - 'stylesheet' => 'api.qunitjs.com', + 'blogname' => 'jQuery Meetings', + 'stylesheet' => 'meetings.jquery.org', 'active_plugins' => array( 'jquery-static-index.php', ), + 'jquery_body_class' => 'jquery-foundation', ), ), - 'books.jquery.com' => array( - 'blog_id' => 15, - 'cookie_domain' => '.jquery.com', - 'body_class' => 'jquery', + 'api.jquerymobile.com/1.3' => array( + 'cookie_domain' => '.jquerymobile.com', + 'options' => array( + 'blogname' => 'jQuery Mobile 1.3 Documentation', + 'stylesheet' => 'api.jquerymobile.com', + 'active_plugins' => array( + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', + ), + 'jquery_body_class' => 'jquery-mobile', + 'jquery_logo_link'=> 'https://jquerymobile.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jquerymobile_com', + 'jquery_twitter_link' => 'https://twitter.com/jquerymobile', + ), + ), + 'api.jqueryui.com/1.10' => array( + 'cookie_domain' => '.jqueryui.com', 'options' => array( - 'blogname' => 'jQuery Books', - 'stylesheet' => 'books.jquery.com', + 'blogname' => 'jQuery UI 1.10 Documentation', + 'stylesheet' => 'api.jqueryui.com', + 'active_plugins' => array( + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', + ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_logo_link'=> 'https://jqueryui.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), ), - 'events.jquery.org' => array( - 'blog_id' => 16, - 'cookie_domain' => '.jquery.org', - 'body_class' => 'jquery-events', + 'api.jqueryui.com/1.12' => array( + 'cookie_domain' => '.jqueryui.com', 'options' => array( - 'blogname' => 'jQuery Events', - 'stylesheet' => 'events.jquery.org', + 'blogname' => 'jQuery UI 1.12 Documentation', + 'stylesheet' => 'api.jqueryui.com', 'active_plugins' => array( - 'allow-numeric-stubs/allow-numeric-stubs.php', + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_logo_link'=> 'https://jqueryui.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), ), - 'brand.jquery.org' => array( - 'blog_id' => 18, - 'cookie_domain' => '.jquery.org', - 'body_class' => 'jquery-foundation', + 'api.jqueryui.com/1.11' => array( + 'cookie_domain' => '.jqueryui.com', 'options' => array( - 'blogname' => 'jQuery Brand Guidelines', - 'stylesheet' => 'brand.jquery.org', + 'blogname' => 'jQuery UI 1.11 Documentation', + 'stylesheet' => 'api.jqueryui.com', 'active_plugins' => array( - 'jquery-static-index.php', + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_logo_link'=> 'https://jqueryui.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), ), - 'contribute.jquery.org' => array( - 'blog_id' => 19, - 'cookie_domain' => '.jquery.org', - 'body_class' => 'jquery-foundation', + 'api.jquerymobile.com/1.4' => array( + 'cookie_domain' => '.jquerymobile.com', 'options' => array( - 'blogname' => 'Contribute to jQuery', - 'stylesheet' => 'contribute.jquery.org', + 'blogname' => 'jQuery Mobile 1.4 Documentation', + 'stylesheet' => 'api.jquerymobile.com', 'active_plugins' => array( - 'jquery-static-index.php', + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', ), + 'jquery_body_class' => 'jquery-mobile', + 'jquery_logo_link'=> 'https://jquerymobile.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jquerymobile_com', + 'jquery_twitter_link' => 'https://twitter.com/jquerymobile', ), ), - 'irc.jquery.org' => array( - 'blog_id' => 20, - 'cookie_domain' => '.jquery.org', - 'body_class' => 'jquery-foundation', + 'releases.jquery.com' => array( + 'cookie_domain' => '.jquery.com', 'options' => array( - 'blogname' => 'jQuery IRC Center', - 'stylesheet' => 'irc.jquery.org', + 'blogname' => 'jQuery CDN', + 'jquery_description' => 'Worldwide distribution of jQuery releases.', + 'stylesheet' => 'releases.jquery.com', 'active_plugins' => array( 'jquery-static-index.php', ), + 'jquery_body_class' => 'jquery', ), ), - 'meetings.jquery.org' => array( - 'blog_id' => 22, - 'cookie_domain' => '.jquery.org', - 'body_class' => 'jquery-foundation', + 'api.jqueryui.com/1.13' => array( + 'cookie_domain' => '.jqueryui.com', 'options' => array( - 'blogname' => 'jQuery Meetings', - 'stylesheet' => 'meetings.jquery.org', + 'blogname' => 'jQuery UI 1.13 Documentation', + 'stylesheet' => 'api.jqueryui.com', 'active_plugins' => array( - 'jquery-static-index.php', + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', + ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_logo_link'=> 'https://jqueryui.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', + ), + ), + 'api.jqueryui.com/1.14' => array( + 'cookie_domain' => '.jqueryui.com', + 'options' => array( + 'blogname' => 'jQuery UI 1.14 Documentation', + 'stylesheet' => 'api.jqueryui.com', + 'active_plugins' => array( + 'jquery-api-category-listing.php', + 'jquery-api-versioned-links.php', ), + 'jquery_body_class' => 'jquery-ui', + 'jquery_logo_link'=> 'https://jqueryui.com/', + 'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz', + 'jquery_typesense_collection' => 'jqueryui_com', + 'jquery_twitter_link' => 'https://twitter.com/jqueryui', ), - ) + ), ); - uasort( $sites, function( $a, $b ) { - if ( $a['blog_id'] == $b['blog_id'] ) - die( 'Two sites have the same blog_id. Blame nacin?' ); - if ( $a['blog_id'] > $b['blog_id'] ) - return 1; - return -1; - } ); return $sites; } +/** + * Resolve a canonical site (e.g. JQUERY_LIVE_SITE) into one for + * the current environment. This exists to automatically change + * the site hostname if JQUERY_STAGING is true. + * + * This is cheap and can be applied at the last minute as-needed. + * + * @param string $site + * @return string + */ +function jquery_site_expand( $site ) { + if ( JQUERY_STAGING ) { + return strtr( JQUERY_STAGING_FORMAT, [ '%s' => $site ] ); + } + return $site; +} + +/** + * @param string $site E.g. `$_SERVER['HTTP_HOST']` + * @return string + */ +function jquery_site_extract( $hostname ) { + $live_site = preg_replace( '/:\d+$/', '', strtolower( $hostname ) ); + if ( JQUERY_STAGING ) { + // Convert the format into a regex that matches the placeholder + // Strip port from both because the webserver may internally have + // a different port from the public one + $rPortless = preg_quote( preg_replace( '/:\d+$/', '', JQUERY_STAGING_FORMAT ), '/' ); + $rPortless = strtr( $rPortless, [ '%s' => '(.+)' ] ); + $rPortless = "/^{$rPortless}$/"; + if ( preg_match( $rPortless, $live_site, $m ) ) { + $live_site = $m[1]; + } + } + return $live_site; +} + function jquery_default_site_options() { - return array( + $defaults = array( 'enable_xmlrpc' => 1, 'template' => 'jquery', 'blogdescription' => '', 'permalink_structure' => '/%postname%/', 'use_smilies' => 0, + + 'close_comments_days_old' => 14, + 'close_comments_for_old_posts' => 1, + 'comment_moderation' => 1, + 'comments_notify' => 0, + 'default_comment_status' => 'closed', + 'default_ping_status' => 'closed', + 'show_comments_cookies_opt_in' => 0, + + // The one site where comments are sometimes enabled (blog.jquery.com) + // has always had thread_comments turned off. + // + // Other sites like api.jquery.com implement their pages as posts, + // but naturally don't support comments at all. Turn this off to + // remove the WordPress comment-reply script from pages by default. + 'thread_comments' => 0, ); + // Production databases set the home values in corresponding site options tables. + // However, sites that use jquery-static-index.php cause index pages + // to redirect to live sites in local development. This filter does not + // prevent the redirect, but changes the redirect to the local site. + // + // WordPress/wp-login.php requires 'home' to use a full URL. + // If it uses a protocol-relative URL, it uses the entire URL as the "path=" + // and thus cause cookies to never be sent by the browser. This doesn't matter + // much for the public stage sites where we don't login, but it matters for + // jquery-wp-docker. + // + // To ensure canonical URLs work correctly on public stage sites and avoid + // HTTP-403 errors, apply set_url_scheme() which will change it to stay on + // HTTPS if you're already on HTTPS. + if ( JQUERY_STAGING ) { + $defaults['home'] = set_url_scheme( 'http://' . jquery_site_expand( JQUERY_LIVE_SITE ) ); + $defaults['siteurl'] = set_url_scheme( 'http://' . jquery_site_expand( JQUERY_LIVE_SITE ) ); + } + return $defaults; + } diff --git a/sunrise.php b/sunrise.php deleted file mode 100644 index 1fe1079e..00000000 --- a/sunrise.php +++ /dev/null @@ -1,54 +0,0 @@ -site_name ) ) - $current_site->site_name = 'jQuery'; - $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); - - // Can't find the site in the DB: - if ( ! is_object( $current_blog ) ) { - $current_blog = new stdClass; - $current_blog->blog_id = $current_blog->site_id = $current_blog->public = 1; - $current_blog->archived = $current_blog->deleted = $current_blog->spam = 0; - - add_filter( 'ms_site_check', '__return_true' ); - - if ( ! defined( 'WP_INSTALLING' ) ) { - // Okay, see if we can find the main site in the DB. - // If not, time for a new network install. - if ( 1 == $blog_id || ! $wpdb->get_var( "SELECT blog_id FROM $wpdb->blogs WHERE blog_id = 1" ) ) { - require( ABSPATH . WPINC . '/kses.php' ); - require( ABSPATH . WPINC . '/pluggable.php' ); - require( ABSPATH . WPINC . '/formatting.php' ); - wp_redirect( 'http://' . DOMAIN_CURRENT_SITE . '/wp-admin/install.php' ); - die(); - } - - // Otherwise, we have a working network, but have a new site to install. Do that now. - define( 'WP_INSTALLING', true ); - add_action( 'init', function() use ( $blog_id ) { - global $wpdb; - $wpdb->set_blog_id( $blog_id ); - if ( is_super_admin() ) { - $super_admin = wp_get_current_user(); - } else { - $super_admins = get_super_admins(); - $super_admin = get_user_by( 'login', reset( $super_admins ) ); - } - require ABSPATH . 'wp-admin/includes/upgrade.php'; - $sites = jquery_sites(); - $site = str_replace( JQUERY_STAGING_PREFIX, '', $_SERVER['HTTP_HOST'] ); - if ( ! empty( $sites[ $site ]['subsites'] ) ) { - list( $first_path_segment ) = explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ), 2 ); - if ( $first_path_segment && isset( $sites[ $site . '/' . $first_path_segment ] ) ) - $site .= '/' . $first_path_segment; - } - - jquery_install_site( $site, $super_admin ); - wp_safe_redirect( 'http://' . JQUERY_STAGING_PREFIX . $site ); - exit; - } ); - } - } -} \ No newline at end of file diff --git a/themes/api.jquery.com/functions.php b/themes/api.jquery.com/functions.php new file mode 100644 index 00000000..1a47f39a --- /dev/null +++ b/themes/api.jquery.com/functions.php @@ -0,0 +1,10 @@ +

jQuery API

+

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. If you're new to jQuery, we recommend that you check out the jQuery Learning Center.

+

If you're updating to a newer version of jQuery, be sure to read the release notes published on our blog. If you're coming from a version prior 1.9, you should check out the 1.9 Upgrade Guide as well.

+

Note that this is the API documentation for jQuery core. Other projects have API docs in other locations:

+
'2.2 and newer', + '1.4' => '1.8 and newer', + '1.3' => '1.7 and newer', + ); +} + +function jq_mobile_ui_api_versions() { + return array( + '1.5' => '1.12', + '1.4' => '1.10', + '1.3' => '1.9' + ); +} + +function jq_mobile_api_version_latest() { + $versions = jq_mobile_api_versions(); + return key( $versions ); +} + +function jq_mobile_api_version_current() { + $thisVersion = explode( "/", JQUERY_LIVE_SITE ); + return count( $thisVersion ) === 2 ? + $thisVersion[ 1 ] : + jq_mobile_api_version_latest(); +} + +// Allow inline scripts and styles in API demos +add_filter( 'jq_content_security_policy', function ( $policy ) { + $policy[ 'script-src' ] = "'self' 'unsafe-inline' code.jquery.com"; + $policy[ 'style-src' ] = "'self' 'unsafe-inline' code.jquery.com"; + return $policy; +} ); diff --git a/themes/api.jquerymobile.com/i/favicon.ico b/themes/api.jquerymobile.com/i/favicon.ico index 8ccd62d1..360dae94 100644 Binary files a/themes/api.jquerymobile.com/i/favicon.ico and b/themes/api.jquerymobile.com/i/favicon.ico differ diff --git a/themes/api.jquerymobile.com/index.php b/themes/api.jquerymobile.com/index.php new file mode 100644 index 00000000..4026eb0d --- /dev/null +++ b/themes/api.jquerymobile.com/index.php @@ -0,0 +1,74 @@ + + +
+
+

jQuery Mobile API Documentation

+
+ + + +

jQuery Mobile is the easiest way to build sites and apps that are accessible on all + popular smartphone, tablet and desktop devices.

+ +

If you are new to jQuery Mobile, the introduction to the framework in the + Demos + would be a good place to start.

+ +

This site provides API documentation for jQuery Mobile

+ + + +

This site provides API documentation for jQuery Mobile . + We encourage you to upgrade to the latest stable version of jQuery Mobile + in order to receive the best support and take advantage of recent bug + fixes and enhancements. Check out the + upgrade guides + and changelogs + to find out more about upgrading.

+ + + +

To get started, use the search at the top of the page, view the + ">full listing of entries, or browse by + category from the sidebar.

+ +

jQuery Mobile uses jQuery UI and + supports jQuery . + +

See the supported platforms page for a list of all + operating systems and browsers that are supported by this version of jQuery Mobile.

+ +
+ +

Can't find what you're looking for?

+ +

Perhaps one of the following sites will help:

+ + + +
+ +
+ + diff --git a/themes/api.jquerymobile.com/style.css b/themes/api.jquerymobile.com/style.css index e1c8349b..143451b7 100644 --- a/themes/api.jquerymobile.com/style.css +++ b/themes/api.jquerymobile.com/style.css @@ -9,7 +9,7 @@ a { .version-details a, .returns a { - color: #3EB249; + color: #3eb249; } .signatures li h4 { diff --git a/themes/api.jqueryui.com/functions.php b/themes/api.jqueryui.com/functions.php index f82970d1..4f2e6c6e 100644 --- a/themes/api.jqueryui.com/functions.php +++ b/themes/api.jqueryui.com/functions.php @@ -1,11 +1,15 @@ "1.6 and newer", - "1.9" => "1.6 and newer", - "1.8" => "1.3.2 and newer", + "1.14" => "latest versions of jQuery 1.x, 2.x, 3.x & 4.x; see the changelogs of a specific release for more detailed support information", + "1.13" => "jQuery 1.8 and newer", + "1.12" => "jQuery 1.7 and newer", + "1.11" => "jQuery 1.6 and newer", + "1.10" => "jQuery 1.6 and newer", + "1.9" => "jQuery 1.6 and newer", + "1.8" => "jQuery 1.3.2 and newer", ); } @@ -20,3 +24,10 @@ function jq_ui_api_version_current() { $thisVersion[ 1 ] : jq_ui_api_version_latest(); } + +// Allow inline scripts and styles in API demos +add_filter( 'jq_content_security_policy', function ( $policy ) { + $policy[ 'script-src' ] = "'self' 'unsafe-inline' code.jquery.com"; + $policy[ 'style-src' ] = "'self' 'unsafe-inline' code.jquery.com"; + return $policy; +} ); diff --git a/themes/api.jqueryui.com/i/favicon.ico b/themes/api.jqueryui.com/i/favicon.ico index 77e3bd2d..d6c4de29 100755 Binary files a/themes/api.jqueryui.com/i/favicon.ico and b/themes/api.jqueryui.com/i/favicon.ico differ diff --git a/themes/api.jqueryui.com/index.php b/themes/api.jqueryui.com/index.php index ffdc74e5..f72eaddb 100644 --- a/themes/api.jqueryui.com/index.php +++ b/themes/api.jqueryui.com/index.php @@ -18,40 +18,39 @@

jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. If you're new to jQuery UI, you might want to check out our - main site for + main site for more information and full demos. If you're new to jQuery, you might - also be interested in the jQuery + also be interested in the jQuery Learning Center tutorials.

-

This site provides API documentation for jQuery UI 1.10. If - you're working with jQuery UI 1.9, you can find the API documentation - on api.jqueryui.com/1.9/. - However, we would encourage you to upgrade to jQuery UI 1.10 in order +

This site provides API documentation for jQuery UI . If + you're working with an older version, you can find the API documentation + at the links below. + However, we would encourage you to upgrade to jQuery UI in order to receive the best support and take advantage of recent bug fixes and enhancements. Check out the - release announcement - and upgrade guide - to find out more about jQuery UI 1.10.

+ upgrade guide + to find out more about jQuery UI .

This site provides API documentation for jQuery UI . We encourage you to upgrade to - the latest stable version of jQuery UI + the latest stable version of jQuery UI in order to receive the best support and take advantage of recent bug fixes and enhancements. Check out the - upgrade guides - and changelogs + upgrade guides + and changelogs to find out more about upgrading.

To get started, use the search at the top of the page, view the - ">full listing of entries, or browse by + ">full listing of entries, or browse by category from the sidebar.

jQuery UI - supports jQuery .

+ supports .


@@ -68,9 +67,9 @@ $url = $version === $latestVersion ? '/' : "/$version/"; echo "
  • jQuery UI $version API Documentation
  • "; } ?> -
  • jQuery Core API Documentation
  • -
  • jQuery Mobile API Documentation
  • -
  • jQuery Learning Center
  • +
  • jQuery Core API Documentation
  • +
  • jQuery Mobile API Documentation
  • +
  • jQuery Learning Center
  • diff --git a/themes/api.jqueryui.com/style.css b/themes/api.jqueryui.com/style.css index 16a3bae3..af7abe92 100755 --- a/themes/api.jqueryui.com/style.css +++ b/themes/api.jqueryui.com/style.css @@ -4,14 +4,14 @@ Template: jquery */ a { - color: #B24926; + color: #b24926; } .version-details a, .returns a { - color: #FAA523; + color: #faa523; } .signatures li h4 { - background: #B24926; + background: #b24926; } diff --git a/themes/api.qunitjs.com/content-listing.php b/themes/api.qunitjs.com/content-listing.php deleted file mode 100644 index a0ddf4ec..00000000 --- a/themes/api.qunitjs.com/content-listing.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/themes/api.qunitjs.com/footer.php b/themes/api.qunitjs.com/footer.php deleted file mode 100644 index 988370b4..00000000 --- a/themes/api.qunitjs.com/footer.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/themes/api.qunitjs.com/i/favicon.ico b/themes/api.qunitjs.com/i/favicon.ico deleted file mode 100644 index cd47fd3c..00000000 Binary files a/themes/api.qunitjs.com/i/favicon.ico and /dev/null differ diff --git a/themes/api.qunitjs.com/single.php b/themes/api.qunitjs.com/single.php deleted file mode 100644 index 328fe1fd..00000000 --- a/themes/api.qunitjs.com/single.php +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/themes/contribute.jquery.org/style.css b/themes/contribute.jquery.org/style.css index f9cadeeb..585335da 100755 --- a/themes/contribute.jquery.org/style.css +++ b/themes/contribute.jquery.org/style.css @@ -15,20 +15,14 @@ em.color { .example { border: 1px solid #dadada; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - padding: 0 20px; - margin-bottom: 30px; + border-radius: 3px; + padding: 0 20px; + margin-bottom: 30px; } .example pre { clear: both; margin:0 -20px; - -webkit-border-bottom-right-radius: 3px; - -webkit-border-bottom-left-radius: 3px; - -moz-border-radius-bottomright: 3px; - -moz-border-radius-bottomleft: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; } @@ -37,10 +31,6 @@ em.color { background-color: #f1f1f1; margin: 0 -20px 15px; padding: 20px; - -webkit-border-top-left-radius: 3px; - -webkit-border-top-right-radius: 3px; - -moz-border-radius-topleft: 3px; - -moz-border-radius-topright: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; } @@ -48,13 +38,9 @@ em.color { .example h3.ignore-example { background-color: #fff; margin:0 0 10px 0; - padding: 0px; - -webkit-border-top-left-radius: 0px; - -webkit-border-top-right-radius: 0px; - -moz-border-radius-topleft: 0px; - -moz-border-radius-topright: 0px; - border-top-left-radius: 0px; - border-top-right-radius: 0px; + padding: 0; + border-top-left-radius: 0; + border-top-right-radius: 0; } .example #banner-secondary { diff --git a/themes/events.jquery.org/i/favicon.ico b/themes/events.jquery.org/i/favicon.ico deleted file mode 100644 index bcc3a138..00000000 Binary files a/themes/events.jquery.org/i/favicon.ico and /dev/null differ diff --git a/themes/events.jquery.org/page.php b/themes/events.jquery.org/page.php deleted file mode 100644 index 77cddf01..00000000 --- a/themes/events.jquery.org/page.php +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/themes/events.jquery.org/style.css b/themes/events.jquery.org/style.css deleted file mode 100644 index 2a8dd19b..00000000 --- a/themes/events.jquery.org/style.css +++ /dev/null @@ -1,4 +0,0 @@ -/* -Theme Name: events-jquery-org -Template: jquery -*/ diff --git a/themes/index.php b/themes/index.php index 4e6c07c7..62200328 100755 --- a/themes/index.php +++ b/themes/index.php @@ -1,3 +1,2 @@ \ No newline at end of file diff --git a/themes/irc.jquery.org/i/favicon.ico b/themes/irc.jquery.org/i/favicon.ico deleted file mode 100644 index bcc3a138..00000000 Binary files a/themes/irc.jquery.org/i/favicon.ico and /dev/null differ diff --git a/themes/irc.jquery.org/robots.txt b/themes/irc.jquery.org/robots.txt deleted file mode 100644 index 6288b163..00000000 --- a/themes/irc.jquery.org/robots.txt +++ /dev/null @@ -1,21 +0,0 @@ -User-Agent: * -Disallow: /wp-admin/ -Disallow: /wp-includes/ - -Disallow: /%23jquery/ -Disallow: /%23jquery-dev/ -Disallow: /%23jqueryui-dev/ -Disallow: /%23jquerymobile-dev/ -Disallow: /%23jquery-meeting/ -Disallow: /%23jquery-infrastructure/ -Disallow: /%23jquery-developer-summit/ -Disallow: /%23jquery-content/ - -Disallow: /#jquery/ -Disallow: /#jquery-dev/ -Disallow: /#jqueryui-dev/ -Disallow: /#jquerymobile-dev/ -Disallow: /#jquery-meeting/ -Disallow: /#jquery-infrastructure/ -Disallow: /#jquery-developer-summit/ -Disallow: /#jquery-content/ diff --git a/themes/irc.jquery.org/sidebar.php b/themes/irc.jquery.org/sidebar.php deleted file mode 100644 index fc0ccac0..00000000 --- a/themes/irc.jquery.org/sidebar.php +++ /dev/null @@ -1,16 +0,0 @@ - - diff --git a/themes/irc.jquery.org/style.css b/themes/irc.jquery.org/style.css deleted file mode 100755 index 2cfc318d..00000000 --- a/themes/irc.jquery.org/style.css +++ /dev/null @@ -1,12 +0,0 @@ -/* -Theme Name: irc-jquery-org -Template: jquery -*/ - -iframe { - border: 0; -} - -a { - color: #065791; -} diff --git a/themes/jquery.com/i/download.png b/themes/jquery.com/i/download.png index 477c029d..df1da9b4 100644 Binary files a/themes/jquery.com/i/download.png and b/themes/jquery.com/i/download.png differ diff --git a/themes/jquery.com/i/favicon.ico b/themes/jquery.com/i/favicon.ico index bcc3a138..acc27029 100644 Binary files a/themes/jquery.com/i/favicon.ico and b/themes/jquery.com/i/favicon.ico differ diff --git a/themes/jquery.com/i/feature-sprites.png b/themes/jquery.com/i/feature-sprites.png index 3e5bb0a8..5c195140 100644 Binary files a/themes/jquery.com/i/feature-sprites.png and b/themes/jquery.com/i/feature-sprites.png differ diff --git a/themes/jquery.com/i/try-jquery.jpg b/themes/jquery.com/i/try-jquery.jpg deleted file mode 100644 index b3569dd0..00000000 Binary files a/themes/jquery.com/i/try-jquery.jpg and /dev/null differ diff --git a/themes/jquery.com/i/try-jquery@2x.jpg b/themes/jquery.com/i/try-jquery@2x.jpg deleted file mode 100644 index f2468091..00000000 Binary files a/themes/jquery.com/i/try-jquery@2x.jpg and /dev/null differ diff --git a/themes/jquery.com/i/whos-using-sprite.png b/themes/jquery.com/i/whos-using-sprite.png index 779dc32c..3edc03f6 100644 Binary files a/themes/jquery.com/i/whos-using-sprite.png and b/themes/jquery.com/i/whos-using-sprite.png differ diff --git a/themes/jquery.com/page.php b/themes/jquery.com/page.php new file mode 100644 index 00000000..023587ed --- /dev/null +++ b/themes/jquery.com/page.php @@ -0,0 +1,4 @@ + a { - display:block; + display: block; padding: 0 0 .5em 0; font-size: 2em; width: 100%; - text-align:center; + text-align: center; text-decoration: none; line-height: 0.8em; } @@ -96,93 +84,136 @@ a, font-size: 0.6em; } #content #banner-secondary .download-main > a span.download { - background: url('i/download.png') 0px 0px; + background: url('i/download.png') 0 0; width: 44px; - height:37px; + height: 37px; position: relative; top: 1em; - display:inline-block; - margin-right:0.5em; + display: inline-block; + margin-right: 0.5em; } - -.resources { - padding-left: 60px; +#content #banner-secondary .download-main .support-notice { + font-size: 12px; } -#content li.try-jquery { - background: none; - margin: 10px 0 0; - padding: 0; +/* New download button */ +#banner-secondary > .download { + display: flex; + flex-direction: column; + align-items: flex-start; + margin-bottom: 1em; } - -#content li.try-jquery a { - background: url('i/try-jquery.jpg') top left no-repeat; - height: 126px; - width: 277px; - text-indent: -9999px; - display: block; +.download-button-content { + display: flex; + flex-direction: row; + align-items: center; + gap: 0.5em; } - -@media only screen and (-webkit-device-pixel-ratio: 2){ - #sidebar li.try-jquery a { - background: url('i/try-jquery@2x.jpg') top left no-repeat; +.download-button-content .download-icon { + background: url('i/download.png') no-repeat 0 5px / 100% 100%; + width: 35px; + height: 35px; + display: inline-block; + flex-shrink: 0; +} +.download-button-content .download-message { + flex-grow: 1; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + gap: 0.25em; +} +.download-button-content .download-message .download-version { + font-size: 0.7em; +} +.download-options .support-notice { + margin: 0.5em 0; + color: #ccc; +} +@media only screen and (max-width: 767px) { + #banner-secondary .download { + align-items: center; } } -#content #whos-using li { - background: none; -} +/* Team */ -#whos-using li a { - background: url('i/whos-using-sprite.png') 0px 0px no-repeat; +.block-grid, +#content .block-grid { + display: flex; + flex-flow: row wrap; + margin: 0 -12px; +} +.block-grid li, +#content .block-grid li { display: block; - height: 80px; - text-indent: -9999px; + margin: 0; + padding: 0 12px 12px; } - -#whos-using li a.mediatemple { - background-position: 0 -80px; +.block-grid.two-up li, +#content .block-grid.two-up li { + width: 50%; } - -#whos-using li a.backbone { - background-position: 0 -160px; +.block-grid.three-up li, +#content .block-grid.three-up li { + width: 33.33%; } - -#whos-using li a.wikipedia { - background-position: 0 -240px; +.block-grid.four-up li, +#content .block-grid.four-up li { + width: 25%; } - -/* Project Tiles */ - -#content .project-tiles { - margin: 0; +.block-grid.five-up li, +#content .block-grid.five-up li { + width: 20%; +} +@media only screen and (max-width: 767px) { + .block-grid.mobile-one-up li { width: 100% !important; } + .block-grid.mobile-two-up li { width: 50% !important; } + .block-grid.mobile-three-up li { width: 33.33% !important; } + .block-grid.mobile-four-up li { width: 25% !important; } } -.project-tile { - padding-top: 1em; - padding-bottom: 1em; +.page-slug-team .block-grid li { text-align: center; } -.project-tile a { - text-indent: -9999px; - display: inline-block; +.page-slug-team .block-grid img { + max-width: 100%; + margin-bottom: 10px; } - -/* Browser Support */ - -#support-matrix { - width: 100%; - margin: 0 auto 1em; +.page-slug-team .block-grid p { + text-align: left; +} +.page-slug-team #content h2 { + color: #333; + font-size: 20px; + line-height: 20px; + font-weight: bold; + text-align: center; + margin-bottom: 5px; +} +.page-slug-team #content h3 { + color: #0769ad; + font-style: italic; + font-size: 14px; + line-height: 18px; + text-align: center; } -#support-matrix tbody tr { - border-bottom: none; +.page-slug-team #content .team-list h3 { + min-height: 5px; } -#support-matrix tbody tr:hover { - background-color: transparent; +.page-slug-team #content .past-team-list h2, +.page-slug-team #content .past-team-list h3 { + text-align: left; +} +.page-slug-team #content .past-team-list h3 { + min-height: 45px; + border-bottom: 1px solid #dbdbdb; } -#support-matrix td { - text-align: center; +.page-slug-team .center-txt { + padding-left: 10%; + padding-right: 10%; } diff --git a/themes/jquery.org/i/favicon.ico b/themes/jquery.org/i/favicon.ico index bcc3a138..acc27029 100644 Binary files a/themes/jquery.org/i/favicon.ico and b/themes/jquery.org/i/favicon.ico differ diff --git a/themes/jquery.org/i/icon_whouseslogos.gif b/themes/jquery.org/i/icon_whouseslogos.gif index a0013803..606bd5c9 100755 Binary files a/themes/jquery.org/i/icon_whouseslogos.gif and b/themes/jquery.org/i/icon_whouseslogos.gif differ diff --git a/themes/jquery.org/images/dark-grey-tile.png b/themes/jquery.org/images/dark-grey-tile.png deleted file mode 100644 index aad9ba5f..00000000 Binary files a/themes/jquery.org/images/dark-grey-tile.png and /dev/null differ diff --git a/themes/jquery.org/images/foundation-logos.png b/themes/jquery.org/images/foundation-logos.png index 3eff639f..3e7ce67a 100644 Binary files a/themes/jquery.org/images/foundation-logos.png and b/themes/jquery.org/images/foundation-logos.png differ diff --git a/themes/jquery.org/images/gauze.png b/themes/jquery.org/images/gauze.png deleted file mode 100644 index 73dd27a1..00000000 Binary files a/themes/jquery.org/images/gauze.png and /dev/null differ diff --git a/themes/jquery.org/images/header-join-page.jpg b/themes/jquery.org/images/header-join-page.jpg index d8785007..03076d7a 100644 Binary files a/themes/jquery.org/images/header-join-page.jpg and b/themes/jquery.org/images/header-join-page.jpg differ diff --git a/themes/jquery.org/images/icn-fan.png b/themes/jquery.org/images/icn-fan.png index 8db3360b..ba4f52cc 100644 Binary files a/themes/jquery.org/images/icn-fan.png and b/themes/jquery.org/images/icn-fan.png differ diff --git a/themes/jquery.org/images/icn-friend.png b/themes/jquery.org/images/icn-friend.png index 37669f28..f5f2fd2b 100644 Binary files a/themes/jquery.org/images/icn-friend.png and b/themes/jquery.org/images/icn-friend.png differ diff --git a/themes/jquery.org/images/icn-hero.png b/themes/jquery.org/images/icn-hero.png index 3dc55e6a..a3de3736 100644 Binary files a/themes/jquery.org/images/icn-hero.png and b/themes/jquery.org/images/icn-hero.png differ diff --git a/themes/jquery.org/images/icn-jquery-logo.png b/themes/jquery.org/images/icn-jquery-logo.png index 1dd09eda..1a2acbb8 100644 Binary files a/themes/jquery.org/images/icn-jquery-logo.png and b/themes/jquery.org/images/icn-jquery-logo.png differ diff --git a/themes/jquery.org/style.css b/themes/jquery.org/style.css index edbd2a94..1b222808 100755 --- a/themes/jquery.org/style.css +++ b/themes/jquery.org/style.css @@ -5,25 +5,8 @@ Template: jquery /*Custom Colors*/ a, #sidebar h3 { - color: #0769AD; + color: #0769ad; } -/* -#content code a { - background-color: rgba(6, 89, 150, 0.19); -} - -#content h1 { - color: white; - font-weight: normal; - font-style: normal; -} - -#content h2 { - color: white; - font-weight: normal; - font-style: normal; - margin-bottom: 20px; -}*/ .page-slug-index #banner-secondary.large-banner { padding-top: 20px; @@ -37,15 +20,12 @@ a, #sidebar h3 { height: 360px; background: url(images/header-join-page.jpg) no-repeat center; background-size: cover; - -webkit-background-size: cover; - -moz-background-size: cover; - -o-background-size: cover; display: block; position: relative; } #content h2 { - color: #0769AD; + color: #0769ad; font-weight: normal; font-style: normal; margin-bottom: 20px; @@ -58,9 +38,6 @@ a, #sidebar h3 { height: 360px; background: url(images/header-join-page.jpg) no-repeat center; background-size: cover; - -webkit-background-size: cover; - -moz-background-size: cover; - -o-background-size: cover; display: block; position: relative; } @@ -69,28 +46,12 @@ a, #sidebar h3 { font-size: 60px; } -.jquery-foundation.home #banner-secondary.large-banner.entry-header { - padding-bottom: 0px; -} - -.jquery-foundation.page-slug-join #content #banner-large-image .vertically-centered-black-bg { - margin-top: 14.5%; -} - /*Homepage*/ .large-banner img { margin-bottom: 20px; } -.sub-banner { - background-color: lightgray; - text-align: center; - margin: -25px -25px 0; - color: rgb(102,102,102); - font: bold 20px/40px "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; -} - #content > div.row { margin-top: 30px; } @@ -104,323 +65,29 @@ a, #sidebar h3 { position: relative; } -.flexslider { - width: 100%; - display: block; - border: 1px solid #cbcbcb; - margin-left: 0px; - height:a; - overflow: hidden; - border-radius: 10px; - list-style: none; - padding-top: 10px; -} - #content .slides { - margin-left: 0px; -} - -.flexslider ol { - display: none; -} - -#content .flexslider li { - padding-left: 0px; - background: none; - display: none; + margin-left: 0; } ul.flex-direction-nav { display: none; } -#content .flexslider li { - text-align: center; -} - -#content .flexslider li img { - margin-top: 10px; - display: inline-block; -} - -#content .flexslider li img.last { - margin-right: 0px; -} - -.dark-callout-box { - background-image: url(../jquery/images/dark-grey-tile.png); - margin-bottom: 30px; - border-bottom: 10px solid #c1c1c1; - border-top: 10px solid #c1c1c1; - text-align: center; - padding-top: 35px; - padding-bottom: 35px; - margin-top: 25px; -} - - .jquery-foundation.page-slug-donate #content .dark-callout-box { - padding-top: 0px; - padding-bottom: 0px; - } - -.big-message { - font: bold 50px/50px "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; - color: #ffffff !important; - margin-top: 20px; -} - -#content .dark-callout-box h3 { - font: bold 30px/50px "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; - color: #fff; -} - -#content .dark-callout-box p { - font: bold 30px/50px "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; - color: #dddcdc; -} - -#content .project h4 { - font: bold 24px/50px "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; - margin-bottom: 0; - color: #464646; -} - -#content .project { - margin-top: 35px; -} - - #content .twelve.columns .project { - margin-top: 0px; - } - -.project img { - float: left; - display: inline; - width: 10%; -} - -.project-text { - float: right; - width: 85.5%; -} - -.member-level { - width: 32%; - float: left; - display: inline; - margin-right: 2%; - background: url(../jquery/images/dark-grey-tile.png); - position: relative; - overflow: hidden; -} - -.member-level.last { - margin-right: 0px; -} - -.member-level-icon { - display: block; - position: absolute; - top: 60px; - right: -50px; - width: 225px; - height: 225px; - opacity: 0.2; - z-index: 1; -} - -.member-level button.button.join { - position: relative; - top: 0px; - left: 15px; - margin-bottom: 15px; -} - -.member-level-icon.fan { - background: url(images/icn-fan.png) center top no-repeat; -} - -.member-level-icon.friend { - background: url(images/icn-friend.png) center top no-repeat; -} - -.member-level-icon.hero { - background: url(images/icn-hero.png) center top no-repeat; -} - -#content .member-level h3 { - background-color: rgba(0, 0, 0, 0.66); - color: #ffffff; - text-align: center; - font-size: 30px; - line-height: 48px; - font-weight: bold; -} - .errors li { color: #a00; } -a.icon-search { - width: 100px; - height: 100px; - display: block; - position: relative; - text-decoration: none !important; - float: left; - display: inline; - margin-left: 15px; - margin-bottom: 10px; - z-index: 2; -} - -a.icon-search::before { - position: absolute; - right: 4px; - color: #333333; -} - -.member-level ul.gifts { - float: left; - list-style: none; - position: relative; - z-index: 2; -} - -#content .member-level ul.gifts li, -#content .member-level ul.gifts li strong { - padding-left: 0; - padding-right: 15px; - background: none; - color: #f3f3f3; - font: bold "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;; -} - -.member-level p { - color: #f3f3f3; - font: bold "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; - float: left; - display: inline; - padding-left: 15px; - padding-right: 15px; -} - -.member-level .button { - float: left; - display: inline-block; - clear: both; - position: relative; - z-index: 2; - margin-left: 15px; - margin-bottom: 30px; - -} - -.member-level form .button { - clear: none; -} - -.choose-gifts { - background-color: lightgray; - clear: both; - position: relative; - z-index: 2; - padding-left: 15px; - padding-right: 15px; - padding-top: 15px; - padding-bottom: 45px; -} - -.choose-gifts h4 { - font: bold 18px/20px "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; - margin-bottom: 10px; -} - -.choose-gifts label { - color: #ffffff; - margin-right: 20px; -} - -.choose-gifts hr { - height: 1px; - margin-top: 15px; - margin-bottom: 15px; - background: #898989; -} - -.choose-gifts select { - display: block; - width: 100%; - margin-bottom: 15px; -} - -.choose-gifts button.button.pay { - margin-right: 20px; -} - -#content .choose-gifts textarea { - width: 100%; - background: white; - border: 1px solid rgba(192,192,192,1); -} - -.choose-gifts input[type="name"] { - margin-right: 3px; -} - -.choose-gifts input[type="name"], .choose-gifts input[type="email"]{ - display: inline; - width: 49%; - padding: 8px 12px; - border: 1px solid rgba(192,192,192,1); - border-radius: 2px; - -webkit-box-shadow: inset 0 1px 3px rgba(0,0,0,0.17); - box-shadow: inset 0 1px 3px rgba(0,0,0,0.17); -} - -#content .choose-gifts input:focus, #content .choose-gifts input[type=text]:focus, #content .choose-gifts textarea:focus { - border: 1px solid #78CFF5; - -webkit-box-shadow: none; - box-shadow: none; -} - -#content .choose-gifts input::-webkit-input-placeholder { - color: rgba(51,51,51,0.75); -} -#content .choose-gifts input:-moz-placeholder { - color: rgba(51,51,51,0.75); -} -#content .choose-gifts input::-moz-placeholder { - color: rgba(51,51,51,0.75); -} -#content .choose-gifts input:-ms-input-placeholder { - color: rgba(51,51,51,0.75); -} - -#content .choose-gifts textarea::-webkit-input-placeholder { - color: rgba(51,51,51,0.75); -} -#content .choose-gifts textarea:-moz-placeholder { - color: rgba(51,51,51,0.75); -} -#content .choose-gifts textarea::-moz-placeholder { - color: rgba(51,51,51,0.75); -} -#content .choose-gifts textarea:-ms-input-placeholder { - color: rgba(51,51,51,0.75); -} - /*History Page*/ .page-slug-history #content h2 { - color: #0769AD; + color: #0769ad; font-size: 40px; line-height: 40px; } .page-slug-history #content h3 { - color: #0769AD; + color: #0769ad; font-weight: normal; font-style: normal; border-top: 1px solid #d7d7d7; @@ -428,148 +95,15 @@ a.icon-search::before { font-size: 24px; line-height: 24px; } - -.page-slug-team #content ul.block-grid li { - text-align: center; -} - -.page-slug-team #content ul.block-grid img { - max-width: 100%; - margin-bottom: 10px; -} - -.page-slug-team #content ul.block-grid p { - text-align: left; -} - -.page-slug-team #content h2 { - color: #333; - font-size: 20px; - line-height: 20px; - font-weight: bold; - text-align: center; - margin-bottom:5px; -} - -.page-slug-team #content h3 { - color: #0769AD; - font-style: italic; - font-size: 14px; - line-height: 18px; - text-align: center; - min-height: 45px; - border-bottom: 1px solid #dbdbdb; -} - -.page-slug-team #content ul.team-list h3 { - border: none; - min-height: 5px; -} - -.page-slug-team #content ul.past-team-list h2, -.page-slug-team #content ul.past-team-list h3 { - text-align: left; - -} - -.page-slug-team #content p.center-txt { - padding-left: 10%; - padding-right: 10%; -} - -.page-slug-members #content h2.block { - text-align: center; -} - -.page-slug-members #content a { - color: #d58349; -} - -.page-slug-members #content ul.block-grid li { - text-align: center; -} - -.page-slug-members #content ul.block-grid h3 { - color: #4d4d4d; - font-weight: bold; - font-size: 18px; - line-height: 18px; - margin-bottom: 0; - padding-top: 10px; - text-align: center; -} - -.page-slug-members #content ul.block-grid p { - margin-bottom: 0; -} - -.page-slug-members #content ul.block-grid p a { - text-decoration: none; -} - -.page-slug-members .corporatemembers .row { - margin-top: 2em; - padding-bottom: 2em; -} - -.page-slug-sponsors .sponsors img { - margin: 0.3em 1em 2em; -} - -.page-slug-sponsors .sponsors .row { - margin: 1em 0 2em; -} - .page-slug-faq #content h2 { margin-top: 1em; margin-bottom: 0.3em; } -.page-slug-donate h2 { - text-align: center; -} - -.page-slug-donate form { - padding: 0 4em; -} - -.page-slug-donate select { - vertical-align: top; - margin: 1em; -} - -.page-slug-donate .envelope { - border: 1px solid silver; - border-radius: 3px; - padding: 4em; - margin-bottom: 0.8em; -} - -.page-slug-donate .envelope .vcard { - margin-top: 1em; - margin-left: 30%; -} - -.page-slug-donate #content .row .callout-block { - padding-top: 20px; - padding-bottom: 20px; - margin-bottom: 40px; -} - -/*a.button, -#content a.button, .button { - background-color: #b71551; -} - -a.button:hover, -#content a.button:hover { - background-color: #7c0d36; -}*/ - /*Adjust widths for longer navigation*/ -nav#main .searchform { +.searchform { width: 20%; } @@ -581,30 +115,10 @@ nav#main ul { padding-bottom: 15px; } -@media only screen and (max-width: 767px) { - .sponsors-page ul.block-grid li img { - float: none; - width: 80%; - max-width: 80%; - display: block; - margin-left: auto; - margin-right: auto; - margin-bottom: 20px; - margin-top: 0; - } - - .sponsors-page ul.block-grid li p { - float: none; - width: 100%; - text-align: center; - } -} - /*iPad Portrait*/ -@media only screen and (max-width: 768px) { - +@media only screen and (max-width: 767px) { #banner-large-image { margin-right: -40px; margin-left: -40px; @@ -612,14 +126,11 @@ nav#main ul { height: 200px; background: url(images/header-join-page.jpg) no-repeat center; background-size: cover; - -webkit-background-size: cover; - -moz-background-size: cover; - -o-background-size: cover; display: block; position: relative; } - #banner-large-image .vertically-centered-black-bg{ + #banner-large-image .vertically-centered-black-bg { height: 70% !important; margin-top: 14%; padding-top: 6%; @@ -638,31 +149,11 @@ nav#main ul { line-height: 1.4em; padding-bottom: 60px; } - - .member-level { - width: 100%; - margin-bottom: 30px; - } - - .sub-banner { - background-color: #d6eef1; - text-align: center; - height: auto; - color: #007d88; - font: 20px/26px "klavika-web"; - margin: -30px -40px 0; - padding: 2% 10% 0.5%; - } - - .flexslider { - margin-bottom: 20px; - } } /*iPhone Landscape*/ @media only screen and (max-width: 480px) { - #banner-large-image { margin-right: -25px; margin-left: -25px; @@ -670,14 +161,11 @@ nav#main ul { height: 200px; background: url(images/header-join-page.jpg) no-repeat center; background-size: cover; - -webkit-background-size: cover; - -moz-background-size: cover; - -o-background-size: cover; display: block; position: relative; } - #banner-large-image .vertically-centered-black-bg{ + #banner-large-image .vertically-centered-black-bg { height: 70% !important; margin-top: 14%; padding-top: 7%; @@ -696,47 +184,4 @@ nav#main ul { line-height: 1.1em; padding-bottom: 60px; } - - .member-level { - width: 100%; - margin-bottom: 30px; - } - - .sub-banner { - margin-left: -25px; - margin-right: -25px; - padding-top: 3.5%; - } - - .dark-callout-box { - background-image: url(images/dark-grey-tile.png); - border-bottom: 10px solid #c1c1c1; - border-top: 10px solid #c1c1c1; - text-align: center; - margin-bottom: 0; - padding-right: 22px !important; - padding-left: 22px !important; - } - - #content .dark-callout-box h3 { - font: bold 28px/32px "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; - color: #fff; - } - - #content .dark-callout-box p { - color: #dddcdc; - font-size: 14px; - line-height: 18px; - } - - .big-message { - font: bold 30px/30px "klavika-web", "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif !important; - color: #ffffff !important; - margin-top: 20px; - } - - .callout-block { - padding-right: 20px !important; - padding-left: 20px !important; - } } diff --git a/themes/jquery/404.php b/themes/jquery/404.php index c6b34411..67a59a43 100755 --- a/themes/jquery/404.php +++ b/themes/jquery/404.php @@ -1,21 +1,21 @@ - -
    -
    -
    -
    -

    -
    -
    - -
    -

    -
    -
    -
    -
    - + +
    +
    +
    +
    +

    +
    +
    + +
    +

    +
    +
    +
    +
    + diff --git a/themes/jquery/archive.php b/themes/jquery/archive.php index 93d95ef1..1a3fd962 100755 --- a/themes/jquery/archive.php +++ b/themes/jquery/archive.php @@ -1,44 +1,44 @@ - - -
    -
    - - - - - - - - -
    -
    -

    -
    - -
    -

    -
    -
    - -
    - -
    - - + + +
    +
    + + + + + + + + +
    +
    +

    +
    + +
    +

    +
    +
    + +
    + +
    + + diff --git a/themes/jquery/author.php b/themes/jquery/author.php index 8f1350f0..89be7de7 100755 --- a/themes/jquery/author.php +++ b/themes/jquery/author.php @@ -1,76 +1,77 @@ - - -
    -
    - - - - - - - - - -
    -
    - -
    -
    -

    - -
    -
    - - - - - - - - -
    -
    -

    -
    - -
    -

    -
    -
    - - -
    - - -
    - - + + +
    +
    + + + + + + + + + +
    +
    + +
    +
    +

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

    +
    + +
    +

    +
    +
    + + +
    + + +
    + + diff --git a/themes/jquery/category.php b/themes/jquery/category.php index 65f503b3..19ed54a4 100755 --- a/themes/jquery/category.php +++ b/themes/jquery/category.php @@ -1,52 +1,52 @@ - - -
    -
    - - -
    ' ); - } - ?> - - - - - - - - -
    -
    -

    -
    - -
    -

    -
    -
    - - -
    - - - - - + + +
    +
    + + +
    ' ); + } + ?> + + + + + + + + +
    +
    +

    +
    + +
    +

    +
    +
    + + +
    + + + + + diff --git a/themes/jquery/comments.php b/themes/jquery/comments.php index 3d7d59d8..dd54ec46 100755 --- a/themes/jquery/comments.php +++ b/themes/jquery/comments.php @@ -1,73 +1,48 @@ - -
    - -

    -
    - - - - - -

    - ' . get_the_title() . '' ); - ?> -

    - - 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?> - - - -
      - 'twentyeleven_comment' ) ); - ?> -
    - - 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?> - - - - -

    - - - - - +
    + +

    +
    + + +

    + ' . get_the_title() . '' ); + ?> +

    + + 1 && get_option( 'page_comments' ) ) : ?> + + + +
      + 'jq_comment' ) ); ?> +
    + + 1 && get_option( 'page_comments' ) ) : ?> + + + + +

    + + + + \ No newline at end of file diff --git a/themes/jquery/content-single.php b/themes/jquery/content-single.php index b5a004c0..dd5bd251 100755 --- a/themes/jquery/content-single.php +++ b/themes/jquery/content-single.php @@ -1,65 +1,65 @@ - - -
    > -
    - - - -
    - -
    - - '' ) ); ?> -
    - -
    - %5$s. Bookmark the permalink.', 'twentyeleven' ); - } elseif ( '' != $categories_list ) { - $utility_text = __( 'This entry was posted in %1$s by %5$s. Bookmark the permalink.', 'twentyeleven' ); - } else { - $utility_text = __( 'This entry was posted by %5$s. Bookmark the permalink.', 'twentyeleven' ); - } - - printf( - $utility_text, - $categories_list, - $tag_list, - esc_url( get_permalink() ), - the_title_attribute( 'echo=0' ), - get_the_author(), - esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) - ); - ?> - ', '' ); ?> - - - - -
    -
    + + +
    > +
    + + + +
    + +
    + + '' ) ); ?> +
    + +
    + %5$s. Bookmark the permalink.', 'twentyeleven' ); + } elseif ( '' != $categories_list ) { + $utility_text = __( 'This entry was posted in %1$s by %5$s. Bookmark the permalink.', 'twentyeleven' ); + } else { + $utility_text = __( 'This entry was posted by %5$s. Bookmark the permalink.', 'twentyeleven' ); + } + + printf( + $utility_text, + $categories_list, + $tag_list, + esc_url( get_permalink() ), + the_title_attribute( 'echo=0' ), + get_the_author(), + esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) + ); + ?> + ', '' ); ?> + + + + +
    +
    diff --git a/themes/jquery/content.php b/themes/jquery/content.php index 0d9a490c..a7e72596 100755 --- a/themes/jquery/content.php +++ b/themes/jquery/content.php @@ -26,13 +26,16 @@ - - - - - - - - - diff --git a/themes/jquery/footer-ui.php b/themes/jquery/footer-ui.php index 9733b2b1..d2a5dab8 100644 --- a/themes/jquery/footer-ui.php +++ b/themes/jquery/footer-ui.php @@ -4,49 +4,27 @@ diff --git a/themes/jquery/footer.php b/themes/jquery/footer.php index 75480d6c..e45682b3 100755 --- a/themes/jquery/footer.php +++ b/themes/jquery/footer.php @@ -4,43 +4,27 @@ - diff --git a/themes/jquery/functions.jquery.php b/themes/jquery/functions.jquery.php index 5eab75c5..81ab6036 100644 --- a/themes/jquery/functions.jquery.php +++ b/themes/jquery/functions.jquery.php @@ -143,47 +143,6 @@ function jq_content_nav() { )) . ''; } -function jq_banner() { - $site = explode( '/', JQUERY_LIVE_SITE, 2 ); - $domain = $site[ 0 ]; - - switch ( $domain ) { - case 'jqueryui.com': - case 'api.jqueryui.com': - case 'blog.jqueryui.com': - $site_color = 'orange'; - break; - case 'jquery.org': - case 'contribute.jquery.org': - case 'brand.jquery.org': - case 'irc.jquery.org': - case 'meetings.jquery.org': - $site_color = 'gray'; - break; - case 'learn.jquery.com': - $site_color = 'chalk'; - break; - case 'qunitjs.com': - case 'api.qunitjs.com': - $site_color = 'purple'; - break; - case 'jquerymobile.com': - case 'api.jquerymobile.com': - case 'blog.jquerymobile.com': - $site_color = 'green'; - break; - default: - $site_color = 'blue'; - break; - } - - echo - '' . - '' . - ''; -} - function jq_post_heirarchy() { global $post; $current = $post; @@ -203,3 +162,42 @@ function jq_post_heirarchy() { 'Posted in: ' . implode( ' > ', array_reverse( $parents ) ) . ''; } + +/** + * Fixes paging on a search page when Relevanssi plugin is used + */ +function jq_posts_per_page($limits) { + if (is_search()) { + global $wp_query; + $wp_query->query_vars['posts_per_page'] = 20; + } + return $limits; +} +add_filter('post_limits', 'jq_posts_per_page'); + +function jq_search_get_provider() { + $typesenseKey = get_option( 'jquery_typesense_key' ); + $typesenseCollection = get_option( 'jquery_typesense_collection' ); + if ( $typesenseKey && $typesenseCollection ) { + return 'typesense'; + } + return ''; +} + +/** + * Try to append a "?v=" cache buster to a static CSS or JS file URI. + */ +function jq_url_append_version( $uri ) { + foreach ( [ + get_stylesheet_directory_uri() => get_stylesheet_directory(), + get_template_directory_uri() => get_template_directory(), + ] as $uriPrefix => $directory ) { + if ( str_starts_with( $uri, $uriPrefix ) ) { + $filepath = strtr( $uri, [ $uriPrefix => $directory ] ); + return $uri . '?v=' . substr( @md5_file( $filepath ) ?: '', 0, 8 ); + } + } + + // Unchanged + return $uri; +} diff --git a/themes/jquery/functions.php b/themes/jquery/functions.php index cbdaea01..13f65d70 100755 --- a/themes/jquery/functions.php +++ b/themes/jquery/functions.php @@ -2,27 +2,30 @@ /** * Functions and definitions * - * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API. + * For more information on hooks, actions, and filters, see https://codex.wordpress.org/Plugin_API. */ -require_once( 'functions.jquery.php' ); +require_once 'functions.jquery.php'; /** * Set the content width based on the theme's design and stylesheet. */ -if ( ! isset( $content_width ) ) +if ( !isset( $content_width ) ) { $content_width = 584; +} -/** - * Tell WordPress to run twentyeleven_setup() when the 'after_setup_theme' hook is run. - */ -add_action( 'after_setup_theme', 'twentyeleven_setup' ); - -if ( ! function_exists( 'twentyeleven_setup' ) ): -/** - * Sets up theme defaults and registers support for various WordPress features. - */ -function twentyeleven_setup() { +add_action('init', function () { + // Remove unused stuff from wp_head + add_action('wp_enqueue_scripts', function () { + // Disable default styles that we don't use + wp_dequeue_style('wp-block-library'); + wp_dequeue_style('classic-theme-styles'); + wp_dequeue_style('global-styles'); + wp_dequeue_style('akismet-widget-style'); + }); +}); + +add_action( 'after_setup_theme', function () { // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); @@ -31,55 +34,38 @@ function twentyeleven_setup() { // This theme uses wp_nav_menu() in one location. register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) ); -} -endif; // twentyeleven_setup +} ); /** * Returns a "Continue Reading" link for excerpts */ -function twentyeleven_continue_reading_link() { +function jq_continue_reading_link() { return ' ' . __( 'Continue reading ', 'twentyeleven' ) . ''; } /** - * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyeleven_continue_reading_link(). + * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis + * and jq_continue_reading_link(). * * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. */ -function twentyeleven_auto_excerpt_more( $more ) { - return ' …' . twentyeleven_continue_reading_link(); -} -add_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' ); - -/** - * Adds a pretty "Continue Reading" link to custom post excerpts. - * - * To override this link in a child theme, remove the filter and add your own - * function tied to the get_the_excerpt filter hook. - */ -function twentyeleven_custom_excerpt_more( $output ) { - if ( has_excerpt() && ! is_attachment() ) { - $output .= twentyeleven_continue_reading_link(); - } - return $output; -} -// add_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' ); +add_filter( 'excerpt_more', function ( $more ) { + return ' …' . jq_continue_reading_link(); +} ); /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. */ -function twentyeleven_page_menu_args( $args ) { +add_filter( 'wp_page_menu_args', function ( $args ) { $args['show_home'] = true; return $args; -} -add_filter( 'wp_page_menu_args', 'twentyeleven_page_menu_args' ); +} ); /** * Register our sidebars and widgetized areas. Also register the default Epherma widget. */ -function twentyeleven_widgets_init() { - +add_action( 'widgets_init', function () { register_sidebar( array( 'name' => __( 'Main Sidebar', 'twentyeleven' ), 'id' => 'sidebar-1', @@ -128,28 +114,12 @@ function twentyeleven_widgets_init() { 'before_title' => '

    ', 'after_title' => '

    ', ) ); -} -add_action( 'widgets_init', 'twentyeleven_widgets_init' ); - -/** - * Display navigation to next/previous pages when applicable - */ -function twentyeleven_content_nav( $nav_id ) { - global $wp_query; - - if ( $wp_query->max_num_pages > 1 ) : ?> - - comment_type ) : case 'pingback' : case 'trackback' : - ?> -
  • -

    ', '' ); ?>

    +?> +
  • id="li-comment-"> +

    Pingback: ', '' ); ?>

    said:', 'twentyeleven' ), - sprintf( '%s', get_comment_author_link() ), - sprintf( '', - esc_url( get_comment_link( $comment->comment_ID ) ), + echo sprintf( '%1s on %2s:', + sprintf( '%s', esc_html( get_comment_author() ) ), + sprintf( '', + esc_url( get_comment_link() ), get_comment_time( 'c' ), - /* translators: 1: date, 2: time */ - sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() ) + sprintf( '%1s at %2s', get_comment_date(), get_comment_time() ) ) ); - ?> - - ', '' ); ?> - + edit_comment_link( __( 'Edit', 'twentyeleven' ), ' • ', '' ); ?> + comment_approved == '0' ) : ?> -
    +
    - -
    -
    __( 'Reply ', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> -
    - + + Posted on by ', 'twentyeleven' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), @@ -262,22 +222,33 @@ function twentyeleven_posted_on() { esc_html( get_the_author() ) ); } -endif; + +function jq_image_posted_on() { + printf( __( 'Published in %2$s' ), + esc_url( get_permalink( wp_get_post_parent_id() ) ), + get_the_title( wp_get_post_parent_id() ) + ); + $metadata = wp_get_attachment_metadata(); + printf( __( '%2$s × %3$s' ), + esc_url( wp_get_attachment_url() ), + $metadata['width'], + $metadata['height'], + ); +} /** * Adds two classes to the array of body classes. * The first is if the site has only had one author with published posts. * The second is if a singular post being displayed */ -function twentyeleven_body_classes( $classes ) { +add_filter( 'body_class', function ( $classes ) { if ( ! is_multi_author() ) { $classes[] = 'single-author'; } - if ( is_singular() && ! is_home() && ! is_page_template( 'sidebar-page.php' ) ) + if ( is_singular() && ! is_home() ) $classes[] = 'singular'; return $classes; -} -add_filter( 'body_class', 'twentyeleven_body_classes' ); +} ); diff --git a/themes/jquery/header.php b/themes/jquery/header.php index 8a46887f..d4bb88f9 100755 --- a/themes/jquery/header.php +++ b/themes/jquery/header.php @@ -1,14 +1,10 @@ - - - - > +> - + <?php - global $page, $paged; wp_title( '|', true, 'right' ); bloginfo( 'name' ); $site_description = get_bloginfo( 'description', 'display' ); @@ -16,90 +12,89 @@ echo " | $site_description"; ?> - - - + + + + + + + + - - - - - - - - - - - - - - - - - + + + + - > - + + +