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 3547f762..1bcabeb5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
/gw-resources/*
-.vagrant
+/blogs.dir/*
+/vendor/
+/composer.lock
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1b94478f..089b211a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,5 +1,22 @@
-Welcome! Thanks for your interest in contributing to jquery-wp-content. You're **almost** in the right place. More information on how to contribute to this and all other jQuery Foundation 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](httsp://contribute.jquery.org/web-sites/) and [code](https://contribute.jquery.org/code).
+# 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 find us on [IRC](https://irc.jquery.org), specifically in #jquery-content 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/).
+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/INSTALL.md b/INSTALL.md
deleted file mode 100644
index 7c5eac2a..00000000
--- a/INSTALL.md
+++ /dev/null
@@ -1,123 +0,0 @@
-# jquery-wp-content
-
-`jquery-wp-content` is a **custom replacement** for the `wp-content` directory which contains the plugins, themes and site configuration to run the jQuery multi-site WordPress network.
-
-## Warning
-
-Configuring your own services can result in different configurations from the prodution environment. It is strongly encouraged to use the virtual machine environment as described in [README.md](README.md).
-
-## Prerequisites
-
-This install guide assumes you have certain prerequisites already configured within your environment.
-
-* Apache
-* Mysql
-* PHP
-
-## Installation
-
-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:
-
-```
-
- ServerName local.jquery.com
- ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.qunitjs.com *.sizzlejs.com *.jquerymobile.com
- DocumentRoot "/srv/www/jquery"
- php_value memory_limit 256M
-
- Options All
- AllowOverride All
- Order allow,deny
- Allow from all
-
-
-```
-
-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.
-
-Check `httpd.conf` to ensure that the PHP module is enabled as well.
-
-You do not need to configure your `/etc/hosts` file for `local.*` because `jquery.com`'s DNS handles this for you. However, if you plan to work offline, you can use the following rules:
-
-```
-127.0.0.1 local.jquery.com local.api.jquery.com local.blog.jquery.com local.books.jquery.com local.codeorigin.jquery.com local.learn.jquery.com local.plugins.jquery.com
-127.0.0.1 local.jqueryui.com local.api.jqueryui.com local.blog.jqueryui.com
-127.0.0.1 local.jquerymobile.com local.api.jquerymobile.com local.blog.jquerymobile.com
-127.0.0.1 local.jquery.org local.brand.jquery.org local.contribute.jquery.org local.events.jquery.org local.irc.jquery.org local.meetings.jquery.org
-127.0.0.1 local.qunitjs.com local.api.qunitjs.com
-127.0.0.1 local.sizzlejs.com
-```
-
-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 https://wordpress.org/latest.zip
- * Check out the latest tag from https://core.svn.wordpress.org/tags/
- * Clone the official WordPress Github mirror at https://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. Create a MySQL database and user. You can choose any name you want for both. Follow the [WordPress instructions](https://codex.wordpress.org/Installing_WordPress#Step_2:_Create_the_Database_and_a_User) for a step by step guide.
-
-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. Restart your web server so the changes above are in use.
-
-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.
diff --git a/LICENSE.txt b/LICENSE.txt
index 55c1648e..7d5393a1 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,80 +1,3 @@
-Copyright jQuery Foundation and other contributors, https://jquery.org/
-
-This software consists of voluntary contributions made by many
-individuals. For exact contribution history, see the revision history
-available at https://github.com/jquery/jquery-wp-content
-
-All PHP files in this software that are not externally maintained
-libraries are derivative works of WordPress and licensed under the terms
-GPLv2 or later.
-
-====
-
-The following externally maintained libraries used by this software have
-their own licenses; we recommend you read them, as their terms may
-differ from the terms above.
-
-- Allow Numeric Stubs
- https://wordpress.org/plugins/allow-numeric-stubs/
- located at plugins/allow-numeric-stubs
-
-- Colorbox
- https://www.jacklmoore.com/colorbox/
- located at themes/jquery/js/plugins.js
-
-- Disable Emojis
- https://wordpress.org/plugins/disable-emojis/
- located at mu-plugins/disable-emojis
-
-- FlexSlider
- https://woocommerce.com/flexslider/
- located at themes/jquery/js/plugins.js
-
-- Grunt Wordpress
- https://github.com/scottgonzalez/grunt-wordpress
- located at mu-plugins/grunt-wodpress.php
-
-- matchMedia.js
- https://github.com/paulirish/matchMedia.js
- located at themes/jquery/js/plugins.js
-
-- Modernizr
- https://modernizr.com/
- located at themes/jquery/js/modernizr.custom.2.8.3.min.js
-
-- No Comments on Pages
- https://wordpress.org/plugins/no-comments-on-pages/
- located at plugins/no-comments-on-pages
-
-- Respond.js
- https://github.com/scottjehl/Respond
- located at themes/jquery/js/plugins.js
-
-- Stripe PHP Bindings
- https://github.com/stripe/stripe-php
- located at mu-plugins/jquery.org/lib/Stripe
-
-- TinyNav.js
- http://tinynav.com/
- located at themes/jquery/js/plugins.js
-
-- VaultPress
- https://vaultpress.com/
- located at plugins/vaultpress
-
-The design, layout, and look-and-feel of jquery-wp-content - including
-all CSS, images, and icons, except as noted above - are copyright jQuery
-Foundation 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.
-
-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
-web sites.
-
-====
-
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
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 516f6aae..9de076af 100644
--- a/README.md
+++ b/README.md
@@ -1,81 +1,22 @@
# jquery-wp-content
-`jquery-wp-content` is a **custom replacement** for the `wp-content` directory which contains the plugins, themes and site configuration to run the jQuery multi-site WordPress network.
+This repository provisions the `wp-content` directory of a WordPress installation, with the themes, plugins, and site options for jQuery Project websites.
-Although we recommend using the pre-built VM, if you would like to manually install `jquery-wp-content` you will find instructions for installing in the [INSTALL.md](INSTALL.md) file in this directory. We strongly recommend using the VM as it will provide the same environment as our production servers.
+## Getting started
-## Prerequisites
+### Production
-This setup guide assumes you have certain prerequisites installed.
+To learn how the sites are managed in production, refer to
+ .
-* [Virtualbox >=4.3+](https://www.virtualbox.org/)
-* [Vagrant >=1.4.0](https://www.vagrantup.com/)
+### Staging
-## Vagrant and Virtualbox
+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
-We recommend the combination of Virtualbox and [Vagrant](https://www.vagrantup.com/intro/index.html) for a local development environment. Vagrant simplifies download, installation, and management of the local environment VM with a few commands.
+## Local
-### Setup
-
-From the root of your `jquery-wp-content` clone, run the following command:
-
-```
-vagrant up
-```
-
-This will start the VM for you, the output should look similar to what you see below.
-
-```
-Bringing machine 'default' up with 'virtualbox' provider...
-[default] Box 'jquery-wp-content' was not found. Fetching box from specified URL for
-the provider 'virtualbox'. Note that if the URL does not have
-a box for this provider, you should interrupt Vagrant now and add
-the box yourself. Otherwise Vagrant will attempt to download the
-full box prior to discovering this error.
-Downloading box from URL: http://boxes.jquery.com/jquery-wp-content.box
-Calculating and comparing box checksum...ime remaining: 0:00:01)
-Extracting box...
-Successfully added box 'jquery-wp-content' with provider 'virtualbox'!
-[default] Importing base box 'jquery-wp-content'...
-[default] Matching MAC address for NAT networking...
-[default] Setting the name of the VM...
-[default] Clearing any previously set forwarded ports...
-[default] Clearing any previously set network interfaces...
-[default] Preparing network interfaces based on configuration...
-[default] Forwarding ports...
-[default] -- 22 => 2222 (adapter 1)
-[default] Running 'pre-boot' VM customizations...
-[default] Booting VM...
-[default] Waiting for machine to boot. This may take a few minutes...
-[default] Machine booted and ready!
-[default] Setting hostname...
-[default] Configuring and enabling network interfaces...
-[default] Mounting shared folders...
-[default] -- /vagrant
-[default] -- /var/www/wordpress/jquery-wp-content
-```
-
-Complete the installation process by pointing your browser at http://vagrant.jquery.com/. Feel free to use any username/password/email combination that you choose, though keep note of the username and password as you will need them to deploy to your local VM.
-
-You do not need to configure your `/etc/hosts` file for `vagrant.*` because `jquery.com`'s DNS handles this for you. However, if you plan to work offline, you can use the following rules:
-
-```
-172.27.72.27 vagrant.jquery.com vagrant.api.jquery.com vagrant.blog.jquery.com vagrant.books.jquery.com vagrant.codeorigin.jquery.com vagrant.learn.jquery.com vagrant.plugins.jquery.com
-172.27.72.27 vagrant.jqueryui.com vagrant.api.jqueryui.com vagrant.blog.jqueryui.com
-172.27.72.27 vagrant.jquerymobile.com vagrant.api.jquerymobile.com vagrant.blog.jquerymobile.com
-172.27.72.27 vagrant.jquery.org vagrant.brand.jquery.org vagrant.contribute.jquery.org vagrant.events.jquery.org vagrant.irc.jquery.org vagrant.meetings.jquery.org
-172.27.72.27 vagrant.qunitjs.com vagrant.api.qunitjs.com
-172.27.72.27 vagrant.sizzlejs.com
-```
-
-### Stopping and Restarting the Virtual Machine
-
-When you're not working on `jquery-wp-content` you'll probably want to run `vagrant halt` to turn off the VM to save yourself some system resources. Alternatively you can suspend the VM by using `vagrant suspend`. You can always start the VM by running `vagrant up`.
-
-### Clean up
-
-Should you need to recover some harddrive space you can safely run the `vagrant destroy` command from within your `jquery-wp-content` clone. This will delete the VM image from your hard drive. **You will not lose any work by doing this.**
-
-## Auto-Updates
-
-Changes pushed to master are automatically pulled onto the stage domain.
+To help preview or debug changes locally during development,
+you can use .
diff --git a/Vagrantfile b/Vagrantfile
deleted file mode 100644
index bbc3afa6..00000000
--- a/Vagrantfile
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-VAGRANTFILE_API_VERSION = "2"
-Vagrant.require_version ">= 1.4.0"
-
-Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
-
- # use the config key as the vm identifier
- config.vm.box = "jquery-wp-content"
- config.vm.box_download_checksum_type = "sha256"
- config.vm.box_download_checksum = "3182bc50668e86022e7d50bc8c096774b49de40cfaffc77f4fad75ca6cf83d3d"
-
- config.vm.box_url = "http://boxes.jquery.com/jquery-wp-content.box"
-
- config.vm.synced_folder "./", "/var/www/wordpress/jquery-wp-content"
-
- # assign an ip address in the hosts network
- config.vm.network "private_network", ip: "172.27.72.27"
-
- # set the hostname of the vm so puppet site.pp will react
- # with the right node config
- # config.vm.provision :shell, :inline => "hostname vagrant.jquery.com"
- config.vm.hostname = "vagrant.jquery.com"
-
- config.vm.provider "virtualbox" do |v|
- # make sure that the name makes sense when seen in the vbox GUI
- v.name = "jQuery Sites"
-
- # Be nice to our users.
- v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
- end
-end
diff --git a/blogs.dir/.gitignore b/blogs.dir/.gitignore
deleted file mode 100644
index 72e8ffc0..00000000
--- a/blogs.dir/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*
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 c3d0ed3b..00000000
--- a/config.php
+++ /dev/null
@@ -1,105 +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 );
-
- delete_site_option( 'site_admins' );
- add_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 d38d5336..809d1240 100644
--- a/mu-plugins/_loader.php
+++ b/mu-plugins/_loader.php
@@ -1,18 +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 WPMU_PLUGIN_DIR . '/relevanssi/relevanssi.php';
-require 'disable-emojis/disable-emojis.php';
+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/disable-emojis/readme.txt b/mu-plugins/disable-emojis/readme.txt
deleted file mode 100755
index 5d3752b0..00000000
--- a/mu-plugins/disable-emojis/readme.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-=== Disable Emojis ===
-Contributors: ryanhellyer
-Tags: emojis
-Donate link: https://geek.hellyer.kiwi/donate/
-Requires at least: 4.2
-Tested up to: 4.7
-Stable tag: 1.5.2
-
-
-This plugin disables the new WordPress emoji functionality.
-
-
-== Description ==
-
-This plugin disables the new WordPress emoji functionality.
-
-
-Note: Emoticons will still work and emoji's 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 emoji's in older browswers.
-
-
-== 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.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/mu-plugins/events.jquery.org/posts.php b/mu-plugins/events.jquery.org/posts.php
deleted file mode 100644
index c3129970..00000000
--- a/mu-plugins/events.jquery.org/posts.php
+++ /dev/null
@@ -1,15 +0,0 @@
-post_name;
- unset( $query_vars[ 'year' ] );
- }
- }
-
- return $query_vars;
-});
diff --git a/mu-plugins/jquery-actions.php b/mu-plugins/jquery-actions.php
deleted file mode 100644
index de1dd2ea..00000000
--- a/mu-plugins/jquery-actions.php
+++ /dev/null
@@ -1,44 +0,0 @@
- and header.
-remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 );
-remove_action( 'template_redirect', 'wp_shortlink_header', 11 );
-
-add_action( 'init', function() {
- global $events;
-
- $events = array(
- 'future' => array(),
- 'past' => array(),
- 'year' => array(),
- );
-
- $eventsFile = gw_resources_dir(
- (JQUERY_STAGING ? JQUERY_STAGING_PREFIX : '') . 'events.jquery.org'
- ) . '/events.json';
- $allEvents = file_exists( $eventsFile ) ?
- json_decode( file_get_contents( $eventsFile ) ) :
- array();
-
- $now = time();
- foreach ( $allEvents as $event ) {
- $event->end = strtotime( $event-> end );
- $year = Date('Y', $event->end);
-
- $events[ 'year' ][ $year ][] = $event;
- if ( $event->end > $now ) {
- $events[ 'future' ][] = $event;
- } else {
- $events[ 'past' ][ $year ][] = $event;
- }
- }
-
- $events[ 'past' ] = array_reverse( $events[ 'past' ], true );
-});
diff --git a/mu-plugins/jquery-filters.php b/mu-plugins/jquery-filters.php
deleted file mode 100644
index 936d9bb7..00000000
--- a/mu-plugins/jquery-filters.php
+++ /dev/null
@@ -1,122 +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;
-});
-
-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;
-});
-
-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 );
-
-// Strip protocol from urls making them protocol agnostic.
-add_filter( 'theme_root_uri', 'strip_https', 10, 1 );
-add_filter( 'clean_url', 'strip_https', 11, 1 );
-function strip_https($url) {
- // WordPress core updates need a protocol.
- if ( 'downloads.wordpress.org' === parse_url( $url, PHP_URL_HOST ) ) {
- return $url;
- }
-
- return preg_replace( '/^https?:/', '', $url );
-}
diff --git a/mu-plugins/jquery.com/jquery-filters.php b/mu-plugins/jquery.com/jquery-filters.php
deleted file mode 100644
index f410da81..00000000
--- a/mu-plugins/jquery.com/jquery-filters.php
+++ /dev/null
@@ -1,35 +0,0 @@
-');
- if ( $memberPos === false ) {
- return $content;
- }
-
- $members = json_decode( file_get_contents( GW_RESOURCE_DIR . '/corporate-members.json' ), true );
- shuffle( $members );
-
- $memberContent = '
';
- foreach( $members as $index => $member ) {
-
- // Only show four members at a time
- if ( $index >= 4 ) {
- break;
- }
-
- $logoUrl = "//jquery.org/resources/members/" .
- preg_replace( '/[^a-z0-9]/', '', strtolower( $member[ 'name' ] ) ) . ".png";
- $memberContent .=
- '' .
- '' .
- ' ' .
- ' ' .
- ' ' .
- ' ';
- }
- $memberContent .= ' ';
-
- return str_replace( '', $memberContent, $content );
-} );
-
-?>
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 5441cd2c..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/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/relevanssi-install.php b/mu-plugins/relevanssi-install.php
deleted file mode 100644
index 3e7f46f9..00000000
--- a/mu-plugins/relevanssi-install.php
+++ /dev/null
@@ -1,22 +0,0 @@
-query("DELETE FROM " . $relevanssi_variables['relevanssi_excerpt_cache'] . " WHERE post = $post");
-}
-
-function relevanssi_fetch_excerpt($post, $query) {
- global $wpdb, $relevanssi_variables;
-
- $query = mysql_real_escape_string($query);
- $excerpt = $wpdb->get_var("SELECT excerpt FROM " . $relevanssi_variables['relevanssi_excerpt_cache'] . " WHERE post = $post AND query = '$query'");
-
- if (!$excerpt) return null;
-
- return $excerpt;
-}
-
-function relevanssi_store_excerpt($post, $query, $excerpt) {
- global $wpdb, $relevanssi_variables;
-
- $query = mysql_real_escape_string($query);
- $excerpt = mysql_real_escape_string($excerpt);
-
- $wpdb->query("INSERT INTO " . $relevanssi_variables['relevanssi_excerpt_cache'] . " (post, query, excerpt)
- VALUES ($post, '$query', '$excerpt')
- ON DUPLICATE KEY UPDATE excerpt = '$excerpt'");
-}
-
-function relevanssi_fetch_hits($param) {
- global $wpdb, $relevanssi_variables;
-
- $time = get_option('relevanssi_cache_seconds', 172800);
-
- $hits = $wpdb->get_var("SELECT hits FROM " . $relevanssi_variables['relevanssi_cache'] . " WHERE param = '$param' AND UNIX_TIMESTAMP() - UNIX_TIMESTAMP(tstamp) < $time");
-
- if ($hits) {
- return unserialize($hits);
- }
- else {
- return null;
- }
-}
-
-function relevanssi_store_hits($param, $data) {
- global $wpdb, $relevanssi_variables;
-
- $param = mysql_real_escape_string($param);
- $data = mysql_real_escape_string($data);
- $wpdb->query("INSERT INTO " . $relevanssi_variables['relevanssi_cache'] . " (param, hits)
- VALUES ('$param', '$data')
- ON DUPLICATE KEY UPDATE hits = '$data'");
-}
-
-function relevanssi_truncate_cache($all = false) {
- global $wpdb, $relevanssi_variables;
- $relevanssi_excerpt_cache = $relevanssi_variables['relevanssi_excerpt_cache'];
- $relevanssi_cache = $relevanssi_variables['relevanssi_cache'];
-
- if ($all) {
- $query = "TRUNCATE TABLE $relevanssi_excerpt_cache";
- $wpdb->query($query);
-
- $query = "TRUNCATE TABLE $relevanssi_cache";
- }
- else {
- $time = get_option('relevanssi_cache_seconds', 172800);
- $query = "DELETE FROM $relevanssi_cache
- WHERE UNIX_TIMESTAMP() - UNIX_TIMESTAMP(tstamp) > $time";
- // purge all expired cache data
- }
- $wpdb->query($query);
-}
-
-
-?>
diff --git a/mu-plugins/relevanssi/lib/common.php b/mu-plugins/relevanssi/lib/common.php
deleted file mode 100644
index 2649fbd8..00000000
--- a/mu-plugins/relevanssi/lib/common.php
+++ /dev/null
@@ -1,701 +0,0 @@
-blog_id)) {
- switch_to_blog($hit->blog_id);
- }
- global $sitepress;
-
- if (function_exists('icl_object_id') && !function_exists('pll_is_translated_post_type')) {
- if ($sitepress->is_translated_post_type($hit->post_type)) {
- if ($hit->ID == icl_object_id($hit->ID, $hit->post_type, false, ICL_LANGUAGE_CODE)) $filtered_hits[] = $hit;
- }
- else {
- $filtered_hits[] = $hit;
- }
- }
- elseif (function_exists('icl_object_id') && function_exists('pll_is_translated_post_type')) {
- if (pll_is_translated_post_type($hit->post_type)) {
- global $polylang;
- if ($polylang->model->get_post_language($hit->ID)->slug == ICL_LANGUAGE_CODE) {
- $filtered_hits[] = $hit;
- }
- else if ($hit->ID == icl_object_id($hit->ID, $hit->post_type, false, ICL_LANGUAGE_CODE)) {
- $filtered_hits[] = $hit;
- }
- }
- else {
- $filtered_hits[] = $hit;
- }
- }
-
- // if there is no WPML but the target blog has identical language with current blog,
- // we use the hits. Note en-US is not identical to en-GB!
- elseif (get_bloginfo('language') == $lang) {
- $filtered_hits[] = $hit;
- }
- if (isset($hit->blog_id)) {
- restore_current_blog();
- }
- }
- return array($filtered_hits, $data[1]);
- }
- return $data;
-}
-
-/**
- * Function by Matthew Hood http://my.php.net/manual/en/function.sort.php#75036
- */
-function relevanssi_object_sort(&$data, $key, $dir = 'desc') {
- if ('title' == $key) $key = 'post_title';
- if ('date' == $key) $key = 'post_date';
- if (!isset($data[0]->$key)) return; // trying to sort by a non-existent key
- $dir = strtolower($dir);
- for ($i = count($data) - 1; $i >= 0; $i--) {
- $swapped = false;
- for ($j = 0; $j < $i; $j++) {
- if (function_exists('mb_strtolower')) {
- $key1 = mb_strtolower($data[$j]->$key);
- $key2 = mb_strtolower($data[$j + 1]->$key);
- }
- else {
- $key1 = strtolower($data[$j]->$key);
- $key2 = strtolower($data[$j + 1]->$key);
- }
- if ('asc' == $dir) {
- if ($key1 > $key2) {
- $tmp = $data[$j];
- $data[$j] = $data[$j + 1];
- $data[$j + 1] = $tmp;
- $swapped = true;
- }
- }
- else {
- if ($key1 < $key2) {
- $tmp = $data[$j];
- $data[$j] = $data[$j + 1];
- $data[$j + 1] = $tmp;
- $swapped = true;
- }
- }
- }
- if (!$swapped) return;
- }
-}
-
-function relevanssi_show_matches($data, $hit) {
- isset($data['body_matches'][$hit]) ? $body = $data['body_matches'][$hit] : $body = "";
- isset($data['title_matches'][$hit]) ? $title = $data['title_matches'][$hit] : $title = "";
- isset($data['tag_matches'][$hit]) ? $tag = $data['tag_matches'][$hit] : $tag = "";
- isset($data['comment_matches'][$hit]) ? $comment = $data['comment_matches'][$hit] : $comment = "";
- isset($data['scores'][$hit]) ? $score = round($data['scores'][$hit], 2) : $score = 0;
- isset($data['term_hits'][$hit]) ? $term_hits_a = $data['term_hits'][$hit] : $term_hits_a = array();
- arsort($term_hits_a);
- $term_hits = "";
- $total_hits = 0;
- foreach ($term_hits_a as $term => $hits) {
- $term_hits .= " $term: $hits";
- $total_hits += $hits;
- }
-
- $text = get_option('relevanssi_show_matches_text');
- $replace_these = array("%body%", "%title%", "%tags%", "%comments%", "%score%", "%terms%", "%total%");
- $replacements = array($body, $title, $tag, $comment, $score, $term_hits, $total_hits);
-
- $result = " " . str_replace($replace_these, $replacements, $text);
-
- return apply_filters('relevanssi_show_matches', $result);
-}
-
-function relevanssi_update_log($query, $hits) {
- if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == "Mediapartners-Google")
- return;
-
- global $wpdb, $relevanssi_variables;
-
- $user = wp_get_current_user();
- if ($user->ID != 0 && get_option('relevanssi_omit_from_logs')) {
- $omit = explode(",", get_option('relevanssi_omit_from_logs'));
- if (in_array($user->ID, $omit)) return;
- if (in_array($user->user_login, $omit)) return;
- }
-
- // Bot filter, by Justin_K
- // See: http://wordpress.org/support/topic/bot-logging-problem-w-tested-solution
- if (isset($_SERVER['HTTP_USER_AGENT'])) {
- $user_agent = $_SERVER['HTTP_USER_AGENT'];
- $bots = array('Google'=>'Mediapartners-Google');
- $bots = apply_filters('relevanssi_bots_to_not_log', $bots);
- foreach ($bots as $name => $lookfor) {
- if (stristr($user_agent, $lookfor) !== false) return;
- }
- }
-
- get_option('relevanssi_log_queries_with_ip') == "on" ? $ip = $_SERVER['REMOTE_ADDR'] : $ip = '';
- $q = $wpdb->prepare("INSERT INTO " . $relevanssi_variables['log_table'] . " (query, hits, user_id, ip, time) VALUES (%s, %d, %d, %s, NOW())", $query, intval($hits), $user->ID, $ip);
- $wpdb->query($q);
-}
-
-/**
- * Do note that while this function takes $post_ok as a parameter, it actually doesn't care much
- * about the previous value, and will instead overwrite it. If you want to make sure your value
- * is preserved, either disable this default function, or run your function on a later priority
- * (this defaults to 10).
- */
-function relevanssi_default_post_ok($post_ok, $doc) {
- $status = relevanssi_get_post_status($doc);
-
- // if it's not public, don't show
- if ('publish' != $status) {
- $post_ok = false;
- }
-
- // ...unless
-
- if ('private' == $status) {
- $post_ok = false;
-
- if (function_exists('awp_user_can')) {
- // Role-Scoper, though Role-Scoper actually uses a different function to do this
- // So whatever is in here doesn't actually run.
- $current_user = wp_get_current_user();
- $post_ok = awp_user_can('read_post', $doc, $current_user->ID);
- }
- else {
- // Basic WordPress version
- $type = relevanssi_get_post_type($doc);
- $cap = 'read_private_' . $type . 's';
- $cap = apply_filters('relevanssi_private_cap', $cap);
- if (current_user_can($cap)) {
- $post_ok = true;
- }
- }
- }
-
- // only show drafts, pending and future posts in admin search
- if (in_array($status, array('draft', 'pending', 'future')) && is_admin()) {
- $post_ok = true;
- }
-
- if (relevanssi_s2member_level($doc) == 0) $post_ok = false; // not ok with s2member
-
- return $post_ok;
-}
-
-/**
- * Return values:
- * 2: full access to post
- * 1: show title only
- * 0: no access to post
- * -1: s2member not active
- */
-function relevanssi_s2member_level($doc) {
- $return = -1;
- if (function_exists('is_permitted_by_s2member')) {
- // s2member
- $alt_view_protect = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["filter_wp_query"];
-
- if (version_compare (WS_PLUGIN__S2MEMBER_VERSION, "110912", ">="))
- $completely_hide_protected_search_results = (in_array ("all", $alt_view_protect) || in_array ("searches", $alt_view_protect)) ? true : false;
- else /* Backward compatibility with versions of s2Member, prior to v110912. */
- $completely_hide_protected_search_results = (strpos ($alt_view_protect, "all") !== false || strpos ($alt_view_protect, "searches") !== false) ? true : false;
-
- if (is_permitted_by_s2member($doc)) {
- // Show title and excerpt, even full content if you like.
- $return = 2;
- }
- else if (!is_permitted_by_s2member($doc) && $completely_hide_protected_search_results === false) {
- // Show title and excerpt. Alt View Protection is NOT enabled for search results. However, do NOT show full content body.
- $return = 1;
- }
- else {
- // Hide this search result completely.
- $return = 0;
- }
- }
-
- return $return;
-}
-
-function relevanssi_populate_array($matches) {
- global $relevanssi_post_array, $relevanssi_post_types, $wpdb;
- if (function_exists('wp_suspend_cache_addition'))
- wp_suspend_cache_addition(true);
-
- $ids = array();
- foreach ($matches as $match) {
- array_push($ids, $match->doc);
- }
-
- $ids = implode(',', $ids);
- $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE id IN ($ids)");
- foreach ($posts as $post) {
- $relevanssi_post_array[$post->ID] = $post;
- $relevanssi_post_types[$post->ID] = $post->post_type;
- }
-
- if (function_exists('wp_suspend_cache_addition'))
- wp_suspend_cache_addition(false);
-}
-
-function relevanssi_get_term_taxonomy($id) {
- global $wpdb;
- $taxonomy = $wpdb->get_var("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = $id");
- return $taxonomy;
-}
-
-/**
- * Extracts phrases from search query
- * Returns an array of phrases
- */
-function relevanssi_extract_phrases($q) {
- if ( function_exists( 'mb_strpos' ) )
- $pos = mb_strpos($q, '"');
- else
- $pos = strpos($q, '"');
-
- $phrases = array();
- while ($pos !== false) {
- $start = $pos;
- if ( function_exists( 'mb_strpos' ) )
- $end = mb_strpos($q, '"', $start + 1);
- else
- $end = strpos($q, '"', $start + 1);
-
- if ($end === false) {
- // just one " in the query
- $pos = $end;
- continue;
- }
- if ( function_exists( 'mb_substr' ) )
- $phrase = mb_substr($q, $start + 1, $end - $start - 1);
- else
- $phrase = substr($q, $start + 1, $end - $start - 1);
-
- $phrase = trim($phrase);
-
- if (!empty($phrase)) $phrases[] = $phrase;
- $pos = $end;
- }
- return $phrases;
-}
-
-/* If no phrase hits are made, this function returns an empty string
- * If phrase matches are found, the function returns MySQL queries
- */
-function relevanssi_recognize_phrases($q) {
- global $wpdb;
-
- $phrases = relevanssi_extract_phrases($q);
-
- $all_queries = array();
- if (count($phrases) > 0) {
- foreach ($phrases as $phrase) {
- $queries = array();
- $phrase = esc_sql($phrase);
- "on" == get_option("relevanssi_index_excerpt") ? $excerpt = " OR post_excerpt LIKE '%$phrase%'" : $excerpt = "";
- $query = "(SELECT ID FROM $wpdb->posts
- WHERE (post_content LIKE '%$phrase%' OR post_title LIKE '%$phrase%' $excerpt)
- AND post_status IN ('publish', 'draft', 'private', 'pending', 'future', 'inherit'))";
-
- $queries[] = $query;
-
- $query = "(SELECT ID FROM $wpdb->posts as p, $wpdb->term_relationships as r, $wpdb->term_taxonomy as s, $wpdb->terms as t
- WHERE r.term_taxonomy_id = s.term_taxonomy_id AND s.term_id = t.term_id AND p.ID = r.object_id
- AND t.name LIKE '%$phrase%' AND p.post_status IN ('publish', 'draft', 'private', 'pending', 'future', 'inherit'))";
-
- $queries[] = $query;
-
- $query = "(SELECT ID
- FROM $wpdb->posts AS p, $wpdb->postmeta AS m
- WHERE p.ID = m.post_id
- AND m.meta_value LIKE '%$phrase%'
- AND p.post_status IN ('publish', 'draft', 'private', 'pending', 'future', 'inherit'))";
-
- $queries[] = $query;
-
- $queries = implode(' OR relevanssi.doc IN ', $queries);
- $queries = "AND (relevanssi.doc IN $queries)";
- $all_queries[] = $queries;
- }
- }
- else {
- $phrases = "";
- }
-
- $all_queries = implode(" ", $all_queries);
-
- return $all_queries;
-}
-
-// found here: http://forums.digitalpoint.com/showthread.php?t=1106745
-function relevanssi_strip_invisibles($text) {
- $text = preg_replace(
- array(
- '@@siu',
- '@@siu',
- '@]*?.*? @siu',
- '@]*?.*? @siu',
- '@]*?.*? @siu',
- '@]*?.*? @siu',
- '@]*?.*? @siu',
- '@@siu',
- '@]*?.*?@siu',
- ),
- ' ',
- $text );
- return $text;
-}
-
-function relevanssi_strlen_sort($a, $b) {
- return strlen($b) - strlen($a);
-}
-
-function relevanssi_get_custom_fields() {
- $custom_fields = get_option("relevanssi_index_fields");
- if ($custom_fields) {
- if ($custom_fields == 'all') {
- return $custom_fields;
- }
- else if ($custom_fields == 'visible') {
- return $custom_fields;
- }
- else {
- $custom_fields = explode(",", $custom_fields);
- for ($i = 0; $i < count($custom_fields); $i++) {
- $custom_fields[$i] = trim($custom_fields[$i]);
- }
- }
- }
- else {
- $custom_fields = false;
- }
- return $custom_fields;
-}
-
-function relevanssi_mb_trim($string) {
- $string = str_replace(chr(194) . chr(160), '', $string);
- $string = preg_replace( "/(^\s+)|(\s+$)/us", "", $string );
- return $string;
-}
-
-function relevanssi_remove_punct($a) {
- $a = strip_tags($a);
- $a = stripslashes($a);
-
- $a = str_replace('ß', 'ss', $a);
-
- $a = str_replace("·", '', $a);
- $a = str_replace("…", '', $a);
- $a = str_replace("€", '', $a);
- $a = str_replace("", '', $a);
-
- $a = str_replace(chr(194) . chr(160), ' ', $a);
- $a = str_replace(" ", ' ', $a);
- $a = str_replace('’', ' ', $a);
- $a = str_replace("'", ' ', $a);
- $a = str_replace("’", ' ', $a);
- $a = str_replace("‘", ' ', $a);
- $a = str_replace("”", ' ', $a);
- $a = str_replace("“", ' ', $a);
- $a = str_replace("„", ' ', $a);
- $a = str_replace("´", ' ', $a);
- $a = str_replace("—", ' ', $a);
- $a = str_replace("–", ' ', $a);
- $a = str_replace("×", ' ', $a);
- $a = preg_replace('/[[:punct:]]+/u', ' ', $a);
-
- $a = preg_replace('/[[:space:]]+/', ' ', $a);
- $a = trim($a);
-
- return $a;
-}
-
-
-/**
- * This function will prevent the default search from running, when Relevanssi is
- * active.
- * Thanks to John Blackbourne.
- */
-function relevanssi_prevent_default_request( $request, $query ) {
- if ($query->is_search) {
- global $wpdb;
- if (isset($query->query_vars['post_type']) && isset($query->query_vars['post_status'])) {
- if ($query->query_vars['post_type'] == 'attachment' && $query->query_vars['post_status'] == 'inherit,private') {
- // this is a media library search; do not meddle
- return $request;
- }
- }
- $bbpress = false;
- if ($query->query_vars['post_type'] == 'topic' || $query->query_vars['post_type'] == 'reply') $bbpress = true;
- if (is_array($query->query_vars['post_type'])) {
- if (in_array('topic', $query->query_vars['post_type'])) $bbpress = true;
- if (in_array('reply', $query->query_vars['post_type'])) $bbpress = true;
- }
- if ($bbpress) {
- // this is a BBPress search; do not meddle
- return $request;
- }
- $admin_search_ok = true;
- $admin_search_ok = apply_filters('relevanssi_admin_search_ok', $admin_search_ok, $query );
-
- $prevent = true;
- $prevent = apply_filters('relevanssi_prevent_default_request', $prevent, $query );
-
- if (!is_admin() && $prevent )
- $request = "SELECT * FROM $wpdb->posts WHERE 1=2";
- else if ('on' == get_option('relevanssi_admin_search') && $admin_search_ok )
- $request = "SELECT * FROM $wpdb->posts WHERE 1=2";
- }
- return $request;
-}
-
-function relevanssi_tokenize($str, $remove_stops = true, $min_word_length = -1) {
- $tokens = array();
- if (is_array($str)) {
- foreach ($str as $part) {
- $tokens = array_merge($tokens, relevanssi_tokenize($part, $remove_stops, $min_word_length));
- }
- }
- if (is_array($str)) return $tokens;
-
- if ( function_exists('mb_internal_encoding') )
- mb_internal_encoding("UTF-8");
-
- if ($remove_stops) {
- $stopword_list = relevanssi_fetch_stopwords();
- }
-
- if (function_exists('relevanssi_thousandsep')) {
- $str = relevanssi_thousandsep($str);
- }
-
- $str = apply_filters('relevanssi_remove_punctuation', $str);
-
- if ( function_exists('mb_strtolower') )
- $str = mb_strtolower($str);
- else
- $str = strtolower($str);
-
- $t = strtok($str, "\n\t ");
- while ($t !== false) {
- $t = strval($t);
- $accept = true;
- if (strlen($t) < $min_word_length) {
- $t = strtok("\n\t ");
- continue;
- }
- if ($remove_stops == false) {
- $accept = true;
- }
- else {
- if (count($stopword_list) > 0) { //added by OdditY -> got warning when stopwords table was empty
- if (in_array($t, $stopword_list)) {
- $accept = false;
- }
- }
- }
-
- if (RELEVANSSI_PREMIUM) {
- $t = apply_filters('relevanssi_premium_tokenizer', $t);
- }
-
- if ($accept) {
- $t = relevanssi_mb_trim($t);
- if (is_numeric($t)) $t = " $t"; // $t ends up as an array index, and numbers just don't work there
- if (!isset($tokens[$t])) {
- $tokens[$t] = 1;
- }
- else {
- $tokens[$t]++;
- }
- }
-
- $t = strtok("\n\t ");
- }
- return $tokens;
-}
-
-function relevanssi_get_post_status($id) {
- global $relevanssi_post_array;
-
- $type = substr($id, 0, 2);
- if ($type == '**') {
- return 'publish';
- }
- if ($type == 'u_') {
- return 'publish';
- }
-
- if (isset($relevanssi_post_array[$id])) {
- $status = $relevanssi_post_array[$id]->post_status;
- if ('inherit' == $status) {
- $parent = $relevanssi_post_array[$id]->post_parent;
- $status = relevanssi_get_post_status($parent);
- if ($status == false) {
- // attachment without a parent
- // let's assume it's public
- $status = 'publish';
- }
- }
- return $status;
- }
- else {
- return get_post_status($id);
- }
-}
-
-function relevanssi_get_post_type($id) {
- global $relevanssi_post_array;
-
- if (isset($relevanssi_post_array[$id])) {
- return $relevanssi_post_array[$id]->post_type;
- }
- else {
- return get_post_type($id);
- }
-}
-
-function relevanssi_the_tags($sep = ', ', $echo = true) {
- $tags = relevanssi_highlight_terms(get_the_tag_list('', $sep), get_search_query());
- if ($echo) {
- echo $tags;
- }
- else {
- return $tags;
- }
-}
-
-function relevanssi_get_the_tags($sep = ', ') {
- return relevanssi_the_tags($sep, false);
-}
-
-function relevanssi_get_term_tax_id($field, $id, $taxonomy) {
- global $wpdb;
- return $wpdb->get_var(
- "SELECT term_taxonomy_id
- FROM $wpdb->term_taxonomy
- WHERE term_id = $id AND taxonomy = '$taxonomy'");
-}
-
-/**
- * Takes in a search query, returns it with synonyms added.
- */
-function relevanssi_add_synonyms($q) {
- if (empty($q)) return $q;
-
- $synonym_data = get_option('relevanssi_synonyms');
- if ($synonym_data) {
- $synonyms = array();
- if (function_exists('mb_strtolower')) {
- $synonym_data = mb_strtolower($synonym_data);
- }
- else {
- $synonym_data = strtolower($synonym_data);
- }
- $pairs = explode(";", $synonym_data);
- foreach ($pairs as $pair) {
- $parts = explode("=", $pair);
- $key = strval(trim($parts[0]));
- $value = trim($parts[1]);
- $synonyms[$key][$value] = true;
- }
- if (count($synonyms) > 0) {
- $new_terms = array();
- $terms = array_keys(relevanssi_tokenize($q, false)); // remove stopwords is false here
- if (!in_array($q, $terms)) $terms[] = $q;
-
- foreach ($terms as $term) {
- if (in_array(strval($term), array_keys($synonyms))) { // strval, otherwise numbers cause problems
- if (isset($synonyms[strval($term)])) { // necessary, otherwise terms like "02" can cause problems
- $new_terms = array_merge($new_terms, array_keys($synonyms[strval($term)]));
- }
- }
- }
- if (count($new_terms) > 0) {
- foreach ($new_terms as $new_term) {
- $q .= " $new_term";
- }
- }
- }
- }
- return $q;
-}
-
-/* Helper function that does mb_stripos, falls back to mb_strpos and mb_strtoupper
- * if that cannot be found, and falls back to just strpos if even that is not possible.
- */
-function relevanssi_stripos($content, $term, $offset) {
- if (function_exists('mb_strlen')) {
- if ($offset > mb_strlen($content)) return false;
- }
- else {
- if ($offset > strlen($content)) return false;
- }
- if (function_exists('mb_stripos')) {
- $pos = ("" == $content) ? false : mb_stripos($content, $term, $offset);
- }
- else if (function_exists('mb_strpos') && function_exists('mb_strtoupper') && function_exists('mb_substr')) {
- $pos = mb_strpos(mb_strtoupper($content), mb_strtoupper($term), $offset);
- }
- else {
- $pos = strpos(strtoupper($content), strtoupper($term), $offset);
- }
- return $pos;
-}
-
-/* Function to close tags in a bit of HTML code. Used to make sure no tags are left open
- * in excerpts. This method is not foolproof, but it's good enough for now.
- */
-function relevanssi_close_tags($html) {
- preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?(?#iU', $html, $result);
- $openedtags = $result[1];
- preg_match_all('#([a-z]+)>#iU', $html, $result);
- $closedtags = $result[1];
- $len_opened = count($openedtags);
- if (count($closedtags) == $len_opened) {
- return $html;
- }
- $openedtags = array_reverse($openedtags);
- for ($i=0; $i < $len_opened; $i++) {
- if (!in_array($openedtags[$i], $closedtags)) {
- $html .= ''.$openedtags[$i].'>';
- } else {
- unset($closedtags[array_search($openedtags[$i], $closedtags)]);
- }
- }
- return $html;
-}
-
-/* Prints out post title with highlighting.
- */
-function relevanssi_the_title() {
- global $post;
- if (empty($post->post_highlighted_title)) $post->post_highlighted_title = $post->post_title;
- echo $post->post_highlighted_title;
-}
-
-/* Returns the post title with highlighting.
- */
-function relevanssi_get_the_title($post_id) {
- $post = get_post($post_id);
- if (empty($post->post_highlighted_title)) $post->post_highlighted_title = $post->post_title;
- return $post->post_highlighted_title;
-}
-
-function relevanssi_update_doc_count( $values, $post ) {
- $D = get_option( 'relevanssi_doc_count');
- $count = count($values);
- if ($values && $count > 0) {
- update_option( 'relevanssi_doc_count', $D + $count);
- }
- return $values;
-}
-?>
diff --git a/mu-plugins/relevanssi/lib/excerpts-highlights.php b/mu-plugins/relevanssi/lib/excerpts-highlights.php
deleted file mode 100644
index fd9b11b3..00000000
--- a/mu-plugins/relevanssi/lib/excerpts-highlights.php
+++ /dev/null
@@ -1,490 +0,0 @@
-" . $post->post_excerpt . "";
- }
- else {
- echo __('There is no excerpt because this is a protected post.');
- }
-}
-
-function relevanssi_do_excerpt($t_post, $query) {
- global $post;
- $old_global_post = NULL;
- if ($post != NULL) $old_global_post = $post;
- $post = $t_post;
-
- $remove_stopwords = false;
- $terms = relevanssi_tokenize($query, $remove_stopwords, -1);
-
- // These shortcodes cause problems with Relevanssi excerpts
- remove_shortcode('layerslider');
-
- $content = apply_filters('relevanssi_pre_excerpt_content', $post->post_content, $post, $query);
- $content = apply_filters('the_content', $content);
- $content = apply_filters('relevanssi_excerpt_content', $content, $post, $query);
-
- $content = relevanssi_strip_invisibles($content); // removes
+ ";
+ }
+
+ /**
+ * 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 "";
+ }
+
+ 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 .= "" . esc_html( $arr[6] ) . " ";
+ }
+
+ 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/mu-plugins/redirects.php b/plugins/redirects.php
similarity index 65%
rename from mu-plugins/redirects.php
rename to plugins/redirects.php
index dc9f7175..d637ddff 100644
--- a/mu-plugins/redirects.php
+++ b/plugins/redirects.php
@@ -4,20 +4,18 @@
* Description: Adds custom XML-RPC methods to control redirection.
*/
-$jquery_redirects = 'jquery_redirects';
-
add_filter( 'template_redirect', function() {
- global $jquery_redirects;
-
- // Only handle 404 Not Found
- if ( !is_404() ) {
+ if ( is_404() ) {
+ $url = trailingslashit( $_SERVER[ 'REQUEST_URI' ] );
+ } elseif ( is_front_page() ) {
+ $url = "/";
+ } else {
+ // Don't influence any other pages
return;
}
- $url = trailingslashit( $_SERVER[ 'REQUEST_URI' ] );
-
- // Check for redirects stored in the transients
- $transient = get_option( $jquery_redirects );
+ // Check for redirects stored in the database
+ $transient = get_option( 'jquery_redirects' );
if ( $transient && !empty( $transient[ $url ] ) ) {
wp_redirect( $transient[ $url ], 301 );
@@ -31,7 +29,6 @@
function jq_set_redirects( $args ) {
global $wp_xmlrpc_server;
- global $jquery_redirects;
// Authenticate
$username = $args[ 1 ];
@@ -42,5 +39,5 @@ function jq_set_redirects( $args ) {
}
// Store redirects
- return update_option( $jquery_redirects, json_decode( $args[ 3 ], true ) );
+ 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 8938954f..00000000
--- a/plugins/vaultpress/class.vaultpress-database.php
+++ /dev/null
@@ -1,338 +0,0 @@
-table=$table;
- if ( $parse_create_table ) {
- $this->structure = $this->parse_create_table( $this->show_create() );
- }
- }
-
- 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() );
- if ( !empty( $this->structure ) ) {
- $hash = md5( $this->convert_to_sql_string( $row, $this->structure->columns ) );
- foreach ( get_object_vars( $row ) as $i => $v ) {
- if ( !in_array( $i, $columns ) )
- unset( $row->$i );
- }
-
- $row->hash = $hash;
- } else {
- $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;
- }
-
- /**
- * Convert a PHP object to a mysqldump compatible string, using the provided data type information.
- **/
- function convert_to_sql_string( $data, $datatypes ) {
- global $wpdb;
- if ( !is_object( $data ) || !is_object( $datatypes ) )
- return false;
-
- foreach ( array_keys( (array)$data ) as $key )
- $keys[] = sprintf( "`%s`", $wpdb->escape( $key ) );
- foreach ( (array)$data as $key => $val ) {
- if ( null === $val ) {
- $vals[] = 'NULL';
- continue;
- }
- $type = 'text';
- if ( isset( $datatypes->$key->type ) )
- $type= strtolower( $datatypes->$key->type );
- if ( preg_match( '/int|double|float|decimal|bool/i', $type ) )
- $type = 'number';
-
- if ( 'number' === $type ) {
- // do not add quotes to numeric types.
- $vals[] = $val;
- } else {
- $val = $wpdb->escape( $val );
- // Escape characters that aren't escaped by $wpdb->escape(): \n, \r, etc.
- $val = str_replace( array( "\x0a", "\x0d", "\x1a" ), array( '\n', '\r', '\Z' ), $val );
- $vals[] = sprintf( "'%s'", $val );
- }
- }
- if ( !count($keys) )
- return false;
- // format the row as a mysqldump line: (`column1`, `column2`) VALUES (numeric_value1,'text value 2')
- return sprintf( "(%s) VALUES (%s)", implode( ', ',$keys ), implode( ',',$vals ) );
- }
-
-
-
- function parse_create_table( $sql ) {
- $table = new stdClass();
-
- $table->raw = $sql;
- $table->columns = new stdClass();
- $table->primary = null;
- $table->uniques = new stdClass();
- $table->keys = new stdClass();
- $sql = explode( "\n", trim( $sql ) );
- $table->engine = preg_replace( '/^.+ ENGINE=(\S+) .+$/i', "$1", $sql[(count($sql)-1)] );
- $table->charset = preg_replace( '/^.+ DEFAULT CHARSET=(\S+)( .+)?$/i', "$1", $sql[(count($sql)-1)] );
- $table->single_int_paging_column = null;
-
- foreach ( $sql as $idx => $val )
- $sql[$idx] = trim($val);
- $columns = preg_grep( '/^\s*`[^`]+`\s*\S*/', $sql );
- if ( !$columns )
- return false;
-
- $table->name = preg_replace( '/(^[^`]+`|`[^`]+$)/', '', array_shift( preg_grep( '/^CREATE\s+TABLE\s+/', $sql ) ) );
-
- foreach ( $columns as $line ) {
- preg_match( '/^`([^`]+)`\s+([a-z]+)(\(\d+\))?\s*/', $line, $m );
- $name = $m[1];
- $table->columns->$name = new stdClass();
- $table->columns->$name->null = (bool)stripos( $line, ' NOT NULL ' );
- $table->columns->$name->type = $m[2];
- if ( isset($m[3]) ) {
- if ( substr( $m[3], 0, 1 ) == '(' )
- $table->columns->$name->length = substr( $m[3], 1, -1 );
- else
- $table->columns->$name->length = $m[3];
- } else {
- $table->columns->$name->length = null;
- }
- if ( preg_match( '/ character set (\S+)/i', $line, $m ) ) {
- $table->columns->$name->charset = $m[1];
- } else {
- $table->columns->$name->charset = '';
- }
- if ( preg_match( '/ collate (\S+)/i', $line, $m ) ) {
- $table->columns->$name->collate = $m[1];
- } else {
- $table->columns->$name->collate = '';
- }
- if ( preg_match( '/ DEFAULT (.+),$/i', $line, $m ) ) {
- if ( substr( $m[1], 0, 1 ) == "'" )
- $table->columns->$name->default = substr( $m[1], 1, -1 );
- else
- $table->columns->$name->default = $m[1];
- } else {
- $table->columns->$name->default = null;
- }
- $table->columns->$name->line = $line;
- }
- $pk = preg_grep( '/^PRIMARY\s+KEY\s+/i', $sql );
- if ( count( $pk ) ) {
- $pk = array_pop( $pk );
- $pk = preg_replace( '/(^[^\(]+\(`|`\),?$)/', '', $pk );
- $pk = preg_replace( '/\([0-9]+\)/', '', $pk );
- $pk = explode( '`,`', $pk );
- $table->primary = $pk;
- }
- if ( is_array( $table->primary ) && count( $table->primary ) == 1 ) {
- $pk_column_name = $table->primary[0];
- switch( strtolower( $table->columns->$pk_column_name->type ) ) {
- // Integers, exact value
- case 'tinyint':
- case 'smallint':
- case 'int':
- case 'integer':
- case 'bigint':
- // Fixed point, exact value
- case 'decimal':
- case 'numeric':
- // Floating point, approximate value
- case 'float':
- case 'double':
- case 'real':
- // Date and Time
- case 'date':
- case 'datetime':
- case 'timestamp':
- $table->single_int_paging_column = $pk_column_name;
- break;
- }
- }
- $keys = preg_grep( '/^((?:UNIQUE )?INDEX|(?:UNIQUE )?KEY)\s+/i', $sql );
- if ( !count( $keys ) )
- return $table;
- foreach ( $keys as $idx => $key ) {
- if ( 0 === strpos( $key, 'UNIQUE' ) )
- $is_unique = false;
- else
- $is_unique = true;
-
- // for KEY `refresh` (`ip`,`time_last`) USING BTREE,
- $key = preg_replace( '/ USING \S+ ?(,?)$/', '$1', $key );
-
- // for KEY `id` USING BTREE (`id`),
- $key = preg_replace( '/` USING \S+ \(/i', '` (', $key );
-
- $key = preg_replace( '/^((?:UNIQUE )?INDEX|(?:UNIQUE )?KEY)\s+/i', '', $key );
- $key = preg_replace( '/\([0-9]+\)/', '', $key );
- preg_match( '/^`([^`]+)`\s+\(`(.+)`\),?$/', $key, $m );
- $key = $m[1]; //preg_replace( '/\([^)]+\)/', '', $m[1]);
- if ( !$key )
- continue;
- if ( $is_unique )
- $table->keys->$key = explode( '`,`', $m[2] );
- else
- $table->uniques->$key = explode( '`,`', $m[2] );
- }
-
- $uniques = get_object_vars( $table->uniques );
- foreach( $uniques as $idx => $val ) {
- if ( is_array( $val ) && count( $val ) == 1 ) {
- $pk_column_name = $val[0];
- switch( strtolower( $table->columns->$pk_column_name->type ) ) {
- // Integers, exact value
- case 'tinyint':
- case 'smallint':
- case 'int':
- case 'integer':
- case 'bigint':
- // Fixed point, exact value
- case 'decimal':
- case 'numeric':
- // Floating point, approximate value
- case 'float':
- case 'double':
- case 'real':
- // Date and Time
- case 'date':
- case 'datetime':
- case 'timestamp':
- $table->single_int_paging_column = $pk_column_name;
- break;
- }
- }
- }
-
- if ( empty( $table->primary ) ) {
- if ( !empty( $uniques ) )
- $table->primary = array_shift( $uniques );
- }
-
- return $table;
- }
-}
diff --git a/plugins/vaultpress/class.vaultpress-filesystem.php b/plugins/vaultpress/class.vaultpress-filesystem.php
deleted file mode 100644
index 556fe542..00000000
--- a/plugins/vaultpress/class.vaultpress-filesystem.php
+++ /dev/null
@@ -1,261 +0,0 @@
-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 ) ) {
- $file_name = basename( $file );
- if ( 'wp-config.php' == $file_name ) {
- $dir = dirname( $file );
- $dir = explode( DIRECTORY_SEPARATOR, $dir );
- array_pop( $dir );
- $dir = implode( DIRECTORY_SEPARATOR, $dir );
- $file = trailingslashit( $dir ) . $file_name;
- if ( !file_exists( $file ) || !is_readable( $file ) )
- die( "no such file" );
- } else {
- 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 );
- }
- $dir = $this->dir;
- if ( 0 !== strpos( $file, $dir ) && 'wp-config.php' == basename( $file ) ) {
- $dir = explode( DIRECTORY_SEPARATOR, $dir );
- array_pop( $dir );
- $dir = implode( DIRECTORY_SEPARATOR, $dir );
- }
- $rval['path'] = str_replace( $dir, '', $file );
- return $rval;
- }
-
- function ls( $what, $md5=false, $sha1=false, $limit=null, $offset=null, $full_list=false ) {
- clearstatcache();
- $path = realpath($this->dir . $what);
- $dir = $this->dir;
- if ( !$path && '/wp-config.php' == $what ) {
- $dir = explode( DIRECTORY_SEPARATOR, $dir );
- array_pop( $dir );
- $dir = implode( DIRECTORY_SEPARATOR, $dir );
- $path = realpath( $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 ( !$full_list && !$this->should_backup_file( $i ) )
- continue;
- 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 should_backup_file( $filepath ) {
- $vp = VaultPress::init();
- if ( is_dir( $filepath ) )
- $filepath = trailingslashit( $filepath );
- $regex_patterns = $vp->get_should_ignore_files();
- foreach ( $regex_patterns as $pattern ) {
- $matches = array();
- if ( preg_match( $pattern, $filepath, $matches ) ) {
- return false;
- }
- }
- return true;
- }
-
- function validate( $file ) {
- $rpath = realpath( $this->dir.$file );
- $dir = $this->dir;
- if ( !$rpath && '/wp-config.php' == $file ) {
- $dir = explode( DIRECTORY_SEPARATOR, $dir );
- array_pop( $dir );
- $dir = implode( DIRECTORY_SEPARATOR, $dir );
- $rpath = realpath( $dir . $file );
- }
- if ( !$rpath )
- die( serialize( array( 'type' => 'null', 'path' => $file ) ) );
- if ( is_dir( $rpath ) )
- $rpath = "$rpath/";
- if ( strpos( $rpath, $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 4dbb12bb..00000000
--- a/plugins/vaultpress/class.vaultpress-hotfixes.php
+++ /dev/null
@@ -1,834 +0,0 @@
-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
- $query_parts = explode( " ", $query );
- $post_id = array_pop( $query_parts );
-
- // 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 "$elem>";
- # 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 6921589e..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;
- }
-}
diff --git a/plugins/vaultpress/cron-tasks.php b/plugins/vaultpress/cron-tasks.php
deleted file mode 100644
index d09ca301..00000000
--- a/plugins/vaultpress/cron-tasks.php
+++ /dev/null
@@ -1,150 +0,0 @@
- 300,
- 'display' => __( 'Once every five minutes' , 'vaultpress'),
- );
- return $schedules;
- }
-
- function _scan_site() {
- if ( !get_option( '_vp_current_scan' ) ) {
- $ignore_symlinks = get_option( '_vp_ignore_symlinks', false );
- $paths = array( 'root' => new VP_FileScan( ABSPATH, $ignore_symlinks ) );
-
- // 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, $ignore_symlinks );
-
- // 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, $ignore_symlinks );
-
- // 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, $ignore_symlinks );
-
- 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 ) );
- }
- }
-
- static function &init() {
- static $instance = false;
- if ( !$instance )
- $instance = new VP_Site_Scanner();
- return $instance;
- }
-}
-VP_Site_Scanner::init();
diff --git a/plugins/vaultpress/images/dashboard-icon-sprite-2x.png b/plugins/vaultpress/images/dashboard-icon-sprite-2x.png
deleted file mode 100644
index de1d7c3b..00000000
Binary files a/plugins/vaultpress/images/dashboard-icon-sprite-2x.png and /dev/null differ
diff --git a/plugins/vaultpress/images/dashboard-icon-sprite.png b/plugins/vaultpress/images/dashboard-icon-sprite.png
deleted file mode 100644
index e8a65b30..00000000
Binary files a/plugins/vaultpress/images/dashboard-icon-sprite.png and /dev/null differ
diff --git a/plugins/vaultpress/images/logo_plugin-notice.png b/plugins/vaultpress/images/logo_plugin-notice.png
deleted file mode 100644
index 9c9b13f4..00000000
Binary files a/plugins/vaultpress/images/logo_plugin-notice.png and /dev/null differ
diff --git a/plugins/vaultpress/images/noise.png b/plugins/vaultpress/images/noise.png
deleted file mode 100644
index d8d10909..00000000
Binary files a/plugins/vaultpress/images/noise.png and /dev/null differ
diff --git a/plugins/vaultpress/images/plugin-shield-2x.png b/plugins/vaultpress/images/plugin-shield-2x.png
deleted file mode 100644
index 237996e5..00000000
Binary files a/plugins/vaultpress/images/plugin-shield-2x.png and /dev/null differ
diff --git a/plugins/vaultpress/images/plugin-shield.png b/plugins/vaultpress/images/plugin-shield.png
deleted file mode 100644
index f8bf33ff..00000000
Binary files a/plugins/vaultpress/images/plugin-shield.png and /dev/null differ
diff --git a/plugins/vaultpress/images/vp-icon-sprite-2x.png b/plugins/vaultpress/images/vp-icon-sprite-2x.png
deleted file mode 100644
index 36846c21..00000000
Binary files a/plugins/vaultpress/images/vp-icon-sprite-2x.png and /dev/null differ
diff --git a/plugins/vaultpress/images/vp-icon-sprite.png b/plugins/vaultpress/images/vp-icon-sprite.png
deleted file mode 100644
index e525eaec..00000000
Binary files a/plugins/vaultpress/images/vp-icon-sprite.png and /dev/null differ
diff --git a/plugins/vaultpress/images/vp-toolbar-icon-trans-2x.png b/plugins/vaultpress/images/vp-toolbar-icon-trans-2x.png
deleted file mode 100644
index 0cb57e61..00000000
Binary files a/plugins/vaultpress/images/vp-toolbar-icon-trans-2x.png and /dev/null differ
diff --git a/plugins/vaultpress/images/vp-toolbar-icon-trans.png b/plugins/vaultpress/images/vp-toolbar-icon-trans.png
deleted file mode 100644
index 757b0bb4..00000000
Binary files a/plugins/vaultpress/images/vp-toolbar-icon-trans.png and /dev/null differ
diff --git a/plugins/vaultpress/nav-styles.css b/plugins/vaultpress/nav-styles.css
deleted file mode 100644
index d94ba2e0..00000000
--- a/plugins/vaultpress/nav-styles.css
+++ /dev/null
@@ -1,19 +0,0 @@
-#toplevel_page_vaultpress div.wp-menu-image {
- background: url(images/vp-icon-sprite.png) center top no-repeat;
- background-size: 28px 84px;
-}
-
-.admin-color-classic #toplevel_page_vaultpress div.wp-menu-image {
- background-position: center -28px;
-}
-
-#toplevel_page_vaultpress.current div.wp-menu-image,
-#toplevel_page_vaultpress:hover div.wp-menu-image {
- background-position: center bottom;
-}
-
-@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
- #toplevel_page_vaultpress div.wp-menu-image {
- background-image: url(images/vp-icon-sprite-2x.png);
- }
-}
diff --git a/plugins/vaultpress/readme.txt b/plugins/vaultpress/readme.txt
deleted file mode 100644
index b0004896..00000000
--- a/plugins/vaultpress/readme.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-=== VaultPress ===
-Contributors: automattic, apokalyptik, briancolinger, josephscott, shaunandrews, xknown, thingalon
-Tags: security, malware, virus, backups, scanning
-Requires at least: 2.9.2
-Tested up to: 3.8
-Stable tag: 1.5.1
-License: GPLv2
-
-VaultPress is a subscription service offering realtime backup, automated security scanning, and support from WordPress experts.
-
-== Description ==
-
-[VaultPress](http://vaultpress.com/?utm_source=plugin-readme&utm_medium=description&utm_campaign=1.0) is a real-time backup and security scanning service designed and built by [Automattic](http://automattic.com/), the same company that operates 25+ million sites on WordPress.com.
-
-The VaultPress plugin provides the required functionality to backup and synchronize every post, comment, media file, revision and dashboard settings on our servers. To start safeguarding your site, you need to sign up for a VaultPress subscription.
-
-[wpvideo TxdSIdpO]
-
-For more information, check out [VaultPress.com](http://vaultpress.com/).
-
-== Installation ==
-
-1. Search for VaultPress in the WordPress.org plugin directory and click install. Or, upload the files to your `wp-content/vaultpress/` folder.
-2. Visit `wp-admin/plugins.php` and activate the VaultPress plugin.
-3. Head to `wp-admin/admin.php?page=vaultpress` and enter your site’s registration key. You can purchase your registration key at [VaultPress.com](http://vaultpress.com/plugin/?utm_source=plugin-readme&utm_medium=installation&utm_campaign=1.0)
-
-You can find more detailed instructions at [http://vaultpress.com/](http://help.vaultpress.com/install-vaultpress/?utm_source=plugin-readme&utm_medium=description&utm_campaign=1.0)
-
-== Frequently Asked Questions ==
-
-View our full list of FAQs at [http://help.vaultpress.com/faq/](http://help.vaultpress.com/faq/?utm_source=plugin-readme&utm_medium=faq&utm_campaign=1.0)
-
-= What’s included in each VaultPress plan? =
-
-All plans include Daily or Realtime Backups, Downloadable Archives for Restoring, Vitality Statistics, and the Activity Log.
-
-The Lite plan provides Daily Backups, a 30-day backup archive and automated restores.
-
-The Basic plan provides Realtime Backups to protect your changes as they happen and support services.
-
-The Premium plan provides priority recovery and support services, along with site migration assistance. The Premium plan provides automated security scanning of Core, Theme, and Plugin files.
-
-Update-to-date pricing and features can always be found on the [Plans & Pricing](http://vaultpress.com/plugin/?utm_source=plugin-readme&utm_medium=installation&utm_campaign=1.0) page.
-
-= How many sites can I protect with VaultPress? =
-
-A VaultPress subscription is for a single WordPress site. You can purchase additional subscriptions for each of your WordPress sites, and manage them all with in one place.
-
-= Does VaultPress work with WordPress 3.0 Multisite installs? =
-
-Yes, VaultPress supports Multisite installs. Each site will require its own subscription.
-
-== Changelog ==
-= 1.5.1 =
-* Feature: Adding file exclusion patterns to avoid backing up cache and backup directories.
-
-= 1.5 =
-* Bugfix: Don't show admin notices on the about page.
-
-= 1.4.9 =
-* Bugfix: Clean up PHP5 strict warnings.
-
-= 1.4.8 =
-* Feature: Include styles and images with the plugin instead of loading them externally.
-
-= 1.4.7 =
-* Bugfix: Some servers have SSL configuration problems, which breaks the plugin when SSL verification is enforced.
-
-= 1.4.6 =
-* Bugfix: PHP 5.4 notices
-* Feature: Add the possibility to ignore frequent updates on some postmeta keys.
-
-= 1.3.9 =
-* Feature: Request decoding (base64/rot13)
-* Feature: Response encoding (base64/rot13)
-
-= 1.3.8 =
-* Bugfix: Validate IPv4-mapped IPv6 addresses in the internal firewall.
-* Bugfix: Fix hooks not being properly added under certain circumstances.
-
-= 1.3.7 =
-* Bugfix: Protect against infinite loop due to a PHP bug.
-* Bugfix: Encode remote ping requests.
-
-= 1.0 =
-* First public release!
diff --git a/plugins/vaultpress/styles.css b/plugins/vaultpress/styles.css
deleted file mode 100644
index c0d07791..00000000
--- a/plugins/vaultpress/styles.css
+++ /dev/null
@@ -1,682 +0,0 @@
-/* --- Misc --- */
-.clrfix { zoom:1; }
-.clrfix:after { content:".";display:block;height:0;width:0;line-height:0;clear:both;visibility:hidden; }
-
-/* --- Structure --- */
-#vp-wrap {
-}
-
-/* --- Old Plugin Head 0.x --- */
-#vp-head {
- padding: 10px 0;
-}
-#vp-head:after {
- content: "."; display: block; height: 0; clear: both; visibility: hidden;
-}
-#vp-head h2 a.vp-visit-dashboard {
- position: absolute;
- top: 27px;
- right: 15px;
- -webkit-font-smoothing: antialiased;
- font-weight: bold;
- float: right;
- text-shadow: none;
- font-size: 13px;
- line-height: 100%;
- padding: 5px 15px 7px 15px;
- text-decoration: none;
- color: #999;
- border: 1px solid #CCC;
- border: 1px solid rgba(0,0,0,0.3);
- -webkit-border-radius: 3px;
- -moz-border-radius: 3px;
- border-radius: 3px;
- box-shadow: 0 1px 0 rgba(0,0,0,0.1);
-}
-#vp-head a.vp-visit-dashboard:hover {
- background: #0098C4;
- color: #FFF;
- border-color: rgba(0,0,0,0.3);
- box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 0 rgba(0,0,0,0.1);
-}
-#vp-head a.vp-visit-dashboard:active {
- color: rgba(255,255,255,0.6);
- box-shadow: inset 0 2px 2px rgba(0,0,0,0.2);
- top: 28px;
-}
-#vp-head h2 {
- float: left;
- height: 32px;
- background: url(images/plugin-shield.png) 0 7px no-repeat;
- background-size: 31px 32px;
- font-size: 23px;
- padding: 11px 15px 4px 40px;
- line-height: 29px;
-}
-#vp-head .updated {
- clear: left;
-}
-
-/* --- Header 1.x --- */
-#icon-vaultpress {
- background: url(images/plugin-shield.png) 0 0 no-repeat;
-}
-
-
-/* --- Notices --- */
-#vp-notice {
- clear: both;
- display: block;
- background: #343434 url(images/logo_plugin-notice.png) 15px 17px no-repeat;
- border: 1px solid rgba(0,0,0,0.5);
- box-shadow: 0 2px 1px rgba(0,0,0,0.1);
- padding: 20px 15px 20px 55px;
- margin: 10px 0;
- -webkit-border-radius: 3px;
- -moz-border-radius: 3px;
- border-radius: 3px;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;;
-}
-#vp-notice:after {
- content: "."; display: block; height: 0; clear: both; visibility: hidden;
-}
-
- #vp-notice .vp-message {
- color: #FFF;
- -webkit-font-smoothing: antialiased;
- }
- #vp-notice .vp-message h3 {
- font-size: 20px;
- font-weight: normal;
- font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Arial, Helvetica, sans-serif;
- margin: 0 0 10px 0;
- }
- #vp-notice .vp-message p {
- margin: 0;
- padding: 0;
- font-size: 12px;
- line-height: 180%;
- }
- #vp-notice .vp-message a {
- padding: 3px 10px;
- text-decoration: none;
- color: #CCC;
- border: 1px solid #FFF;
- border: 1px solid rgba(255,255,255,0.3);
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
- box-shadow: 0 1px 0 rgba(0,0,0,0.1);
- }
- #vp-notice .vp-message a:hover {
- background: #0098C4;
- color: #FFF;
- border-color: rgba(0,0,0,0.3);
- box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
- }
- #vp-notice .vp-message a:active {
- color: rgba(255,255,255,0.6);
- box-shadow: inset 0 2px 2px rgba(0,0,0,0.2);
- position: relative;
- top: 1px;
- }
-
-#vp-notice.vp-error {
- background-color: #AB0300;
-}
- #vp-notice.vp-error a { color: #FFF; }
- #vp-notice.vp-error a:hover { background: #333; box-shadow: inset 0 1px 0 rgba(255,255,255,0.1) }
- #vp-notice.vp-error a:active { }
-
-
-/* --- Remote Access Notice --- */
-#no-access-credentials {
- clear: both;
- background: #FBFBDF;
- padding: 1px 25px;
- margin: 0 0 20px 0;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- clear: both;
- -webkit-border-top-left-radius: 4px;
- -webkit-border-top-right-radius: 4px;
- -moz-border-radius-topleft: 4px;
- -moz-border-radius-topright: 4px;
- border-top-left-radius: 4px;
- border-top-right-radius: 4px;
- -webkit-background-clip: padding-box;
- -webkit-font-smoothing: antialiased;
-}
-#no-access-credentials p {
- font-size: 14px;
- color: #333;
- text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
- text-align: left;
- padding-left: 42px;
- line-height: 32px;
- background: url(images/dashboard-icon-sprite.png) no-repeat -270px -391px;
- background-size: 300px 420px;
-}
-
-
-/* --- Toolbar --- */
-#wpadminbar #wp-admin-bar-vp-notice a {
- padding: 0 4px;
-}
-#wpadminbar #wp-admin-bar-vp-notice strong {
- float: left;
- margin-top: 3px;
- padding: 1px 7px 0 5px;
- background-color: #ff9a00;
- color: #fff;
- color: rgba(255,255,255,0.9);
- font-size: 12px;
- text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
- line-height: 21px;
- text-shadow: none;
- -webkit-border-radius: 2px;
- -moz-border-radius: 2px;
- border-radius: 2px;
- overflow: hidden;
- height: 21px;
-}
-
-#wpadminbar #wp-admin-bar-vp-notice a:active strong {
- position: relative;
- top: 1px;
- box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
-}
-
-#wpadminbar #wp-admin-bar-vp-notice.error strong {
- background-color: #ac0300;
-}
-
-#wpadminbar #wp-admin-bar-vp-notice strong .ab-icon {
- width: 16px;
- height: 21px;
- margin: 0 6px 0 0;
- background: transparent url(images/vp-toolbar-icon-trans.png) no-repeat 0 2px;
- background-size: 16px;
-}
-
-
-/* gray hover */
-/*
-#wpadminbar #wp-admin-bar-vp-notice a:hover strong {
- background-color: #333;
- -webkit-box-shadow: inset 0px 1px 1px 0px rgba(0, 0, 0, .4);
- -moz-box-shadow: inset 0px 1px 1px 0px rgba(0, 0, 0, .4);
- box-shadow: inset 0px 1px 1px 0px rgba(0, 0, 0, .4);
- border-bottom: 1px solid #444;
-}
-*/
-
-/* reset hover state */
-
-#wpadminbar #wp-admin-bar-vp-notice a.ab-item:hover {
- background-image: none;
- background-color: #222;
-}
-
-
-/* --- Status Ticker --- */
-#vp-ticker {
- margin: 0 0 20px 0;
- padding: 8px 8px;
- position: relative;
- top: 0px;
- border-top: 1px solid #CCC;
- border-bottom: 1px solid #CCC;
- background: #EFEFEF url(images/noise.png) repeat 0 0;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- -webkit-font-smoothing: antialiased;
-}
-#vp-ticker h3 {
- margin: 0;
- padding: 0 5px 0 0;
- font-size: 13px;
- line-height: 1em;
- color: #999;
- display: inline;
- font-style: normal;
- text-shadow: 0 1px 0 #FFF;
- font-weight: bold;
-
- -webkit-font-smoothing: antialiased;
- -webkit-border-radius: 4px;
- -moz-border-radius: 4px;
- border-radius: 4px;
-}
-#vp-ticker p {
- margin: 0;
- padding: 0;
- display: inline;
- font-size: 13px;
- line-height: 1em;
- color: #000;
- text-shadow: none;
-}
-
-
-/* --- Tabs --- */
-#vp-tabs {
- /* IE 7 specific */
- *position: relative;
- *z-index: 1;
-}
-#vp-tabs .menu-tabs {
- float: left;
- height: 28px;
- line-height: 28px;
- margin: 0 5px 0 0;
- padding: 0 8px;
- border-width: 1px 1px 1px;
- border-style: solid;
- border-color: #ddd #ddd #fff;
- font-size: 13px;
- color: #818181;
- background-color: #fff;
- text-decoration: none;
- text-shadow: #fff 0px 1px 0px;
- text-transform: uppercase;
- font-family: "Lucida Grande", Lucida, Helvetica, Verdana, Arial, sans-serif;
-}
-#vp-tabs .menu-tab-inactive {
- border-color: #ddd;
- background-color: #ededed;
- color: #21759b;
-}
-#vp-tabs .menu-tab-inactive:hover {
- text-decoration: underline;
-}
-#vp-tab-content {
- min-width: 568px;
- max-width: 1000px;
- margin-top: -1px;
- padding: 20px;
- border: 1px solid #ddd;
- background-color: #fff;
-}
-#vp-tab-content .label {
- padding-left: 8px;
-}
-#vp-totals table td {
- border-top: #ececec 1px solid;
- padding: 3px 0;
- white-space: nowrap;
-}
-#vp-totals table tr.first td {
- border-top: none;
-}
-#vp-totals td.b {
- padding-right: 6px;
- text-align: right;
- font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
- font-size: 18px;
-}
-#vp-totals .t {
- font-size: 12px;
- padding-right: 12px;
- padding-top: 6px;
- color: #777;
-}
-#vp-totals td.first,
-#vp-totals td.last {
- width: 1%;
-}
-#vp-totals .col1 {
- float: left;
- width: 45%;
- margin-right: 1em;
-}
-#vp-totals p,
-#vp-activity p {
- margin-top: 0;
- color: #333;
- font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
- font-size: 16px;
-}
-#vp-totals p em {
- color: #666;
- font-size: 13px;
- font-style: italic;
-}
-#vp-totals .col2 {
- float: left;
- width: 25%;
-}
-#vp-totals .col3 {
- float: right;
- width: 25%;
-}
-#vp-totals p {
- clear: both;
- width: 100%;
-}
-#vp-activity td {
- padding: 12px 8px;
- color: #666;
- font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
- font-size: 13px;
- vertical-align: middle;
-}
-#vp-activity td .ago {
- color: #000;
- font-size: 1.2em;
-}
-#vp-activity td.date {
- width: 1%;
- padding-right: 15px;
- white-space: nowrap;
-}
-
-
-
-/* --- Not Registered/Activated --- */
-#vp_registration {
- clear: both;
- position: relative;
- margin: 10px 0 20px 0;
- -webkit-font-smoothing: antialiased;
-}
-#vp_registration:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
-
-#vp_registration .vp_view-plans {
- background: #333 url(images/noise.png) repeat 0 0;
- color: #FFF;
- float: left;
- width: 360px;
- padding: 20px 30px 30px 30px;
- margin-right: 30px;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
-}
-#vp_registration .vp_view-plans h1 {
- font-size: 24px;
- font-weight: normal;
- font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Arial, Helvetica, sans-serif;
- margin: 0 0 10px 0;
- line-height: 140%;
-}
-#vp_registration .vp_view-plans h1 strong {}
-#vp_registration .vp_view-plans p {
- color: #CCC;
- font-size: 15px;
- line-height: 140%;
- margin: 0 0 25px 0;
-}
-#vp_registration .vp_view-plans h5 strong {}
-#vp_registration .vp_view-plans p.vp_plans-btn {
- position: relative;
- left: -5px;
-}
-#vp_registration .vp_view-plans p.vp_plans-btn a {
- float: left;
- padding: 4px;
- background-color: rgba(0,0,0,0.8);
- background-color: #000;
- -webkit-border-radius: 30px;
- -moz-border-radius: 30px;
- border-radius: 30px;
- text-decoration: none;
- color: #FFF;
- font-size: 13px;
- text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
-}
-#vp_registration .vp_view-plans p.vp_plans-btn a:hover {}
-#vp_registration .vp_view-plans p.vp_plans-btn a:active {}
-#vp_registration .vp_view-plans p.vp_plans-btn a strong {
- background: #0090BA;
- padding: 10px 55px;
- float: left;
- border: 1px solid rgba(0, 0, 0, 0.4);
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
- -moz-border-radius: 30px;
- -webkit-border-radius: 30px;
- border-radius: 30px;
- -webkit-background-clip: padding-box;
- text-decoration: none;
- color: white;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-size: 16px;
- font-weight: normal;
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
- background: -moz-linear-gradient(top, #10C3EF 0%, #10A6CC 3%, #039BC1 43%, #009AC4 46%, #0084A5 100%);
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #10C3EF), color-stop(3%, #10A6CC), color-stop(43%, #039BC1), color-stop(46%, #009AC4), color-stop(100%, #0084A5));
- background: -webkit-linear-gradient(top, #10C3EF 0%, #10A6CC 3%, #039BC1 43%, #009AC4 46%, #0084A5 100%);
- background: -o-linear-gradient(top, #10C3EF 0%, #10A6CC 3%, #039BC1 43%, #009AC4 46%, #0084A5 100%);
- background: -ms-linear-gradient(top, #10C3EF 0%, #10A6CC 3%, #039BC1 43%, #009AC4 46%, #0084A5 100%);
- background: linear-gradient(top, #10C3EF 0%, #10A6CC 3%, #039BC1 43%, #009AC4 46%, #0084A5 100%);
-}
-#vp_registration .vp_view-plans p.vp_plans-btn a strong b { font-weight: bold; }
-#vp_registration .vp_view-plans p.vp_plans-btn a:hover strong {
- box-shadow: 0 3px 4px #000;
- text-decoration: underline;
-}
-#vp_registration .vp_view-plans p.vp_plans-btn a:active strong {
- background: #007ca0; /* Old browsers */
- background: -moz-linear-gradient(top, #007ca0 0%, #7db9e8 100%); /* FF3.6+ */
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#007ca0), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */
- background: -webkit-linear-gradient(top, #007ca0 0%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */
- background: -o-linear-gradient(top, #007ca0 0%,#7db9e8 100%); /* Opera11.10+ */
- background: -ms-linear-gradient(top, #007ca0 0%,#7db9e8 100%); /* IE10+ */
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#007ca0', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */
- background: linear-gradient(top, #007ca0 0%,#7db9e8 100%); /* W3C */
-}
-
-#vp_registration .vp_register-plugin {
- float: left;
- padding: 50px 0 0 0;
-}
-#vp_registration .vp_register-plugin h3 {
- font-size: 15px;
- color: #333;
- text-shadow: 0 1px 0 #FFF;
- margin: 0 0 5px 0;
-}
-#vp_registration .vp_register-plugin p {
- margin: 0 0 15px 0;
- color: #666;
-}
-#vp_registration .vp_register-plugin fieldset {}
-#vp_registration .vp_register-plugin textarea {
- display: block;
- width: 350px;
- height: 60px;
- border: 1px solid #999;
- box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
- padding: 5px;
- font-size: 14px;
- font-family: Georgia, Constantia, "Palatino Linotype", "Book Antiqua", serif;;
- -webkit-border-radius: 3px;
- -moz-border-radius: 3px;
- border-radius: 3px;
-}
-#vp_registration .vp_register-plugin button {
- -webkit-font-smoothing: antialiased;
- float: left;
- font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Arial, Helvetica, sans-serif;
- padding: 0;
- border: none !important;
- background: transparent;
- text-decoration: none;
- color: #333;
- font-size: 13px;
- text-shadow: 0 1px 0 #FFF;
- cursor: pointer;
- position: relative;
- top: 10px;
- left: -4px;
-}
-#vp_registration .vp_register-plugin button strong {
- float: left;
- padding: 7px 25px;
- border: 1px solid #999;
- -webkit-border-radius: 30px;
- -moz-border-radius: 30px;
- border-radius: 30px;
-
- background: #ffffff; /* Old browsers */
- background: -moz-linear-gradient(top, #ffffff 0%, #dddddd 100%); /* FF3.6+ */
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#dddddd)); /* Chrome,Safari4+ */
- background: -webkit-linear-gradient(top, #ffffff 0%,#dddddd 100%); /* Chrome10+,Safari5.1+ */
- background: -o-linear-gradient(top, #ffffff 0%,#dddddd 100%); /* Opera11.10+ */
- background: -ms-linear-gradient(top, #ffffff 0%,#dddddd 100%); /* IE10+ */
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#dddddd',GradientType=0 ); /* IE6-9 */
- background: linear-gradient(top, #ffffff 0%,#dddddd 100%); /* W3C */
-}
-#vp_registration .vp_register-plugin button strong:active { background: #CCC; position: relative; top: 1px; }
-
-
-
-/* Progress Bars */
-#vp_progress {
- font-family: Helvetica, Arial, Sans-serif;
-}
-#vp_progress:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
-
-#vp_progress .vp_graphs {
- background: #333 url(images/noise.png) repeat 0 0;
- color: #FFF;
- float: left;
- width: 380px;
- padding: 0;
- -webkit-border-radius: 6px;
- -moz-border-radius: 6px;
- border-radius: 6px;
- -webkit-font-smoothing: antialiased;
-}
-#vp_progress .vp_graphs:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
-
-#vp_progress .vp_graphs h1 {
- color: #FFF;
- text-shadow: 0 -1px 0 rgba(0,0,0,0.4);
- padding: 20px 30px 20px 30px;
- margin: 0;
- border-bottom: 1px solid rgba(255,255,255,0.05);
-
- font-size: 24px;
- font-weight: normal;
- font-family: HelveticaNeue-Light, 'Helvetica Neue Light', 'Helvetica Neue', Arial, Helvetica, sans-serif;
- line-height: 140%;
-}
-#vp_progress .vp_graphs ul {
- padding: 0 0 5px 0;
- float: left;
- width: 380px;
- background: rgba(0,0,0,0.1);
-}
-#vp_progress .vp_graphs ul li {
- float: left;
- clear: both;
- margin: 0;
- width: 320px;
- padding: 15px 30px;
- line-height: 100%;
- border-top: 1px solid rgba(0,0,0,0.3);
- border-bottom: 1px solid rgba(255,255,255,0.05);
-}
-#vp_progress .vp_graphs ul li.completed { }
-#vp_progress .vp_graphs ul li.completed .bar { }
-#vp_progress .vp_graphs ul li.completed .bar span {
- background: rgb(41,154,11);
- background: -moz-linear-gradient(top, rgba(41,154,11,1) 0%, rgba(41,154,11,1) 100%);
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(41,154,11,1)), color-stop(100%,rgba(41,154,11,1)));
- background: -webkit-linear-gradient(top, rgba(41,154,11,1) 0%,rgba(41,154,11,1) 100%);
- background: -o-linear-gradient(top, rgba(41,154,11,1) 0%,rgba(41,154,11,1) 100%);
- background: -ms-linear-gradient(top, rgba(41,154,11,1) 0%,rgba(41,154,11,1) 100%);
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#299a0b', endColorstr='#299a0b',GradientType=0 );
- background: linear-gradient(top, rgba(41,154,11,1) 0%,rgba(41,154,11,1) 100%);
-}
-#vp_progress .vp_graphs ul li.completed .percentage,
-#vp_progress .vp_graphs ul li.completed .title {
- color: #FFF;
-}
-
-#vp_progress .bar {
- float: left;
- width: 215px;
- padding: 4px;
- background: #252525 url(images/noise.png) repeat 0 0;
- margin: 0 5px 0 0;
- border: 1px solid rgba(255,255,255,0.1);
- -webkit-border-radius: 20px;
- -moz-border-radius: 20px;
- border-radius: 20px;
- box-shadow: inset 0 1px 1px rgba(0,0,0,0.6);
-}
-#vp_progress .bar span {
- float: left;
- height: 22px;
-
- background: #63b6db;
- background: -moz-linear-gradient(top, #63b6db 0%, #309dcf 100%);
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#63b6db), color-stop(100%,#309dcf));
- background: -webkit-linear-gradient(top, #63b6db 0%,#309dcf 100%);
- background: -o-linear-gradient(top, #63b6db 0%,#309dcf 100%);
- background: -ms-linear-gradient(top, #63b6db 0%,#309dcf 100%);
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#63b6db', endColorstr='#309dcf',GradientType=0 );
- background: linear-gradient(top, #63b6db 0%,#309dcf 100%);
-
-
- box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
-
- -webkit-border-radius: 20px;
- -moz-border-radius: 20px;
- border-radius: 20px;
-}
-#vp_progress .percentage {
- float: right;
- position: relative;
- top: 10px;
- margin: 0;
- width: 30px;
- text-align: right;
- font-size: 11px;
- font-weight: bold;
- color: #999;
-}
-#vp_progress .title {
- float: left;
- width: 60px;
- position: relative;
- top: 10px;
- font-size: 12px;
- color: #CCC;
-}
-
-#vp_progress .vp_progress-description {
- margin: 0 0 0 400px;
- padding: 20px 20px 0 20px;
-}
-#vp_progress .vp_progress-description h3 {
- font-size: 12px;
- color: #AAA;
-}
-#vp_progress .vp_progress-description ul {
- margin: 0 0 20px 0;
-}
-#vp_progress .vp_progress-description li {
- list-style: square;
- color: #777;
- margin: 0 0 15px 0;
- font-size: 12px;
- line-height: 160%;
-}
-#vp_progress .vp_progress-description li strong {
- color: #555;
-}
-#vp_progress .vp_progress-description p {
- font-size: 12px;
- color: #999;
- font-style: italic;
- line-height: 160%;
- margin: 0 0 30px 0;
-}
-
-
-@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3, '/', 2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
- #vp-head h2 { background-image: url(images/plugin-shield-2x.png); }
- #no-access-credentials p { background-image: url(images/dashboard-icon-sprite-2x.png); }
- #wpadminbar #wp-admin-bar-vp-notice strong .ab-icon { background-image: url(images/vp-toolbar-icon-trans-2x.png); }
-}
\ No newline at end of file
diff --git a/plugins/vaultpress/vaultpress.php b/plugins/vaultpress/vaultpress.php
deleted file mode 100644
index f9bc5b3d..00000000
--- a/plugins/vaultpress/vaultpress.php
+++ /dev/null
@@ -1,2220 +0,0 @@
-realtime backup and automated security scanning from VaultPress . Activate, enter your registration key, and never worry again. Need some help?
- * Version: 1.5.1
- * 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 = 3;
- var $plugin_version = '1.5.1';
-
- 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' ) || $this->get_option( 'do_not_send_backup_pings' );
- if ( $do_not_backup )
- $this->add_vp_required_filters();
- else
- $this->add_listener_actions_and_filters();
- }
- }
-
- static 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();
- }
-
- if ( $current_db_version < 3 ) {
- $this->update_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' ) );
- }
- }
- }
-
- function admin_menu() {
- // if Jetpack is loaded then we need to wait for that menu to be added
- if ( class_exists( 'Jetpack' ) )
- add_action( 'jetpack_admin_menu', array( $this, 'load_menu' ) );
- else
- $this->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' ) || !is_admin() )
- return;
-
- wp_enqueue_style( 'vaultpress-nav', plugins_url( '/nav-styles.css', __FILE__ ), false, date( 'Ymd' ) );
-
- if ( isset( $_GET['page'] ) && 'vaultpress' == $_GET['page'] )
- wp_enqueue_style( 'vaultpress', plugins_url( '/styles.css', __FILE__ ), 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') );
-
- $screen = get_current_screen();
- if ( !in_array( $screen->id, array( 'about', 'about-user', 'about-network' ) ) && !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() {
-?>
-
-
-
-
-
-
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;
- case '_vp_config_post_meta_name_ignore':
- $val = $this->get_post_meta_name_ignore( true );
- update_option( '_vp_config_post_meta_name_ignore', $val );
- break;
- case '_vp_config_should_ignore_files':
- $val = $this->get_should_ignore_files( true );
- update_option( '_vp_config_should_ignore_files', $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 ) );
- }
-
- // post meta name patterns to ignore
- function get_post_meta_name_ignore( $return_defaults = false ) {
- $defaults = array(
- 'pvc_views'
- );
- if ( $return_defaults )
- return $defaults;
- $ignore_names = $this->get_config( '_vp_config_post_meta_name_ignore' );
- return array_unique( array_merge( $defaults, $ignore_names ) );
- }
-
- // file name patterns to ignore
- function get_should_ignore_files( $return_defaults = false ) {
- $defaults = array(
- '@.*/404\.log\.txt$@',
- '@.*/\.DS_Store$@',
- '@.*/debug\.log$@',
- '@.*\.timthumb\.txt$@',
- '@.*timthumb[A-Za-z0-9]*$@',
- '@.*wp-content/contents/cache/@',
- '@.*wp-content/content/cache/@',
- '@.*wp-content/cache/@',
- '@.*wp-content/old-cache/@',
- '@.*cache/@',
- '@.*wp-content/w3tc/@',
- '@.*owa/owa-data/caches/@',
- '@.*gt-cache@',
- '@.*/wpclicks/tracker/cache/@',
- '@.*amember/data/new_rewrite@',
- '@.*sucuri/blocks/@',
- '@.*/_sucuribackup.*@',
- '@.*sess_[0-9a-zA-Z]{32,}@',
- '@.*wp-content/backups.*@',
- '@.*wp-content/backupwordpress@',
- '@.*wp-content/backup-[0-9a-zA-Z]+@',
- '@.*wp-content/[0-9a-zA-Z]+-backups@',
- '@.*mwp_backups/@',
- '@.*managewp/backups/@',
- '@.*wp-snapshots/@',
- '@.*error_log.*@',
- '@.*/error-log.*@',
- '@.*/error\.log$@',
- '@.*/captcha/tmp.*@',
- '@.*\.mt_backup_[0-9a-z:_]*$@i',
- '@.*vp-uploaded-restore-.*@',
- );
- if ( $return_defaults )
- return $defaults;
- $ignore_names = (array) $this->get_config( '_vp_config_should_ignore_files' );
- 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='' ) {
- if ( in_array( $meta_key, $this->get_post_meta_name_ignore() ) )
- return;
-
- $this->add_ping( 'db', array( 'postmeta' => $meta_id ) );
- }
-
- function postmeta_modification_handler( $meta_id, $object_id, $meta_key, $meta_value ) {
- if ( in_array( $meta_key, $this->get_post_meta_name_ignore() ) )
- return;
-
- 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, $post_id = null, $meta_key = null ) {
- if ( in_array( $meta_key, $this->get_post_meta_name_ignore() ) )
- return;
-
- 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;
- $status = $wpdb->get_row( $wpdb->prepare( "SHOW TABLE STATUS WHERE Name = %s", $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 request_firewall_update( $external_services = false ) {
- $args = array( 'timeout' => $this->get_option( 'timeout' ), 'sslverify' => true );
- $hostname = $this->get_option( 'hostname' );
- $path = $external_services ? 'service-ips-external' : 'service-ips';
-
- $data = false;
- $https_error = null;
- $retry = 2;
- do {
- $retry--;
- $protocol = 'http';
- $args['sslverify'] = 'https' == $protocol ? true : false;
- $r = wp_remote_get( $url=sprintf( "%s://%s/%s", $protocol, $hostname, $path ), $args );
- if ( 200 == wp_remote_retrieve_response_code( $r ) ) {
- if ( 99 == $this->get_option( 'connection_error_code' ) )
- $this->clear_connection();
- $data = @unserialize( wp_remote_retrieve_body( $r ) );
- break;
- }
- if ( 'https' == $protocol )
- $https_error = $r;
- usleep( 100 );
- } while( $retry > 0 );
-
- $r_code = wp_remote_retrieve_response_code( $https_error );
- if ( 0 == $retry && 200 != $r_code ) {
- $error_message = sprintf( 'Unexpected HTTP response code %s', $r_code );
- if ( false === $r_code )
- $error_message = 'Unable to find an HTTP transport that supports SSL verification';
- elseif ( is_wp_error( $https_error ) )
- $error_message = $https_error->get_error_message();
-
- $this->update_option( 'connection', time() );
- $this->update_option( 'connection_error_code', 99 );
- $this->update_option( 'connection_error_message', sprintf( __('Warning: The VaultPress plugin is using an insecure protocol because it cannot verify the identity of the VaultPress server. Please contact your hosting provider, and ask them to check that SSL certificate verification is correctly configured on this server. The request failed with the following error: "%s". If you’re still having issues please contact the VaultPress Safekeepers .', 'vaultpress' ), esc_html( $error_message ), 'http://vaultpress.com/contact/' ) );
- }
-
- return $data;
- }
-
- function update_firewall() {
- $data = $this->request_firewall_update();
- if ( $data ) {
- $newval = array( 'updated' => time(), 'data' => $data );
- $this->update_option( 'service_ips', $newval );
- }
-
- $external_data = $this->request_firewall_update( true );
- if ( $external_data ) {
- $external_newval = array( 'updated' => time(), 'data' => $external_data );
- update_option( 'vaultpress_service_ips_external', $external_newval );
- }
-
- if ( !empty( $data ) && !empty( $external_data ) )
- $data = array_merge( $data, $external_data );
-
- if ( $data ) {
- return $data;
- } else {
- return null;
- }
- }
-
- // Update local cache of VP plan settings, based on a ping or connection test result
- function update_plan_settings( $message ) {
- if ( array_key_exists( 'do_backups', $message ) )
- $this->update_option( 'do_not_backup', ( false === $message['do_backups'] ) );
-
- if ( array_key_exists( 'do_backup_pings', $message ) )
- $this->update_option( 'do_not_send_backup_pings', ( false === $message['do_backup_pings'] ) );
- }
-
- 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_plan_settings( $connect );
-
- 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 get_login_tokens() {
- // By default the login token is valid for 30 minutes.
- $nonce_life = $this->get_option( 'nonce_life' ) ? $this->get_option( 'nonce_life' ) : 1800;
- $salt = wp_salt( 'nonce' ) . md5( $this->get_option( 'secret' ) );
- $nonce_life /= 2;
-
- return array(
- 'previous' => substr( hash_hmac( 'md5', 'vp-login' . ceil( time() / $nonce_life - 1 ), $salt ), -12, 10 ),
- 'current' => substr( hash_hmac( 'md5', 'vp-login' . ceil( time() / $nonce_life ), $salt ), -12, 10 ),
- );
- }
- function add_js_token() {
- $nonce = $this->get_login_tokens();
- $token = $nonce['current'];
-
- // Uglyfies the JS code before sending it to the browser.
- $whitelist = array( 'charAt', 'all', 'setAttribute', 'document', 'createElement', 'appendChild', 'input', 'hidden', 'type', 'name', 'value', 'getElementById', 'loginform', '_vp' );
- shuffle( $whitelist );
- $whitelist = array_flip( $whitelist );
-
- $set = array(
- 0 => array( '+[]', 'e^e' ),
- 1 => array( '+!![]', '2>>1', "e[{$whitelist['type']}].charCodeAt(3)>>6" ),
- 2 => array( '(+!![])<<1', "e[{$whitelist['_vp']}].replace(/_/,'').length" ),
- 3 => array( "(Math.log(2<<4)+[])[e[{$whitelist['charAt']}]](0)", "e[{$whitelist['_vp']}].length" ),
- 4 => array( '(+!![])<<2', "e[{$whitelist['input']}].length^1", "e[{$whitelist['name']}].length" ),
- 5 => array( '((1<<2)+1)', 'parseInt("f",0x10)/3' ),
- 6 => array( '(7^1)', "e[{$whitelist['hidden']}].length" ),
- 7 => array( '(3<<1)+1', "e[{$whitelist['hidden']}].length^1" ),
- 8 => array( '(0x101>>5)', "e[{$whitelist['document']}].length" ),
- 9 => array( '(0x7^4)*(3+[])', "e[{$whitelist['loginform']}].length", "(1< array( "(![]+\"\")[e[{$whitelist['charAt']}]](1)", "e[{$whitelist['appendChild']}][e[{$whitelist['charAt']}]](0)", "e[{$whitelist['name']}][e[{$whitelist['charAt']}]](1)" ),
- 'b' => array( "([]+{})[e[{$whitelist['charAt']}]](2)", "({}+[])[e[{$whitelist['charAt']}]](2)" ),
- 'c' => array( "([]+{})[e[{$whitelist['charAt']}]](5)", "e[{$whitelist['createElement']}][e[{$whitelist['charAt']}]](0)" ),
- 'd' => array( "([][0]+\"\")[e[{$whitelist['charAt']}]](2)", "([][0]+[])[e[{$whitelist['charAt']}]](2)" ),
- 'e' => array( "(!![]+[])[e[{$whitelist['charAt']}]](3)", "(!![]+\"\")[e[{$whitelist['charAt']}]](3)" ),
- 'f' => array( "(![]+[])[e[{$whitelist['charAt']}]](0)", "([]+![])[e[{$whitelist['charAt']}]](e^e)", "([]+![])[e[{$whitelist['charAt']}]](0)" ),
- );
-
- $js_code = <<
-JS;
- $chars = array();
- for ( $i = 0; $i < strlen( $token ); $i++ ) {
- if ( isset( $set[$token{$i}] ) ) {
- $k = array_rand( $set[$token{$i}], 1 );
- $chars[] = $set[$token{$i}][$k];
- } else {
- $chars[] = $token{$i};
- }
- }
- $random = array_unique( $chars );
- shuffle( $random );
- $random = array_flip( $random );
-
- foreach( $chars as $i => $v )
- $chars[$i] = sprintf( '_[%d]', $random[$v] );
-
- $code = preg_replace(
- "#[\n\r\t]#",
- '',
- sprintf( $js_code,
- join( '|', array_keys( $whitelist ) ),
- join( ',', array_keys( $random ) ),
- join( '+"")+(', $chars )
- )
- );
- echo $code;
- }
-
- function authenticate( $user, $username, $password ) {
- if ( is_wp_error( $user ) )
- return $user;
- if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST || defined( 'APP_REQUEST' ) && APP_REQUEST ) {
- // Try to log in with the username and password.
- }
- $retval = $user;
- if ( empty( $_POST['_vptrue'] ) || !in_array( $_POST['_vptrue'], $this->get_login_tokens(), true ) )
- $retval = new WP_Error( 'invalid_token', __( 'Invalid token. Please try to log in again.' ) );
-
- return $retval;
- }
-
- 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;
- }
-
- $this->update_plan_settings( $_POST );
-
- $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'] ) ) {
- $parse_create_table = isset( $_POST['use_new_hash'] ) && $_POST['use_new_hash'] ? true : false;
- $bdb->attach( base64_decode( $_POST['table'] ), $parse_create_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;
-
- if ( isset( $_POST['full_list'] ) )
- $full_list = (bool)$_POST['full_list'];
- else
- $full_list = 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, $full_list ) );
- }
- 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'] ) ) {
- if ( is_string( $_POST['signature'] ) ) {
- $sig = $_POST['signature'];
- } else {
- $__vp_validate_error = array( 'error' => 'invalid_signature_format' );
- return false;
- }
- } 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' );
- $service_ips_external = get_option( 'vaultpress_service_ips_external' );
- if ( !empty( $rxs['data'] ) && !empty( $service_ips_external['data'] ) )
- $rxs['data'] = array_merge( $rxs['data'], $service_ips_external['data'] );
- 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 || !isset( $sig[0] ) || !isset( $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' );
- 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':
- $_keys = array_keys( $data );
- $subtype = array_shift( $_keys );
- 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' ), 5 ); # Priority 5, so it's called before Jetpack's 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' ), 10, 3 );
- add_action( 'update_postmeta', array( $this, 'postmeta_action_handler' ), 10, 3 );
- add_action( 'delete_postmeta', array( $this, 'postmeta_action_handler' ), 10, 3 );
-
- // 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() {
- // Log ins
- if ( $this->get_option( 'login_lockdown' ) ) {
- add_action( 'login_form', array( $this, 'add_js_token' ) );
- add_filter( 'authenticate', array( $this, 'authenticate' ), 999 );
- }
-
- // 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 72ca9f46..00000000
--- a/plugins/vaultpress/vp-scanner.php
+++ /dev/null
@@ -1,153 +0,0 @@
-last_dir = $this->path = @realpath( $path );
- else
- $this->last_dir = $this->path = dirname( @realpath( $path ) );
- $this->ignore_symlinks = $ignore_symlinks;
- }
-
- 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( '#(?ignore_symlinks && is_link( $full_entry ) )
- continue;
-
- if ( rtrim( $last_dir, DIRECTORY_SEPARATOR ) == rtrim( $path, DIRECTORY_SEPARATOR ) ) {
- // Reset last_dir and offset when we reached the previous last_dir value.
- $last_dir = '';
- $offset = 0;
- }
-
- if ( is_file( $full_entry ) ) {
- if ( !vp_is_interesting_file( $full_entry ) )
- continue;
- $_return_offset = $_offset;
- $_return_dir = dirname( $full_entry );
- $files[] = $full_entry;
- } elseif ( is_dir( $full_entry ) ) {
- list( $_return_offset, $_return_dir ) = $this->_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;
-
- if ( !isset( $GLOBALS['vp_signatures'] ) )
- $GLOBALS['vp_signatures'] = array();
-
- $found = array ();
- foreach ( $GLOBALS['vp_signatures'] as $signature ) {
- if ( !is_object( $signature ) || !isset( $signature->patterns ) )
- continue;
- // 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;
- $matches = array ();
- if ( is_array( $file_content ) && ( $signature->patterns ) && is_array( $signature->patterns ) ) {
- reset( $signature->patterns );
- while ( $is_vulnerable && list( , $pattern ) = each( $signature->patterns ) ) {
- if ( ! $match = preg_grep( '#' . addcslashes( $pattern, '#' ) . '#im', $file_content ) ) {
- $is_vulnerable = false;
- break;
- }
- $matches += $match;
- }
- } else {
- $is_vulnerable = false;
- }
- $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 06a2b4ad..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)
-
-
-
-
-
diff --git a/sites.php b/sites.php
index 54f335d2..1d45eb42 100644
--- a/sites.php
+++ b/sites.php
@@ -5,348 +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',
- 'description' => 'jQuery: The Write Less, Do More, JavaScript Library',
'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',
- 'logo_link' => 'https://jquery.com/',
'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',
- '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.',
+ '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',
- 'logo_link' => 'https://jqueryui.com/',
'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',
- 'logo_link' => 'https://jqueryui.com/',
'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',
- 'logo_link' => 'https://jqueryui.com/',
'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',
),
- ),
- ),
- 'qunitjs.com' => array(
- 'blog_id' => 10,
- 'cookie_domain' => '.qunitjs.com',
- 'body_class' => 'qunitjs',
- 'options' => array(
- 'blogname' => 'QUnit',
- 'description' => 'QUnit: A JavaScript Unit Testing framework.',
- 'stylesheet' => 'qunitjs.com',
- 'active_plugins' => array(
- 'jquery-static-index.php',
- ),
- ),
- ),
- 'sizzlejs.com' => array(
- 'blog_id' => 11,
- 'cookie_domain' => '.sizzlejs.com',
- 'body_class' => 'sizzlejs',
- 'options' => array(
- 'blogname' => 'Sizzle JS',
- 'stylesheet' => 'sizzlejs.com',
- 'active_plugins' => array(
- 'jquery-static-index.php',
- ),
+ 'jquery_body_class' => 'jquery-foundation',
),
),
'jquerymobile.com' => array(
- 'blog_id' => 12,
'cookie_domain' => '.jquerymobile.com',
- 'body_class' => 'jquery-mobile',
'options' => array(
'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',
),
),
'api.jquerymobile.com' => array(
- 'subsites' => 1, // Has one level of sub-sites (api.jquerymobile.com/([^/]+))
- 'blog_id' => 13,
+ 'subsites' => true, // Has one level of sub-sites (api.jquerymobile.com/([^/]+))
'cookie_domain' => '.jquerymobile.com',
- 'body_class' => 'jquery-mobile',
- 'logo_link' => 'https://jquerymobile.com/',
'options' => array(
'blogname' => 'jQuery Mobile API Documentation',
'stylesheet' => 'api.jquerymobile.com',
- 'active_plugins' => array(),
- ),
- ),
- 'api.qunitjs.com' => array(
- 'blog_id' => 14,
- 'cookie_domain' => '.qunitjs.com',
- 'body_class' => 'qunitjs',
- 'logo_link' => 'https://qunitjs.com/',
- 'options' => array(
- 'blogname' => 'QUnit API Documentation',
- 'stylesheet' => 'api.qunitjs.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',
),
),
- 'books.jquery.com' => array(
- 'blog_id' => 15,
- 'cookie_domain' => '.jquery.com',
- 'body_class' => 'jquery',
- 'options' => array(
- 'blogname' => 'jQuery Books',
- 'stylesheet' => 'books.jquery.com',
- ),
- ),
- 'events.jquery.org' => array(
- 'blog_id' => 16,
- 'cookie_domain' => '.jquery.org',
- 'body_class' => 'jquery-foundation jquery-events',
+ 'blog.jquerymobile.com' => array(
+ 'cookie_domain' => '.jquerymobile.com',
'options' => array(
- 'blogname' => 'jQuery Events',
- 'stylesheet' => 'events.jquery.org',
- 'active_plugins' => array(
- 'allow-numeric-stubs/allow-numeric-stubs.php',
- 'jquery-static-index.php',
- ),
+ '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(
- 'blog_id' => 18,
'cookie_domain' => '.jquery.org',
- 'body_class' => 'jquery-foundation',
'options' => array(
'blogname' => 'jQuery Brand Guidelines',
'stylesheet' => 'brand.jquery.org',
'active_plugins' => array(
'jquery-static-index.php',
),
+ 'jquery_body_class' => 'jquery-foundation',
),
),
'contribute.jquery.org' => array(
- 'blog_id' => 19,
'cookie_domain' => '.jquery.org',
- 'body_class' => 'jquery-foundation',
'options' => array(
'blogname' => 'Contribute to jQuery',
'stylesheet' => 'contribute.jquery.org',
'active_plugins' => array(
'jquery-static-index.php',
),
- ),
- ),
- 'irc.jquery.org' => array(
- 'blog_id' => 20,
- 'cookie_domain' => '.jquery.org',
- 'body_class' => 'jquery-foundation',
- 'options' => array(
- 'blogname' => 'jQuery IRC Center',
- 'stylesheet' => 'irc.jquery.org',
- 'active_plugins' => array(
- 'jquery-static-index.php',
- ),
+ 'jquery_body_class' => 'jquery-foundation',
),
),
'meetings.jquery.org' => array(
- 'blog_id' => 22,
'cookie_domain' => '.jquery.org',
- 'body_class' => 'jquery-foundation',
'options' => array(
'blogname' => 'jQuery Meetings',
'stylesheet' => 'meetings.jquery.org',
'active_plugins' => array(
'jquery-static-index.php',
),
- ),
- ),
- 'codeorigin.jquery.com' => array(
- 'blog_id' => 23,
- 'cookie_domain' => '.jquery.com',
- 'body_class' => 'jquery',
- 'options' => array(
- 'blogname' => 'jQuery CDN',
- 'stylesheet' => 'codeorigin.jquery.com',
- 'active_plugins' => array(
- 'jquery-static-index.php',
- ),
+ 'jquery_body_class' => 'jquery-foundation',
),
),
'api.jquerymobile.com/1.3' => array(
- 'blog_id' => 24,
'cookie_domain' => '.jquerymobile.com',
- 'body_class' => 'jquery-mobile',
- 'logo_link' => 'https://jquerymobile.com/',
'options' => array(
'blogname' => 'jQuery Mobile 1.3 Documentation',
'stylesheet' => 'api.jquerymobile.com',
- 'active_plugins' => array(),
+ '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(
- 'blog_id' => 25,
'cookie_domain' => '.jqueryui.com',
- 'body_class' => 'jquery-ui',
- 'logo_link' => 'https://jqueryui.com/',
'options' => array(
'blogname' => 'jQuery UI 1.10 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.12' => array(
- 'blog_id' => 26,
'cookie_domain' => '.jqueryui.com',
- 'body_class' => 'jquery-ui',
- 'logo_link' => 'https://jqueryui.com/',
'options' => array(
'blogname' => 'jQuery UI 1.12 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.11' => array(
- 'blog_id' => 27,
'cookie_domain' => '.jqueryui.com',
- 'body_class' => 'jquery-ui',
- 'logo_link' => 'https://jqueryui.com/',
'options' => array(
'blogname' => 'jQuery UI 1.11 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.jquerymobile.com/1.4' => array(
- 'blog_id' => 28,
'cookie_domain' => '.jquerymobile.com',
- 'body_class' => 'jquery-mobile',
- 'logo_link' => 'https://jquerymobile.com/',
'options' => array(
'blogname' => 'jQuery Mobile 1.4 Documentation',
'stylesheet' => 'api.jquerymobile.com',
- 'active_plugins' => array(),
+ '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',
+ ),
+ ),
+ 'releases.jquery.com' => array(
+ 'cookie_domain' => '.jquery.com',
+ 'options' => array(
+ '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',
+ ),
+ ),
+ 'api.jqueryui.com/1.13' => array(
+ 'cookie_domain' => '.jqueryui.com',
+ 'options' => array(
+ 'blogname' => 'jQuery UI 1.13 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',
+ ),
+ ),
+ '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.' );
- 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 72063820..00000000
--- a/sunrise.php
+++ /dev/null
@@ -1,67 +0,0 @@
-id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
- $current_site->blog_id = defined( 'BLOG_ID_CURRENT_SITE' ) ? BLOG_ID_CURRENT_SITE : 1;
- $current_site->cookie_domain = defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '.jquery.com';
- $current_site->domain = DOMAIN_CURRENT_SITE;
- $current_site->path = PATH_CURRENT_SITE;
- $current_site->site_name = 'jQuery';
-}
-
-if ( isset( $blog_id ) ) {
- $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) );
-
- // If for some reason this became a multi-network configuration, populate the site's network.
- if ( is_object( $current_blog ) && $current_blog->site_id != $current_site->id ) {
- $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * from $wpdb->site WHERE id = %d LIMIT 0,1", $current_blog->site_id ) );
- $current_site->site_name = 'jQuery';
- }
-
- // 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 @@
+ "1.7 and newer",
- "1.11" => "1.6 and newer",
- "1.10" => "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",
);
}
@@ -22,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/index.php b/themes/api.jqueryui.com/index.php
index 9f65b2a9..f72eaddb 100644
--- a/themes/api.jqueryui.com/index.php
+++ b/themes/api.jqueryui.com/index.php
@@ -50,7 +50,7 @@
category from the sidebar.
jQuery UI
- supports jQuery .
+ supports .
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 84dae1f2..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/brand.jquery.org/style.css b/themes/brand.jquery.org/style.css
index 6c995cbc..1df088b7 100644
--- a/themes/brand.jquery.org/style.css
+++ b/themes/brand.jquery.org/style.css
@@ -15,39 +15,21 @@ Template: jquery
/* Headlines */
#content h2 {
- font-size: 30px;
- line-height: 1.8;
- color: #333;
text-transform: uppercase;
- margin-bottom: 20px;
-}
-#content h3 {
- font-size: 22px;
- line-height: 1.5;
- color: #444;
}
#content h4 {
font-size: 18px;
- line-height: 1.2;
}
-#banner-secondary.large-banner h1,
+#banner-secondary.large-banner h1,
#banner-secondary.large-banner h2 {
font-size: 42px;
text-transform: uppercase;
}
-h6.h-klavika {
- font-size: 46px;
- line-height: 1.2;
- margin-bottom: 30px;
-}
-h6.h-klavika em {
- color: #333;
-}
-
-h6.h-helvetica {
- font: 400 46px/1.2 Helvetica, "Helvetica Neue", Arial, sans-serif !important;
- margin-bottom: 30px;
+#content .h-h1-size {
+ font-weight: bold;
+ line-height: 36px;
+ font-size: 36px;
}
/* Color Swatches */
@@ -57,19 +39,18 @@ h6.h-helvetica {
color: #fff;
padding: 20px;
}
-.color * {
- opacity: 0.9;
-}
-#content .color h6 {
- font: 800 14px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif !important;
- margin-bottom: 4px;
+#content .color h3 {
+ color: inherit;
}
#content .color ul {
margin: 0;
padding: 0;
}
+#content .color li::marker {
+ content: "";
+}
#content .color li {
- list-style-type: none;
+ list-style: none;
background: none;
margin: 0;
padding: 0;
@@ -78,9 +59,6 @@ h6.h-helvetica {
}
/* Misc Content */
-p {
- font: 16px/1.5 Helvetica, "Helvetica Neue", Arial, sans-serif;
-}
.figcaption {
padding-top: 20px;
padding-bottom: 20px;
@@ -89,7 +67,7 @@ p {
#banner-secondary p {
padding-left: 0;
color: #fff;
-}
+}
hr {
display: block;
clear: both;
@@ -102,17 +80,13 @@ a {
}
/* Buttons */
-a.button, #content a.button, .button, input[type="submit"] {
+#content .button,
+#content a.button {
float: none;
display: inline-block;
}
/* Helpers */
-.db {
- display: inline-block;
- float: none !important;
- clear: both;
-}
.p-small {
padding-bottom: 20px;
}
\ No newline at end of file
diff --git a/themes/contribute.jquery.org/cla-check.php b/themes/contribute.jquery.org/cla-check.php
deleted file mode 100644
index f75656cd..00000000
--- a/themes/contribute.jquery.org/cla-check.php
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-owner = $owner;
- $data->repo = $repo;
- return $data;
-}
-
-// The web hook used to only log the audit result, not the full data.
-// So we normalize old data to the new format
-function normalizeData( $data ) {
-
- // Since we didn't store error info before, errors got logged as undefined,
- // which come across as null in PHP
- if ( is_null( $data ) ) {
- return (object) array(
- 'error' => 'Unknown error'
- );
- }
-
- // If we're missing the fully structured data, just move the audit result
- // to the proper location
- if ( !empty( $data->commits ) ) {
- return (object) array( 'data' => $data );
- }
-
- // We have proper data, just return it as is
- return $data;
-}
-
-function validateData( $data ) {
- if ( is_null( $data ) ) {
- global $wp_query;
- $wp_query->set_404();
- status_header(404);
- get_template_part( 404 );
- exit();
- }
-}
-
-function getProcessedPost( $data ) {
- the_post();
- $content = get_the_content();
-
- if ( !empty( $data->error ) ) {
- $content = preg_replace( '/.*/s', '', $content );
- $content = preg_replace( '/.*/s', '', $content );
- $content = preg_replace(
- '//',
- '' . htmlspecialchars( $data->error ) . ' ',
- $content
- );
-
- return $content;
- }
-
- if ( count( $data->data->neglectedAuthors ) ) {
- $content = preg_replace( '/.*/s', '', $content );
- $content = preg_replace( '//', neglectedAuthors( $data ), $content );
- } else {
- $content = preg_replace( '/.*/s', '', $content );
- }
-
- $content = preg_replace( '/.*/s', '', $content );
- $content = preg_replace( '//', commitLog( $data ), $content );
-
- return $content;
-}
-
-function neglectedAuthors( $data ) {
- $html = "\n";
- foreach ( $data->data->neglectedAuthors as $author ) {
- $html .= "" . htmlspecialchars( "$author->name <$author->email>" );
- if ( count( $author->errors ) ) {
- $html .= ": ";
- foreach( $author->errors as $error ) {
- $html .= htmlspecialchars( " $error" );
- }
- }
- $html .= " \n";
- }
- $html .= " \n";
- return $html;
-}
-
-function commitLog( $data ) {
- $commitPrefix = "https://github.com/" .
- htmlspecialchars( "$data->owner/$data->repo" ) .
- "/commit/";
-
- $html = "\n";
- foreach ( $data->data->commits as $commit ) {
- $escapedHash = htmlspecialchars( $commit->hash );
- $html .= "$escapedHash \n";
- $html .= "" . htmlspecialchars( "$commit->name <$commit->email>" ) . " \n";
- }
- $html .= " \n";
- return $html;
-}
diff --git a/themes/contribute.jquery.org/functions.php b/themes/contribute.jquery.org/functions.php
new file mode 100644
index 00000000..d5b39a4e
--- /dev/null
+++ b/themes/contribute.jquery.org/functions.php
@@ -0,0 +1,8 @@
+
-
-
-
-
-
-
-
-
-