From 3b29d6e241843d307efa29e383c4f20c5752ae6a Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Sun, 6 Dec 2015 21:30:08 +0100 Subject: [PATCH 001/117] Add option not to disable ElasticPress while indexing --- bin/wp-cli.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 848b72328f..fe7d58e2a5 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -181,7 +181,7 @@ private function _create_network_alias() { /** * Index all posts for a site or network wide * - * @synopsis [--setup] [--network-wide] [--posts-per-page] [--no-bulk] [--offset] [--show-bulk-errors] [--post-type] + * @synopsis [--setup] [--network-wide] [--posts-per-page] [--no-bulk] [--offset] [--show-bulk-errors] [--post-type] [--keep-active] * @param array $args * * @since 0.1.2 @@ -209,6 +209,15 @@ public function index( $args, $assoc_args ) { $total_indexed = 0; + $keep_active = false; + if ( + isset( $assoc_args['keep-active'] ) && + true === $assoc_args['keep-active'] && + ( ! isset( $assoc_args['setup'] ) || false === $assoc_args['setup'] ) + ) { + $keep_active = true; + } + /** * Prior to the index command invoking * Useful for deregistering filters/actions that occur during a query request @@ -218,7 +227,9 @@ public function index( $args, $assoc_args ) { do_action( 'ep_wp_cli_pre_index', $args, $assoc_args ); // Deactivate our search integration - $this->deactivate(); + if ( ! $keep_active ) { + $this->deactivate(); + } timer_start(); From ac6bd2f8a9b7a4038cf1405106bc5061d54045ce Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Wed, 23 Dec 2015 22:53:02 +0100 Subject: [PATCH 002/117] Updated README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1286f9c18e..b62ddf8771 100644 --- a/README.md +++ b/README.md @@ -489,7 +489,7 @@ The following are special parameters that are only supported by ElasticPress. The following commands are supported by ElasticPress: -* `wp elasticpress index [--setup] [--network-wide] [--posts-per-page] [--no-bulk] [--offset] [--show-bulk-errors] [--post-type]` +* `wp elasticpress index [--setup] [--network-wide] [--posts-per-page] [--no-bulk] [--offset] [--show-bulk-errors] [--post-type] [--keep-active]` Index all posts in the current blog. @@ -500,6 +500,7 @@ The following commands are supported by ElasticPress: * `--offset` let's you skip the first n posts (don't forget to remove the `--setup` flag when resuming or the index will be emptied before starting again). * `--show-bulk-errors` displays the error message returned from Elasticsearch when a post fails to index (as opposed to just the title and ID of the post). * `--post-type` let's you specify which post types will be indexed (by default: all indexable post types are indexed). For example, `--post-type="my_custom_post_type"` would limit indexing to only posts from the post type "my_custom_post_type". Accepts multiple post types separated by comma. + * `--keep-active` let's you keep ElasticPress active during indexing (cannot be used with --setup). * `wp elasticpress activate` From a6ac25b0a5b24105ead2e0080aba3dc609d683dc Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Wed, 20 Jan 2016 18:30:09 +0100 Subject: [PATCH 003/117] Refactored code --- bin/wp-cli.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index fe7d58e2a5..c9ad18bb9e 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -209,15 +209,6 @@ public function index( $args, $assoc_args ) { $total_indexed = 0; - $keep_active = false; - if ( - isset( $assoc_args['keep-active'] ) && - true === $assoc_args['keep-active'] && - ( ! isset( $assoc_args['setup'] ) || false === $assoc_args['setup'] ) - ) { - $keep_active = true; - } - /** * Prior to the index command invoking * Useful for deregistering filters/actions that occur during a query request @@ -226,8 +217,13 @@ public function index( $args, $assoc_args ) { */ do_action( 'ep_wp_cli_pre_index', $args, $assoc_args ); - // Deactivate our search integration - if ( ! $keep_active ) { + // Deactivate ElasticPress if setup is set to true. + if ( + ! isset( $assoc_args['keep-active'] ) || + false === $assoc_args['keep-active'] || + ( isset( $assoc_args['setup'] ) && true === $assoc_args['setup'] ) + ) { + // Deactivate our search integration $this->deactivate(); } From 84aa75bcd54963ca77397299b3da0e48a222e35c Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:15:24 -0500 Subject: [PATCH 004/117] Removes composer.lock from repo and adds the beginnings of a proper .gitignore --- .gitignore | 1 + composer.lock | 581 -------------------------------------------------- 2 files changed, 1 insertion(+), 581 deletions(-) create mode 100644 .gitignore delete mode 100644 composer.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..2cf7a3ffde --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +composer.lock \ No newline at end of file diff --git a/composer.lock b/composer.lock deleted file mode 100644 index ab9b320469..0000000000 --- a/composer.lock +++ /dev/null @@ -1,581 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "332f73e3674c21dc09f838e8b7fff5b8", - "packages": [], - "packages-dev": [ - { - "name": "codeclimate/php-test-reporter", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/codeclimate/php-test-reporter.git", - "reference": "2dd8395f81874333d15de3a598f722997ba42fb5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/2dd8395f81874333d15de3a598f722997ba42fb5", - "reference": "2dd8395f81874333d15de3a598f722997ba42fb5", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3", - "satooshi/php-coveralls": "0.6.*", - "symfony/console": ">=2.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*@stable" - }, - "bin": [ - "composer/bin/test-reporter" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.1.x-dev" - } - }, - "autoload": { - "psr-0": { - "CodeClimate\\Component": "src/", - "CodeClimate\\Bundle": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Code Climate", - "email": "hello@codeclimate.com", - "homepage": "https://codeclimate.com" - } - ], - "description": "PHP client for reporting test coverage to Code Climate", - "homepage": "https://github.com/codeclimate/php-test-reporter", - "keywords": [ - "codeclimate", - "coverage" - ], - "time": "2014-12-29 16:17:04" - }, - { - "name": "guzzle/guzzle", - "version": "v3.9.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle3.git", - "reference": "54991459675c1a2924122afbb0e5609ade581155" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/54991459675c1a2924122afbb0e5609ade581155", - "reference": "54991459675c1a2924122afbb0e5609ade581155", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1" - }, - "replace": { - "guzzle/batch": "self.version", - "guzzle/cache": "self.version", - "guzzle/common": "self.version", - "guzzle/http": "self.version", - "guzzle/inflection": "self.version", - "guzzle/iterator": "self.version", - "guzzle/log": "self.version", - "guzzle/parser": "self.version", - "guzzle/plugin": "self.version", - "guzzle/plugin-async": "self.version", - "guzzle/plugin-backoff": "self.version", - "guzzle/plugin-cache": "self.version", - "guzzle/plugin-cookie": "self.version", - "guzzle/plugin-curlauth": "self.version", - "guzzle/plugin-error-response": "self.version", - "guzzle/plugin-history": "self.version", - "guzzle/plugin-log": "self.version", - "guzzle/plugin-md5": "self.version", - "guzzle/plugin-mock": "self.version", - "guzzle/plugin-oauth": "self.version", - "guzzle/service": "self.version", - "guzzle/stream": "self.version" - }, - "require-dev": { - "doctrine/cache": "~1.3", - "monolog/monolog": "~1.0", - "phpunit/phpunit": "3.7.*", - "psr/log": "~1.0", - "symfony/class-loader": "~2.1", - "zendframework/zend-cache": "2.*,<2.3", - "zendframework/zend-log": "2.*,<2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.9-dev" - } - }, - "autoload": { - "psr-0": { - "Guzzle": "src/", - "Guzzle\\Tests": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Guzzle Community", - "homepage": "https://github.com/guzzle/guzzle/contributors" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2014-08-11 04:32:36" - }, - { - "name": "psr/log", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-0": { - "Psr\\Log\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2012-12-21 11:40:51" - }, - { - "name": "satooshi/php-coveralls", - "version": "v0.6.1", - "source": { - "type": "git", - "url": "https://github.com/satooshi/php-coveralls.git", - "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", - "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "ext-simplexml": "*", - "guzzle/guzzle": ">=3.0", - "php": ">=5.3", - "psr/log": "1.0.0", - "symfony/config": ">=2.0", - "symfony/console": ">=2.0", - "symfony/stopwatch": ">=2.2", - "symfony/yaml": ">=2.0" - }, - "require-dev": { - "apigen/apigen": "2.8.*@stable", - "pdepend/pdepend": "dev-master", - "phpmd/phpmd": "dev-master", - "phpunit/php-invoker": ">=1.1.0,<1.2.0", - "phpunit/phpunit": "3.7.*@stable", - "sebastian/finder-facade": "dev-master", - "sebastian/phpcpd": "1.4.*@stable", - "squizlabs/php_codesniffer": "1.4.*@stable", - "theseer/fdomdocument": "dev-master" - }, - "bin": [ - "composer/bin/coveralls" - ], - "type": "library", - "autoload": { - "psr-0": { - "Contrib\\Component": "src/", - "Contrib\\Bundle": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kitamura Satoshi", - "email": "with.no.parachute@gmail.com", - "homepage": "https://www.facebook.com/satooshi.jp" - } - ], - "description": "PHP client library for Coveralls API", - "homepage": "https://github.com/satooshi/php-coveralls", - "keywords": [ - "ci", - "coverage", - "github", - "test" - ], - "time": "2013-05-04 08:07:33" - }, - { - "name": "symfony/config", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Config", - "source": { - "type": "git", - "url": "https://github.com/symfony/Config.git", - "reference": "84c0c150c1520995f09ea9e47e817068b353cb0f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/84c0c150c1520995f09ea9e47e817068b353cb0f", - "reference": "84c0c150c1520995f09ea9e47e817068b353cb0f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/filesystem": "~2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Config\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Config Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" - }, - { - "name": "symfony/console", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Console", - "source": { - "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "ef825fd9f809d275926547c9e57cbf14968793e8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ef825fd9f809d275926547c9e57cbf14968793e8", - "reference": "ef825fd9f809d275926547c9e57cbf14968793e8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/process": "~2.1" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Console\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Console Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.6.1", - "target-dir": "Symfony/Component/EventDispatcher", - "source": { - "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "720fe9bca893df7ad1b4546649473b5afddf0216" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/720fe9bca893df7ad1b4546649473b5afddf0216", - "reference": "720fe9bca893df7ad1b4546649473b5afddf0216", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.0", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/stopwatch": "~2.2" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" - }, - { - "name": "symfony/filesystem", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Filesystem", - "source": { - "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "ff6efc95256cb33031933729e68b01d720b5436b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/ff6efc95256cb33031933729e68b01d720b5436b", - "reference": "ff6efc95256cb33031933729e68b01d720b5436b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" - }, - { - "name": "symfony/stopwatch", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Stopwatch", - "source": { - "type": "git", - "url": "https://github.com/symfony/Stopwatch.git", - "reference": "261abd360cfb6ac65ea93ffd82073e2011d034fc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/261abd360cfb6ac65ea93ffd82073e2011d034fc", - "reference": "261abd360cfb6ac65ea93ffd82073e2011d034fc", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Stopwatch\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Stopwatch Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" - }, - { - "name": "symfony/yaml", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/3346fc090a3eb6b53d408db2903b241af51dcb20", - "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "codeclimate/php-test-reporter": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.2" - }, - "platform-dev": [] -} From 826205cfdb0900b8f7937b866603cb7bcdf0da6d Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:24:37 -0500 Subject: [PATCH 005/117] Ensures both PHPUnit and WP-CLI are available allowing a simplification of the development environment. --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e276215b0f..5665f3666b 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,8 @@ "php": ">=5.2" }, "require-dev": { - "codeclimate/php-test-reporter": "dev-master" + "codeclimate/php-test-reporter": "dev-master", + "phpunit/phpunit": "*@stable", + "wp-cli/wp-cli": "master" } } From e4fb24fefcb2333907b107294c1f6969e7871d28 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Fri, 20 Nov 2015 10:08:16 -0500 Subject: [PATCH 006/117] Import the settings class from Jovo --- classes/class-ep-settings.php | 388 ++++++++++++++++++++++++++++++++++ 1 file changed, 388 insertions(+) create mode 100644 classes/class-ep-settings.php diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php new file mode 100644 index 0000000000..866497a48e --- /dev/null +++ b/classes/class-ep-settings.php @@ -0,0 +1,388 @@ + + */ + +/** + * Jovosearch Settings Page + * + * Sets up the settings page to handle ElasticPress configuration. + */ +class Jovo_Settings { + + /** + * WordPress options page + * + * @since 0.1.0 + * + * @var object + */ + var $options_page; + + /** + * Register WordPress hooks + * + * Loads initial actions. + * + * @since 0.1.0 + * + * @return Jovo_Settings + */ + public function __construct() { + + Jovo_Lib::set_api_key(); + Jovo_Lib::check_host(); + + if ( is_multisite() ) { // Must be network admin in multisite. + + add_action( 'network_admin_menu', array( $this, 'action_admin_menu' ) ); + + } else { + + add_action( 'admin_menu', array( $this, 'action_admin_menu' ) ); + + } + + // Add JavaScripts. + add_action( 'admin_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts' ) ); + + add_action( 'admin_init', array( $this, 'action_admin_init' ) ); + + } + + /** + * Register and Enqueue JavaScripts + * + * Registers and enqueues the necessary JavaScripts for the interface. + * + * @since 0.1.0 + * + * @return void + */ + public function action_admin_enqueue_scripts() { + + // Enqueue more easily debugged version if applicable. + if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { + + wp_register_script( 'jovo_admin', JOVO_URL . 'assets/js/jovosearch-admin.js', array( 'jquery' ), JOVO_VERSION ); + + wp_register_style( 'jovo_progress_style', JOVO_URL . 'assets/css/jquery-ui.css', array(), JOVO_VERSION ); + wp_register_style( 'jovo_styles', JOVO_URL . 'assets/css/jovosearch.css', array(), JOVO_VERSION ); + + } else { + + wp_register_script( 'jovo_admin', JOVO_URL . 'assets/js/jovosearch-admin.min.js', array( 'jquery' ), JOVO_VERSION ); + + wp_register_style( 'jovo_progress_style', JOVO_URL . 'assets/css/jquery-ui.min.css', array(), JOVO_VERSION ); + wp_register_style( 'jovo_styles', JOVO_URL . 'assets/css/jovosearch.min.css', array(), JOVO_VERSION ); + + } + + // Only add the following to the settings page. + if ( isset( get_current_screen()->id ) && strpos( get_current_screen()->id, 'settings_page_elasticpress' ) !== false ) { + + wp_enqueue_style( 'jovo_progress_style' ); + wp_enqueue_style( 'jovo_styles' ); + + wp_enqueue_script( 'jovo_admin' ); + + } + } + + /** + * Admin-init actions + * + * Sets up Settings API. + * + * @since 0.1.0 + * + * @return void + */ + public function action_admin_init() { + + //Save options for multisite + if ( is_multisite() && ( isset( $_POST['jovo_host'] ) || isset( $_POST['jovo_activate'] ) ) ) { + + if ( ! check_admin_referer( 'jovosearch-options' ) ) { + die( esc_html__( 'Security error!', 'jovosearch' ) ); + } + + if ( isset( $_POST['jovo_host'] ) ) { + + $host = $this->sanitize_jovo_host( $_POST['jovo_host'] ); + update_site_option( 'jovo_host', $host ); + + } + + if ( isset( $_POST['jovo_api_key'] ) ) { + + $host = sanitize_text_field( $_POST['jovo_api_key'] ); + update_site_option( 'jovo_api_key', $host ); + + } + + if ( isset( $_POST['jovo_activate'] ) ) { + + $this->sanitize_jovo_activate( $_POST['jovo_activate'] ); + + } else { + + $this->sanitize_jovo_activate( false ); + + } + } + + add_settings_section( 'jovo_settings_section_main', '', array( $this, 'jovo_settings_section_hightlight' ), 'jovosearch' ); + + if ( is_wp_error( Jovo_Lib::check_host() ) || get_site_option( 'jovo_host' ) ) { + + add_settings_field( 'jovo_host', esc_html__( 'ElasticSearch Host:', 'jovosearch' ), array( $this, 'setting_callback_host' ), 'jovosearch', 'jovo_settings_section_main' ); + add_settings_field( 'jovo_api_key', esc_html__( 'ElasticPress API Key:', 'jovosearch' ), array( $this, 'setting_callback_api_key' ), 'jovosearch', 'jovo_settings_section_main' ); + + } + + $stats = Jovo_Lib::ep_get_index_status(); + + if ( $stats['status'] && ! is_wp_error( Jovo_Lib::check_host() ) ) { + + add_settings_field( 'jovo_activate', esc_html__( 'Use ElasticSearch:', 'jovosearch' ), array( $this, 'setting_callback_activate' ), 'jovosearch', 'jovo_settings_section_main' ); + + } + + register_setting( 'jovosearch', 'jovo_host', array( $this, 'sanitize_jovo_host' ) ); + register_setting( 'jovosearch', 'jovo_api_key', 'sanitize_text_field' ); + register_setting( 'jovosearch', 'jovo_activate', array( $this, 'sanitize_jovo_activate' ) ); + + } + + /** + * Admin menu actions + * + * Adds options page to admin menu. + * + * @since 0.1.0 + * + * @return void + */ + public function action_admin_menu() { + + $parent_slug = 'options-general.php'; + $capability = 'manage_options'; + + if ( is_multisite() ) { + $parent_slug = 'settings.php'; + $capability = 'manage_network'; + } + + $this->options_page = add_submenu_page( + $parent_slug, + 'ElasticPress', + 'ElasticPress', + $capability, + 'elasticpress', + array( $this, 'settings_page' ) + ); + } + + /** + * Load the settings page view + * + * Callback for add_meta_box to load column view. + * + * @since 0.1.0 + * + * @param WP_Post|NULL $post Normally WP_Post object, but NULL in our case. + * @param array $args Arguments passed from add_meta_box. + * + * @return void + */ + public function load_view( $post, $args ) { + + $file = dirname( dirname( __FILE__ ) ) . '/includes/settings/' . sanitize_file_name( $args['args'][0] ); + + if ( file_exists( $file ) ) { + require $file; + } + } + + /** + * Populate settings page columns + * + * Creates meta boxes for the settings page columns. + * + * @since 0.1.0 + * + * @return void + */ + protected function populate_columns() { + + add_meta_box( + 'ep-contentbox-1', + 'Settings', + array( + $this, + 'load_view', + ), + $this->options_page, + 'normal', + 'core', + array( 'form.php' ) + ); + + add_meta_box( + 'ep-contentbox-2', + 'Current Status', + array( + $this, + 'load_view', + ), + $this->options_page, + 'side', + 'core', + array( 'status.php' ) + ); + + /** + * Allow other metaboxes + * + * Allows individual features to add their own meta-boxes. + * + * @since 0.4.0 + * + * @param Jovo_Settings $this Instance of Jovo_Settings. + */ + do_action( 'jovo_do_settings_meta', $this ); + + } + + /** + * Sanitize activation + * + * Sanitizes the activation input from the dashboard and performs activation/deactivation. + * + * @since 0.2.0 + * + * @param string $input input items. + * + * @return string Sanitized input items + */ + public function sanitize_jovo_activate( $input ) { + + $input = ( isset( $input ) && 1 === intval( $input ) ? true : false ); + + if ( true === $input ) { + + Jovo_Lib::ep_activate(); + + } else { + + Jovo_Lib::ep_deactivate(); + + } + + return $input; + + } + + /** + * Sanitize EP_HOST + * + * Sanitizes the EP_HOST inputed from the dashboard. + * + * @since 0.2.0 + * + * @param string $input input items. + * + * @return string Sanitized input items + */ + public function sanitize_jovo_host( $input ) { + + $input = esc_url_raw( $input ); + + return $input; + + } + + /** + * Setting callback + * + * Callback for settings field. Displays textbox to specify the EP_HOST. + * + * @since 0.2.0 + * + * @return void + */ + public function setting_callback_activate() { + + echo ''; + + } + + /** + * Setting callback + * + * Callback for settings field. Displays textbox to specify the EP_API_KEY. + * + * @since 0.3.0 + * + * @return void + */ + public function setting_callback_api_key() { + + echo ''; + + } + + /** + * Setting callback + * + * Callback for settings field. Displays textbox to specify the EP_HOST. + * + * @since 0.1.0 + * + * @return void + */ + public function setting_callback_host() { + + echo ''; + + } + + /** + * Build settings page + * + * Loads up the settings page. + * + * @since 0.1.0 + * + * @return void + */ + public function settings_page() { + + $this->populate_columns(); + + include dirname( __FILE__ ) . '/../includes/settings-page.php'; + + } + + /** + * Displays Settings header + * + * Adds a header to main settings information + * + * @since 0.2.0 + * + * @return void + */ + public function jovo_settings_section_hightlight() { + + echo '

' . esc_html__( 'ElasticSearch Integration Options', 'jovosearch' ) . '

'; + + } +} From 1e2dd7f276814847c16b05c9bc6b354381ff07ce Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Fri, 20 Nov 2015 13:44:30 -0500 Subject: [PATCH 007/117] Add .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules From f0ca9332dcb571fc463ec055fcc224f7bd604c31 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Fri, 20 Nov 2015 13:44:42 -0500 Subject: [PATCH 008/117] Add grunt and package files --- Gruntfile.js | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 22 ++++++++ 2 files changed, 170 insertions(+) create mode 100644 Gruntfile.js create mode 100644 package.json diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000000..e5604716cc --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,148 @@ +module.exports = function ( grunt ) { + + // Start out by loading the grunt modules we'll need + require ( 'load-grunt-tasks' ) ( grunt ); + + grunt.initConfig ( + { + + uglify : { + + production : { + + options : { + beautify : false, + preserveComments : false, + mangle : { + except : ['jQuery'] + } + }, + + files : { + 'assets/js/elasticpress-admin.min.js' : [ + 'assets/js/elasticpress-admin.js' + ], + 'assets/js/elasticpress-index-admin.min.js' : [ + 'assets/js/elasticpress-index-admin.js' + ] + } + + } + + }, + + autoprefixer : { + + options : { + browsers : ['last 5 versions'], + map : true + }, + + files : { + expand : true, + flatten : true, + src : ['assets/css/elasticpress.css'], + dest : 'assets/css' + } + + }, + + cssmin : { + + target : { + + files : [{ + expand : true, + cwd : 'assets/css', + src : ['elasticpress.css'], + dest : 'assets/css', + ext : '.min.css' + }] + + } + + }, + + sass : { + + dist : { + + options : { + style : 'expanded', + sourceMap : true, + noCache : true + }, + + files : { + 'assets/css/elasticpress.css' : 'assets/css/elasticpress.scss', + } + + } + + }, + + pot : { + + options : { + text_domain : 'elasticpress', + dest : 'lang/', + keywords : [ //WordPress localisation functions + '__:1', + '_e:1', + '_x:1,2c', + 'esc_html__:1', + 'esc_html_e:1', + 'esc_html_x:1,2c', + 'esc_attr__:1', + 'esc_attr_e:1', + 'esc_attr_x:1,2c', + '_ex:1,2c', + '_n:1,2', + '_nx:1,2,4c', + '_n_noop:1,2', + '_nx_noop:1,2,3c' + ] + }, + + files : { + src : ['**/*.php'], //Parse all php files + expand : true + } + + }, + + watch : { + + options : { + livereload : true + }, + + scripts : { + + files : [ + 'assets/js/**/*' + ], + + tasks : ['uglify:production'] + + }, + + styles : { + + files : [ + 'assets/css/*.scss' + ], + + tasks : ['sass', 'autoprefixer', 'cssmin'] + + } + + } + + } + ); + + // A very basic default task. + grunt.registerTask ( 'default', ['uglify:production', 'sass', 'autoprefixer', 'cssmin', 'pot'] ); + +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000000..a78b572c92 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name" : "ElasticPress", + "private" : true, + "version" : "1.0.0", + "description" : "Grunt base for the ElasticPress Plugin.", + "dependencies" : { }, + "devDependencies": { + "grunt" : "*", + "grunt-contrib-uglify": "*", + "grunt-contrib-watch" : "*", + "grunt-sass" : "*", + "grunt-contrib-cssmin": "*", + "load-grunt-tasks" : "*", + "grunt-autoprefixer" : "*", + "grunt-pot" : "*" + }, + "author" : "10up", + "repository" : { + "type": "git", + "url" : "https://github.com/10up/ElasticPress" + } +} \ No newline at end of file From ba4ecd35512a735afee9ec1ee01d56110a56eee6 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Fri, 20 Nov 2015 13:44:53 -0500 Subject: [PATCH 009/117] Add version and dir constants --- elasticpress.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elasticpress.php b/elasticpress.php index 9a60020685..92627d3c4b 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -19,6 +19,9 @@ exit; // Exit if accessed directly. } +define( 'EP_URL', plugin_dir_url( __FILE__ ) ); +define( 'EP_VERSION', '1.6.2' ); + require_once( 'classes/class-ep-config.php' ); require_once( 'classes/class-ep-api.php' ); require_once( 'classes/class-ep-sync-manager.php' ); From ab7cf9441f6e26866a2111c23d8dac9f8f4d2481 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Fri, 20 Nov 2015 13:45:15 -0500 Subject: [PATCH 010/117] Add most Jovo resources --- assets/css/elasticpress.css | 39 ++ assets/css/elasticpress.css.map | 1 + assets/css/elasticpress.min.css | 1 + assets/css/elasticpress.scss | 54 ++ assets/css/images/index.php | 1 + .../css/images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 0 -> 212 bytes .../images/ui-bg_flat_75_ffffff_40x100.png | Bin 0 -> 208 bytes .../images/ui-bg_glass_55_fbf9ee_1x400.png | Bin 0 -> 335 bytes .../images/ui-bg_glass_65_ffffff_1x400.png | Bin 0 -> 207 bytes .../images/ui-bg_glass_75_dadada_1x400.png | Bin 0 -> 262 bytes .../images/ui-bg_glass_75_e6e6e6_1x400.png | Bin 0 -> 262 bytes .../images/ui-bg_glass_95_fef1ec_1x400.png | Bin 0 -> 332 bytes .../ui-bg_highlight-soft_75_cccccc_1x100.png | Bin 0 -> 280 bytes assets/css/images/ui-icons_222222_256x240.png | Bin 0 -> 6922 bytes assets/css/images/ui-icons_2e83ff_256x240.png | Bin 0 -> 4549 bytes assets/css/images/ui-icons_454545_256x240.png | Bin 0 -> 6992 bytes assets/css/images/ui-icons_888888_256x240.png | Bin 0 -> 6999 bytes assets/css/images/ui-icons_cd0a0a_256x240.png | Bin 0 -> 4549 bytes assets/css/index.php | 1 + assets/css/jquery-ui.css | 503 ++++++++++++++++++ assets/css/jquery-ui.min.css | 7 + assets/index.php | 1 + assets/js/elasticpress-admin.js | 19 + assets/js/elasticpress-admin.min.js | 1 + assets/js/elasticpress-index-admin.js | 127 +++++ assets/js/elasticpress-index-admin.min.js | 1 + assets/js/index.php | 1 + classes/class-ep-index-gui.php | 227 ++++++++ classes/class-ep-index-worker.php | 408 ++++++++++++++ classes/class-ep-settings.php | 106 ++-- includes/settings-page.php | 25 + includes/settings/form.php | 35 ++ includes/settings/index.php | 21 + includes/settings/status.php | 207 +++++++ lang/elasticpress.pot | 329 ++++++++++-- 35 files changed, 2005 insertions(+), 110 deletions(-) create mode 100644 assets/css/elasticpress.css create mode 100644 assets/css/elasticpress.css.map create mode 100644 assets/css/elasticpress.min.css create mode 100644 assets/css/elasticpress.scss create mode 100644 assets/css/images/index.php create mode 100755 assets/css/images/ui-bg_flat_0_aaaaaa_40x100.png create mode 100755 assets/css/images/ui-bg_flat_75_ffffff_40x100.png create mode 100755 assets/css/images/ui-bg_glass_55_fbf9ee_1x400.png create mode 100755 assets/css/images/ui-bg_glass_65_ffffff_1x400.png create mode 100755 assets/css/images/ui-bg_glass_75_dadada_1x400.png create mode 100755 assets/css/images/ui-bg_glass_75_e6e6e6_1x400.png create mode 100755 assets/css/images/ui-bg_glass_95_fef1ec_1x400.png create mode 100755 assets/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png create mode 100755 assets/css/images/ui-icons_222222_256x240.png create mode 100755 assets/css/images/ui-icons_2e83ff_256x240.png create mode 100755 assets/css/images/ui-icons_454545_256x240.png create mode 100755 assets/css/images/ui-icons_888888_256x240.png create mode 100755 assets/css/images/ui-icons_cd0a0a_256x240.png create mode 100644 assets/css/index.php create mode 100755 assets/css/jquery-ui.css create mode 100755 assets/css/jquery-ui.min.css create mode 100644 assets/index.php create mode 100644 assets/js/elasticpress-admin.js create mode 100644 assets/js/elasticpress-admin.min.js create mode 100644 assets/js/elasticpress-index-admin.js create mode 100644 assets/js/elasticpress-index-admin.min.js create mode 100644 assets/js/index.php create mode 100644 classes/class-ep-index-gui.php create mode 100644 classes/class-ep-index-worker.php create mode 100644 includes/settings-page.php create mode 100644 includes/settings/form.php create mode 100644 includes/settings/index.php create mode 100644 includes/settings/status.php diff --git a/assets/css/elasticpress.css b/assets/css/elasticpress.css new file mode 100644 index 0000000000..2440b8da81 --- /dev/null +++ b/assets/css/elasticpress.css @@ -0,0 +1,39 @@ +#ep_stats .ep_site { + display: none; } + +#ep_stats #ep_site_sel { + padding: 15px 0 0 0; } + +#ep_stats .ep_stats_section { + padding: 20px 0; } + +#ep_stats .search_stats { + display: block; + float: left; + margin: 0; + padding: 10px 0; + width: 50%; } + +#ep_stats .index_stats { + display: block; + float: right; + margin: 0; + padding: 10px 0; + width: 50%; } + +#ep_stats #ep_ind_stats, +#ep_stats #ep_cluster_stats { + clear: both; + width: 100%; } + +#ep_stats h3 { + margin: 0; + padding: 0; } + +#ep_stats ul { + list-style: disc; + margin: 0; + padding: 0; } + #ep_stats ul li { + margin-left: 20px; } +/*# sourceMappingURL=elasticpress.css.map */ \ No newline at end of file diff --git a/assets/css/elasticpress.css.map b/assets/css/elasticpress.css.map new file mode 100644 index 0000000000..51cd373e97 --- /dev/null +++ b/assets/css/elasticpress.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["elasticpress.scss"],"names":[],"mappings":"AAAA;EAGE,cAAe,EACf;;AAJF;EAOE,oBAAqB,EACrB;;AARF;EAWE,gBAAiB,EACjB;;AAZF;EAeE,eAAgB;EAChB,YAAe;EACf,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AApBF;EAuBE,eAAgB;EAChB,aAAgB;EAChB,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AA5BF;;EAgCE,YAAa;EACb,YAAa,EACb;;AAlCF;EAqCE,UAAY;EACZ,WAAY,EACZ;;AAvCF;EA2CE,iBAAkB;EAClB,UAAe;EACf,WAAe,EAMf;EAnDF;IAgDG,kBAAmB,EACnB","file":"elasticpress.css"} \ No newline at end of file diff --git a/assets/css/elasticpress.min.css b/assets/css/elasticpress.min.css new file mode 100644 index 0000000000..0ad2e733b1 --- /dev/null +++ b/assets/css/elasticpress.min.css @@ -0,0 +1 @@ +#ep_stats .ep_site{display:none}#ep_stats #ep_site_sel{padding:15px 0 0}#ep_stats .ep_stats_section{padding:20px 0}#ep_stats .index_stats,#ep_stats .search_stats{display:block;margin:0;padding:10px 0;width:50%}#ep_stats .search_stats{float:left}#ep_stats .index_stats{float:right}#ep_stats h3,#ep_stats ul{margin:0;padding:0}#ep_stats #ep_cluster_stats,#ep_stats #ep_ind_stats{clear:both;width:100%}#ep_stats ul{list-style:disc}#ep_stats ul li{margin-left:20px} \ No newline at end of file diff --git a/assets/css/elasticpress.scss b/assets/css/elasticpress.scss new file mode 100644 index 0000000000..ca7b16b0d1 --- /dev/null +++ b/assets/css/elasticpress.scss @@ -0,0 +1,54 @@ +#ep_stats { + + .ep_site { + display : none; + } + + #ep_site_sel { + padding : 15px 0 0 0; + } + + .ep_stats_section { + padding : 20px 0; + } + + .search_stats { + display : block; + float : left; + margin : 0; + padding : 10px 0; + width : 50%; + } + + .index_stats { + display : block; + float : right; + margin : 0; + padding : 10px 0; + width : 50%; + } + + #ep_ind_stats, + #ep_cluster_stats { + clear : both; + width : 100%; + } + + h3 { + margin : 0; + padding : 0; + } + + ul { + + list-style : disc; + margin : 0; + padding : 0; + + li { + margin-left : 20px; + } + + } + +} \ No newline at end of file diff --git a/assets/css/images/index.php b/assets/css/images/index.php new file mode 100644 index 0000000000..83c037f11a --- /dev/null +++ b/assets/css/images/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/css/images/ui-bg_flat_0_aaaaaa_40x100.png b/assets/css/images/ui-bg_flat_0_aaaaaa_40x100.png new file mode 100755 index 0000000000000000000000000000000000000000..d2e2aec4327bc07e7dba5bd14a7045574b4191a2 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^8bF-F1SA+{?>A)!QcOwS?k)_>#w|r1Kptm-M`SUO z_5fqIli7AahM1>|V~EA+ zRdP`(kYX@0Ff`RQFw-?K4>2&eGB&j`FxECOure@6YJK$*MMG|WN@iLmZVkdWf?)F zK#IZ0z|d6Jz)aV`JjB4<%GlJ(z*yVBz{nc6a#?2AmP!?*K(O3p^r= zfwTu0yPeFo12TF&T^vI^j=w#x$i?I+((tf;UXnmgbH|3oY>pC!)f}(GR!16S-u+#{ ze6YEqRkW=8vGl=5qArKM<9}TC-}iEvB{zdaTcX5$wyRTK&ALYGq)oZD3$! kV35@M>LrSX-29Zxv`X9>gl`0e0yQvry85}Sb4q9e0BKEiuK)l5 literal 0 HcmV?d00001 diff --git a/assets/css/images/ui-bg_glass_65_ffffff_1x400.png b/assets/css/images/ui-bg_glass_65_ffffff_1x400.png new file mode 100755 index 0000000000000000000000000000000000000000..911ab82b9c82aad0d4d9298bf18ff341736bfcd7 GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^j6gI2NH8$CE1Q=ADW)WEcNYf6yIsOdfIQ9ukH}&m z?E%JaC$sH<3_(v9#}JM4$r%X}t&0mp9yKsb%{ak$*<@oTP*SzTHKHUXu_Vzopr03-%8asU7T literal 0 HcmV?d00001 diff --git a/assets/css/images/ui-bg_glass_75_dadada_1x400.png b/assets/css/images/ui-bg_glass_75_dadada_1x400.png new file mode 100755 index 0000000000000000000000000000000000000000..cc7df67189fcc6391cfea75a4cf6b0495a722236 GIT binary patch literal 262 zcmeAS@N?(olHy`uVBq!ia0vp^j6gI&0LWmFTHNUZq?nSt-Ch3w7g=q17Rci)@Q5r1 z(jH*!b~4)z#PD=+46!(!T=8puqDZgOs>RXUCGx5b?-VBQkUm|IuXOmYJrBRJgj{Vx zMbNnqUkncy+qa2-mWYc>swkcIuvGK#>(0d)B7)5f`@$Ei28nH~0h*~=;u=wsl30>z zm0Xkxq!^403{74d5D3zm9eRnfw8uMft7(lQtPXiC>nC}Q!>*kacdC15flp4 Oz~JfX=d#Wzp$P!T*G|U( literal 0 HcmV?d00001 diff --git a/assets/css/images/ui-bg_glass_95_fef1ec_1x400.png b/assets/css/images/ui-bg_glass_95_fef1ec_1x400.png new file mode 100755 index 0000000000000000000000000000000000000000..1aec78e79b279f1881a59d4ad2882c4205947969 GIT binary patch literal 332 zcmeAS@N?(olHy`uVBq!ia0vp^j6gI&fCnc6a#?2AmP!?*K(O3p^r= zfwTu0yPeFo12VciT^vI^j=w#>k(V)1qW$CZ|6)SVV-&*#dav<$DMuV&n0Dbpw@azopr0NHbMt^fc4 literal 0 HcmV?d00001 diff --git a/assets/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/assets/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png new file mode 100755 index 0000000000000000000000000000000000000000..f547342219928a5947134afffcf80c39c9985c8b GIT binary patch literal 280 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 Q^5g_ikWrPcku(qaFX2Wbe*gdg literal 0 HcmV?d00001 diff --git a/assets/css/images/ui-icons_2e83ff_256x240.png b/assets/css/images/ui-icons_2e83ff_256x240.png new file mode 100755 index 0000000000000000000000000000000000000000..f2bf8388370920783b94285cb75827ce4b4cc1c5 GIT binary patch literal 4549 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 F{sUG;a@YU> literal 0 HcmV?d00001 diff --git a/assets/css/images/ui-icons_454545_256x240.png b/assets/css/images/ui-icons_454545_256x240.png new file mode 100755 index 0000000000000000000000000000000000000000..d6169e8bf9389ab9b5b7d2c6f0c5fe3e4d363105 GIT binary patch literal 6992 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 literal 0 HcmV?d00001 diff --git a/assets/css/images/ui-icons_cd0a0a_256x240.png b/assets/css/images/ui-icons_cd0a0a_256x240.png new file mode 100755 index 0000000000000000000000000000000000000000..49370189231d006600b0f0c2967cad1583eba634 GIT binary patch literal 4549 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 E2b3c!L;wH) literal 0 HcmV?d00001 diff --git a/assets/css/index.php b/assets/css/index.php new file mode 100644 index 0000000000..83c037f11a --- /dev/null +++ b/assets/css/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/css/jquery-ui.css b/assets/css/jquery-ui.css new file mode 100755 index 0000000000..2ced101995 --- /dev/null +++ b/assets/css/jquery-ui.css @@ -0,0 +1,503 @@ +/*! jQuery UI - v1.11.4 - 2015-06-10 +* http://jqueryui.com +* Includes: core.css, progressbar.css, theme.css +* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=highlight_soft&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=flat&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=glass&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=glass&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=glass&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=glass&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px +* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { + display: none; +} +.ui-helper-hidden-accessible { + border: 0; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; +} +.ui-helper-reset { + margin: 0; + padding: 0; + border: 0; + outline: 0; + line-height: 1.3; + text-decoration: none; + font-size: 100%; + list-style: none; +} +.ui-helper-clearfix:before, +.ui-helper-clearfix:after { + content: ""; + display: table; + border-collapse: collapse; +} +.ui-helper-clearfix:after { + clear: both; +} +.ui-helper-clearfix { + min-height: 0; /* support: IE7 */ +} +.ui-helper-zfix { + width: 100%; + height: 100%; + top: 0; + left: 0; + position: absolute; + opacity: 0; + filter:Alpha(Opacity=0); /* support: IE8 */ +} + +.ui-front { + z-index: 100; +} + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { + cursor: default !important; +} + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { + display: block; + text-indent: -99999px; + overflow: hidden; + background-repeat: no-repeat; +} + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; +} +.ui-progressbar { + height: 2em; + text-align: left; + overflow: hidden; +} +.ui-progressbar .ui-progressbar-value { + margin: -1px; + height: 100%; +} +.ui-progressbar .ui-progressbar-overlay { + background: url("data:image/gif;base64,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"); + height: 100%; + filter: alpha(opacity=25); /* support: IE8 */ + opacity: 0.25; +} +.ui-progressbar-indeterminate .ui-progressbar-value { + background-image: none; +} + +/* Component containers +----------------------------------*/ +.ui-widget { + font-family: Verdana,Arial,sans-serif; + font-size: 1.1em; +} +.ui-widget .ui-widget { + font-size: 1em; +} +.ui-widget input, +.ui-widget select, +.ui-widget textarea, +.ui-widget button { + font-family: Verdana,Arial,sans-serif; + font-size: 1em; +} +.ui-widget-content { + border: 1px solid #aaaaaa; + background: #ffffff url("images/ui-bg_flat_75_ffffff_40x100.png") 50% 50% repeat-x; + color: #222222; +} +.ui-widget-content a { + color: #222222; +} +.ui-widget-header { + border: 1px solid #aaaaaa; + background: #cccccc url("images/ui-bg_highlight-soft_75_cccccc_1x100.png") 50% 50% repeat-x; + color: #222222; + font-weight: bold; +} +.ui-widget-header a { + color: #222222; +} + +/* Interaction states +----------------------------------*/ +.ui-state-default, +.ui-widget-content .ui-state-default, +.ui-widget-header .ui-state-default { + border: 1px solid #d3d3d3; + background: #e6e6e6 url("images/ui-bg_glass_75_e6e6e6_1x400.png") 50% 50% repeat-x; + font-weight: normal; + color: #555555; +} +.ui-state-default a, +.ui-state-default a:link, +.ui-state-default a:visited { + color: #555555; + text-decoration: none; +} +.ui-state-hover, +.ui-widget-content .ui-state-hover, +.ui-widget-header .ui-state-hover, +.ui-state-focus, +.ui-widget-content .ui-state-focus, +.ui-widget-header .ui-state-focus { + border: 1px solid #999999; + background: #dadada url("images/ui-bg_glass_75_dadada_1x400.png") 50% 50% repeat-x; + font-weight: normal; + color: #212121; +} +.ui-state-hover a, +.ui-state-hover a:hover, +.ui-state-hover a:link, +.ui-state-hover a:visited, +.ui-state-focus a, +.ui-state-focus a:hover, +.ui-state-focus a:link, +.ui-state-focus a:visited { + color: #212121; + text-decoration: none; +} +.ui-state-active, +.ui-widget-content .ui-state-active, +.ui-widget-header .ui-state-active { + border: 1px solid #aaaaaa; + background: #ffffff url("images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x; + font-weight: normal; + color: #212121; +} +.ui-state-active a, +.ui-state-active a:link, +.ui-state-active a:visited { + color: #212121; + text-decoration: none; +} + +/* Interaction Cues +----------------------------------*/ +.ui-state-highlight, +.ui-widget-content .ui-state-highlight, +.ui-widget-header .ui-state-highlight { + border: 1px solid #fcefa1; + background: #fbf9ee url("images/ui-bg_glass_55_fbf9ee_1x400.png") 50% 50% repeat-x; + color: #363636; +} +.ui-state-highlight a, +.ui-widget-content .ui-state-highlight a, +.ui-widget-header .ui-state-highlight a { + color: #363636; +} +.ui-state-error, +.ui-widget-content .ui-state-error, +.ui-widget-header .ui-state-error { + border: 1px solid #cd0a0a; + background: #fef1ec url("images/ui-bg_glass_95_fef1ec_1x400.png") 50% 50% repeat-x; + color: #cd0a0a; +} +.ui-state-error a, +.ui-widget-content .ui-state-error a, +.ui-widget-header .ui-state-error a { + color: #cd0a0a; +} +.ui-state-error-text, +.ui-widget-content .ui-state-error-text, +.ui-widget-header .ui-state-error-text { + color: #cd0a0a; +} +.ui-priority-primary, +.ui-widget-content .ui-priority-primary, +.ui-widget-header .ui-priority-primary { + font-weight: bold; +} +.ui-priority-secondary, +.ui-widget-content .ui-priority-secondary, +.ui-widget-header .ui-priority-secondary { + opacity: .7; + filter:Alpha(Opacity=70); /* support: IE8 */ + font-weight: normal; +} +.ui-state-disabled, +.ui-widget-content .ui-state-disabled, +.ui-widget-header .ui-state-disabled { + opacity: .35; + filter:Alpha(Opacity=35); /* support: IE8 */ + background-image: none; +} +.ui-state-disabled .ui-icon { + filter:Alpha(Opacity=35); /* support: IE8 - See #6059 */ +} + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { + width: 16px; + height: 16px; +} +.ui-icon, +.ui-widget-content .ui-icon { + background-image: url("images/ui-icons_222222_256x240.png"); +} +.ui-widget-header .ui-icon { + background-image: url("images/ui-icons_222222_256x240.png"); +} +.ui-state-default .ui-icon { + background-image: url("images/ui-icons_888888_256x240.png"); +} +.ui-state-hover .ui-icon, +.ui-state-focus .ui-icon { + background-image: url("images/ui-icons_454545_256x240.png"); +} +.ui-state-active .ui-icon { + background-image: url("images/ui-icons_454545_256x240.png"); +} +.ui-state-highlight .ui-icon { + background-image: url("images/ui-icons_2e83ff_256x240.png"); +} +.ui-state-error .ui-icon, +.ui-state-error-text .ui-icon { + background-image: url("images/ui-icons_cd0a0a_256x240.png"); +} + +/* positioning */ +.ui-icon-blank { background-position: 16px 16px; } +.ui-icon-carat-1-n { background-position: 0 0; } +.ui-icon-carat-1-ne { background-position: -16px 0; } +.ui-icon-carat-1-e { background-position: -32px 0; } +.ui-icon-carat-1-se { background-position: -48px 0; } +.ui-icon-carat-1-s { background-position: -64px 0; } +.ui-icon-carat-1-sw { background-position: -80px 0; } +.ui-icon-carat-1-w { background-position: -96px 0; } +.ui-icon-carat-1-nw { background-position: -112px 0; } +.ui-icon-carat-2-n-s { background-position: -128px 0; } +.ui-icon-carat-2-e-w { background-position: -144px 0; } +.ui-icon-triangle-1-n { background-position: 0 -16px; } +.ui-icon-triangle-1-ne { background-position: -16px -16px; } +.ui-icon-triangle-1-e { background-position: -32px -16px; } +.ui-icon-triangle-1-se { background-position: -48px -16px; } +.ui-icon-triangle-1-s { background-position: -64px -16px; } +.ui-icon-triangle-1-sw { background-position: -80px -16px; } +.ui-icon-triangle-1-w { background-position: -96px -16px; } +.ui-icon-triangle-1-nw { background-position: -112px -16px; } +.ui-icon-triangle-2-n-s { background-position: -128px -16px; } +.ui-icon-triangle-2-e-w { background-position: -144px -16px; } +.ui-icon-arrow-1-n { background-position: 0 -32px; } +.ui-icon-arrow-1-ne { background-position: -16px -32px; } +.ui-icon-arrow-1-e { background-position: -32px -32px; } +.ui-icon-arrow-1-se { background-position: -48px -32px; } +.ui-icon-arrow-1-s { background-position: -64px -32px; } +.ui-icon-arrow-1-sw { background-position: -80px -32px; } +.ui-icon-arrow-1-w { background-position: -96px -32px; } +.ui-icon-arrow-1-nw { background-position: -112px -32px; } +.ui-icon-arrow-2-n-s { background-position: -128px -32px; } +.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } +.ui-icon-arrow-2-e-w { background-position: -160px -32px; } +.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } +.ui-icon-arrowstop-1-n { background-position: -192px -32px; } +.ui-icon-arrowstop-1-e { background-position: -208px -32px; } +.ui-icon-arrowstop-1-s { background-position: -224px -32px; } +.ui-icon-arrowstop-1-w { background-position: -240px -32px; } +.ui-icon-arrowthick-1-n { background-position: 0 -48px; } +.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } +.ui-icon-arrowthick-1-e { background-position: -32px -48px; } +.ui-icon-arrowthick-1-se { background-position: -48px -48px; } +.ui-icon-arrowthick-1-s { background-position: -64px -48px; } +.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } +.ui-icon-arrowthick-1-w { background-position: -96px -48px; } +.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } +.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } +.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } +.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } +.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } +.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } +.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } +.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } +.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } +.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } +.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } +.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } +.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } +.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } +.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } +.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } +.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } +.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } +.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } +.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } +.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } +.ui-icon-arrow-4 { background-position: 0 -80px; } +.ui-icon-arrow-4-diag { background-position: -16px -80px; } +.ui-icon-extlink { background-position: -32px -80px; } +.ui-icon-newwin { background-position: -48px -80px; } +.ui-icon-refresh { background-position: -64px -80px; } +.ui-icon-shuffle { background-position: -80px -80px; } +.ui-icon-transfer-e-w { background-position: -96px -80px; } +.ui-icon-transferthick-e-w { background-position: -112px -80px; } +.ui-icon-folder-collapsed { background-position: 0 -96px; } +.ui-icon-folder-open { background-position: -16px -96px; } +.ui-icon-document { background-position: -32px -96px; } +.ui-icon-document-b { background-position: -48px -96px; } +.ui-icon-note { background-position: -64px -96px; } +.ui-icon-mail-closed { background-position: -80px -96px; } +.ui-icon-mail-open { background-position: -96px -96px; } +.ui-icon-suitcase { background-position: -112px -96px; } +.ui-icon-comment { background-position: -128px -96px; } +.ui-icon-person { background-position: -144px -96px; } +.ui-icon-print { background-position: -160px -96px; } +.ui-icon-trash { background-position: -176px -96px; } +.ui-icon-locked { background-position: -192px -96px; } +.ui-icon-unlocked { background-position: -208px -96px; } +.ui-icon-bookmark { background-position: -224px -96px; } +.ui-icon-tag { background-position: -240px -96px; } +.ui-icon-home { background-position: 0 -112px; } +.ui-icon-flag { background-position: -16px -112px; } +.ui-icon-calendar { background-position: -32px -112px; } +.ui-icon-cart { background-position: -48px -112px; } +.ui-icon-pencil { background-position: -64px -112px; } +.ui-icon-clock { background-position: -80px -112px; } +.ui-icon-disk { background-position: -96px -112px; } +.ui-icon-calculator { background-position: -112px -112px; } +.ui-icon-zoomin { background-position: -128px -112px; } +.ui-icon-zoomout { background-position: -144px -112px; } +.ui-icon-search { background-position: -160px -112px; } +.ui-icon-wrench { background-position: -176px -112px; } +.ui-icon-gear { background-position: -192px -112px; } +.ui-icon-heart { background-position: -208px -112px; } +.ui-icon-star { background-position: -224px -112px; } +.ui-icon-link { background-position: -240px -112px; } +.ui-icon-cancel { background-position: 0 -128px; } +.ui-icon-plus { background-position: -16px -128px; } +.ui-icon-plusthick { background-position: -32px -128px; } +.ui-icon-minus { background-position: -48px -128px; } +.ui-icon-minusthick { background-position: -64px -128px; } +.ui-icon-close { background-position: -80px -128px; } +.ui-icon-closethick { background-position: -96px -128px; } +.ui-icon-key { background-position: -112px -128px; } +.ui-icon-lightbulb { background-position: -128px -128px; } +.ui-icon-scissors { background-position: -144px -128px; } +.ui-icon-clipboard { background-position: -160px -128px; } +.ui-icon-copy { background-position: -176px -128px; } +.ui-icon-contact { background-position: -192px -128px; } +.ui-icon-image { background-position: -208px -128px; } +.ui-icon-video { background-position: -224px -128px; } +.ui-icon-script { background-position: -240px -128px; } +.ui-icon-alert { background-position: 0 -144px; } +.ui-icon-info { background-position: -16px -144px; } +.ui-icon-notice { background-position: -32px -144px; } +.ui-icon-help { background-position: -48px -144px; } +.ui-icon-check { background-position: -64px -144px; } +.ui-icon-bullet { background-position: -80px -144px; } +.ui-icon-radio-on { background-position: -96px -144px; } +.ui-icon-radio-off { background-position: -112px -144px; } +.ui-icon-pin-w { background-position: -128px -144px; } +.ui-icon-pin-s { background-position: -144px -144px; } +.ui-icon-play { background-position: 0 -160px; } +.ui-icon-pause { background-position: -16px -160px; } +.ui-icon-seek-next { background-position: -32px -160px; } +.ui-icon-seek-prev { background-position: -48px -160px; } +.ui-icon-seek-end { background-position: -64px -160px; } +.ui-icon-seek-start { background-position: -80px -160px; } +/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ +.ui-icon-seek-first { background-position: -80px -160px; } +.ui-icon-stop { background-position: -96px -160px; } +.ui-icon-eject { background-position: -112px -160px; } +.ui-icon-volume-off { background-position: -128px -160px; } +.ui-icon-volume-on { background-position: -144px -160px; } +.ui-icon-power { background-position: 0 -176px; } +.ui-icon-signal-diag { background-position: -16px -176px; } +.ui-icon-signal { background-position: -32px -176px; } +.ui-icon-battery-0 { background-position: -48px -176px; } +.ui-icon-battery-1 { background-position: -64px -176px; } +.ui-icon-battery-2 { background-position: -80px -176px; } +.ui-icon-battery-3 { background-position: -96px -176px; } +.ui-icon-circle-plus { background-position: 0 -192px; } +.ui-icon-circle-minus { background-position: -16px -192px; } +.ui-icon-circle-close { background-position: -32px -192px; } +.ui-icon-circle-triangle-e { background-position: -48px -192px; } +.ui-icon-circle-triangle-s { background-position: -64px -192px; } +.ui-icon-circle-triangle-w { background-position: -80px -192px; } +.ui-icon-circle-triangle-n { background-position: -96px -192px; } +.ui-icon-circle-arrow-e { background-position: -112px -192px; } +.ui-icon-circle-arrow-s { background-position: -128px -192px; } +.ui-icon-circle-arrow-w { background-position: -144px -192px; } +.ui-icon-circle-arrow-n { background-position: -160px -192px; } +.ui-icon-circle-zoomin { background-position: -176px -192px; } +.ui-icon-circle-zoomout { background-position: -192px -192px; } +.ui-icon-circle-check { background-position: -208px -192px; } +.ui-icon-circlesmall-plus { background-position: 0 -208px; } +.ui-icon-circlesmall-minus { background-position: -16px -208px; } +.ui-icon-circlesmall-close { background-position: -32px -208px; } +.ui-icon-squaresmall-plus { background-position: -48px -208px; } +.ui-icon-squaresmall-minus { background-position: -64px -208px; } +.ui-icon-squaresmall-close { background-position: -80px -208px; } +.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } +.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } +.ui-icon-grip-solid-vertical { background-position: -32px -224px; } +.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } +.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } +.ui-icon-grip-diagonal-se { background-position: -80px -224px; } + + +/* Misc visuals +----------------------------------*/ + +/* Corner radius */ +.ui-corner-all, +.ui-corner-top, +.ui-corner-left, +.ui-corner-tl { + border-top-left-radius: 4px; +} +.ui-corner-all, +.ui-corner-top, +.ui-corner-right, +.ui-corner-tr { + border-top-right-radius: 4px; +} +.ui-corner-all, +.ui-corner-bottom, +.ui-corner-left, +.ui-corner-bl { + border-bottom-left-radius: 4px; +} +.ui-corner-all, +.ui-corner-bottom, +.ui-corner-right, +.ui-corner-br { + border-bottom-right-radius: 4px; +} + +/* Overlays */ +.ui-widget-overlay { + background: #aaaaaa url("images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x; + opacity: .3; + filter: Alpha(Opacity=30); /* support: IE8 */ +} +.ui-widget-shadow { + margin: -8px 0 0 -8px; + padding: 8px; + background: #aaaaaa url("images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x; + opacity: .3; + filter: Alpha(Opacity=30); /* support: IE8 */ + border-radius: 8px; +} diff --git a/assets/css/jquery-ui.min.css b/assets/css/jquery-ui.min.css new file mode 100755 index 0000000000..bd5c1fceb7 --- /dev/null +++ b/assets/css/jquery-ui.min.css @@ -0,0 +1,7 @@ +/*! jQuery UI - v1.11.4 - 2015-06-10 +* http://jqueryui.com +* Includes: core.css, progressbar.css, theme.css +* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=highlight_soft&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=flat&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=glass&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=glass&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=glass&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=glass&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px +* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ + +.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-progressbar{height:2em;text-align:left;overflow:hidden}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-progressbar-overlay{background:url("data:image/gif;base64,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");height:100%;filter:alpha(opacity=25);opacity:0.25}.ui-progressbar-indeterminate .ui-progressbar-value{background-image:none}.ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #aaa;background:#fff url("images/ui-bg_flat_75_ffffff_40x100.png") 50% 50% repeat-x;color:#222}.ui-widget-content a{color:#222}.ui-widget-header{border:1px solid #aaa;background:#ccc url("images/ui-bg_highlight-soft_75_cccccc_1x100.png") 50% 50% repeat-x;color:#222;font-weight:bold}.ui-widget-header a{color:#222}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #d3d3d3;background:#e6e6e6 url("images/ui-bg_glass_75_e6e6e6_1x400.png") 50% 50% repeat-x;font-weight:normal;color:#555}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#555;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #999;background:#dadada url("images/ui-bg_glass_75_dadada_1x400.png") 50% 50% repeat-x;font-weight:normal;color:#212121}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited,.ui-state-focus a,.ui-state-focus a:hover,.ui-state-focus a:link,.ui-state-focus a:visited{color:#212121;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #aaa;background:#fff url("images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x;font-weight:normal;color:#212121}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#212121;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #fcefa1;background:#fbf9ee url("images/ui-bg_glass_55_fbf9ee_1x400.png") 50% 50% repeat-x;color:#363636}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#363636}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #cd0a0a;background:#fef1ec url("images/ui-bg_glass_95_fef1ec_1x400.png") 50% 50% repeat-x;color:#cd0a0a}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#cd0a0a}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#cd0a0a}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px}.ui-icon,.ui-widget-content .ui-icon{background-image:url("images/ui-icons_222222_256x240.png")}.ui-widget-header .ui-icon{background-image:url("images/ui-icons_222222_256x240.png")}.ui-state-default .ui-icon{background-image:url("images/ui-icons_888888_256x240.png")}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url("images/ui-icons_454545_256x240.png")}.ui-state-active .ui-icon{background-image:url("images/ui-icons_454545_256x240.png")}.ui-state-highlight .ui-icon{background-image:url("images/ui-icons_2e83ff_256x240.png")}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url("images/ui-icons_cd0a0a_256x240.png")}.ui-icon-blank{background-position:16px 16px}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:4px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:4px}.ui-widget-overlay{background:#aaa url("images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30)}.ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaa url("images/ui-bg_flat_0_aaaaaa_40x100.png") 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30);border-radius:8px} \ No newline at end of file diff --git a/assets/index.php b/assets/index.php new file mode 100644 index 0000000000..83c037f11a --- /dev/null +++ b/assets/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js new file mode 100644 index 0000000000..9f2c383249 --- /dev/null +++ b/assets/js/elasticpress-admin.js @@ -0,0 +1,19 @@ +jQuery ( document ).ready ( function ( $ ) { + + + /** + * Show site stats + */ + $( '#jovo_site_select' ).change( function() { + + console.log( 'test' ); + + var siteId = $( this ).val(); + + $( '.jovo_site' ).hide(); + + $( '#jovo_' + siteId ).show(); + + } ); + +} ); diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js new file mode 100644 index 0000000000..ad95876377 --- /dev/null +++ b/assets/js/elasticpress-admin.min.js @@ -0,0 +1 @@ +jQuery(document).ready(function(a){a("#jovo_site_select").change(function(){console.log("test");var b=a(this).val();a(".jovo_site").hide(),a("#jovo_"+b).show()})}); \ No newline at end of file diff --git a/assets/js/elasticpress-index-admin.js b/assets/js/elasticpress-index-admin.js new file mode 100644 index 0000000000..31eea62646 --- /dev/null +++ b/assets/js/elasticpress-index-admin.js @@ -0,0 +1,127 @@ +jQuery ( document ).ready ( function ( $ ) { + + /** + * Update the progress bar every 3 seconds + */ + var performIndex = function ( resetBar, button ) { + + $ ( button ).val ( jovo.running_index_text ).removeClass ( 'button-primary' ); + + //Make sure the progress bar is showing + var bar = $ ( '#progressbar' ), + status = $ ( '#progressstats' ); + + bar.show (); + + if ( resetBar ) { + + var progress = 0; + + if ( parseInt ( jovo.total_posts ) > 0 ) { + + progress = parseFloat ( jovo.synced_posts ) / parseFloat ( jovo.total_posts ); + status.html ( jovo.synced_posts + '/' + jovo.total_posts + 'items' ); + + } else { + + status.html ( jovo.counting_items ); + + } + + bar.progressbar ( + { + value : progress * 100 + } + ); + + } + + processIndex ( bar, button, status ); + + }; + + /** + * Send request to server and process response + */ + var processIndex = function ( bar, button, status ) { + + var data = { + action : 'ep_launch_index', + nonce : jovo.nonce + }; + + //call the ajax + $.ajax ( + { + url : ajaxurl, + type : 'POST', + data : data, + complete : function ( response ) { + + if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete + + var progress = parseFloat ( response.responseJSON.data.ep_posts_synced ) / parseFloat ( response.responseJSON.data.ep_posts_total ); + + bar.progressbar ( + { + value : progress * 100 + } + ); + + status.html ( response.responseJSON.data.ep_posts_synced + '/' + response.responseJSON.data.ep_posts_total + ' ' + jovo.items_indexed ); + + performIndex ( false, button ); + + } else { //indexing complete + + bar.progressbar ( + { + value : 100 + } + ); + + setTimeout ( function () { + + $ ( '#progressbar' ).fadeOut ( 'slow' ); + $ ( '#progressstats' ).html ( 'Index complete Refresh the stats' ); + $ ( '#jovo_run_index' ).val ( jovo.index_complete_text ).addClass ( 'button-primary' ); + + }, 1000 ); + + } + + } + + } + ); + + }; + + // The run index button + var run_index_button = $ ( '#jovo_run_index' ); + + /** + * Start the poll if we need it + */ + if ( 1 === jovo.index_running ) { + performIndex ( true, run_index_button ); + } + + /** + * Process indexing operation + */ + run_index_button.click ( function ( event ) { + + event.preventDefault (); + + var button = this; + + if ( ! $ ( button ).hasClass ( 'button-primary' ) ) { + return; + } + + performIndex ( true, button ); //start the polling + + } ); + +} ); diff --git a/assets/js/elasticpress-index-admin.min.js b/assets/js/elasticpress-index-admin.min.js new file mode 100644 index 0000000000..342a03b1de --- /dev/null +++ b/assets/js/elasticpress-index-admin.min.js @@ -0,0 +1 @@ +jQuery(document).ready(function(a){var b=function(b,d){a(d).val(jovo.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(jovo.total_posts)>0?(g=parseFloat(jovo.synced_posts)/parseFloat(jovo.total_posts),f.html(jovo.synced_posts+"/"+jovo.total_posts+"items")):f.html(jovo.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:jovo.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+jovo.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#jovo_run_index").val(jovo.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#jovo_run_index");1===jovo.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file diff --git a/assets/js/index.php b/assets/js/index.php new file mode 100644 index 0000000000..83c037f11a --- /dev/null +++ b/assets/js/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php new file mode 100644 index 0000000000..f3325fcbec --- /dev/null +++ b/classes/class-ep-index-gui.php @@ -0,0 +1,227 @@ + + */ + +/** + * Adds a minimal UI to ElasticPress + * + * Adds a minimal UI to ElasticPress including the ability to index from within the WordPress + * Dashboard as well as the ability to retrieve basic statistics on the state of the + * index. + */ +class EP_Index_GUI { + + /** + * Path to the class file + * + * @since 0.1.0 + * + * @var string + */ + protected $path; + + /** + * Load hooks and other required information + * + * Loads various hook functions required to build the + * Easy EP interface. + * + * @since 0.1.0 + * + * @return EP_Index_GUI + */ + public function __construct() { + + $this->path = trailingslashit( dirname( __FILE__ ) ); + + // Load the class files. + require( dirname( __FILE__ ) . '/class-ep-index-worker.php' ); + + // Add JavaScripts. + add_action( 'admin_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts' ) ); + + // Add Ajax Actions. + add_action( 'wp_ajax_ep_launch_index', array( $this, 'action_wp_ajax_ep_launch_index' ) ); + add_action( 'ep_do_settings_meta', array( $this, 'action_ep_do_settings_meta' ) ); + + return $this; + + } + + /** + * Register and Enqueue JavaScripts + * + * Registers and enqueues the necessary JavaScripts for the interface. + * + * @since 0.1.0 + * + * @return void + */ + public function action_admin_enqueue_scripts() { + + // Enqueue more easily debugged version if applicable. + if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { + + wp_register_script( 'ep_index', EP_URL . 'assets/js/elasticpress-index-admin.js', array( 'jquery', 'jquery-ui-progressbar' ), JOVO_VERSION ); + + } else { + + wp_register_script( 'ep_index', EP_URL . 'assets/js/elasticpress-index-admin.min.js', array( 'jquery', 'jquery-ui-progressbar' ), JOVO_VERSION ); + + } + + // Only add the following to the settings page. + if ( isset( get_current_screen()->id ) && strpos( get_current_screen()->id, 'settings_page_elasticpress' ) !== false ) { + + wp_enqueue_script( 'ep_index' ); + + $running = 0; + $total_posts = 0; + $synced_posts = 0; + + if ( false !== get_transient( 'ep_index_offset' ) ) { + + $running = 1; + $synced_posts = get_transient( 'ep_index_synced' ); + $total_posts = get_transient( 'ep_post_count' ); + + } + + wp_localize_script( + 'ep_index', + 'ep', + array( + 'nonce' => wp_create_nonce( 'ep_manual_index' ), + 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), + 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), + 'items_indexed' => esc_html__( 'items indexed', 'elasticpress' ), + 'counting_items' => esc_html__( 'We\'re Still counting total items for the index. Please be patient', 'elasticpress' ), + 'index_running' => $running, + 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, + 'synced_posts' => $synced_posts, + ) + ); + + } + } + + /** + * Add index settings box + * + * Adds a meta box for allowing remote indexing. + * + * @since 0.4.0 + * + * @param Jovo_Settings $ep_settings Instance of Jovo_Settings. + * + * @return void + */ + public function action_ep_do_settings_meta( $ep_settings ) { + + add_meta_box( + 'ep-contentbox-3', 'Index Site', + array( + $ep_settings, + 'load_view', + ), + $ep_settings->options_page, + 'normal', + 'core', + array( 'index.php' ) + ); + + } + + /** + * Process manual indexing + * + * Processes the action when the manual indexing button is clicked. + * + * @since 0.1.0 + * + * @return void + */ + public function action_wp_ajax_ep_launch_index() { + + // Verify nonce and make sure this is run by an admin. + if ( ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'ep_manual_index' ) || ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( esc_html__( 'Security error!', 'elasticpress' ) ); + } + + $post_count = array( 'total' => 0 ); + $post_types = ep_get_indexable_post_types(); + $post_statuses = ep_get_indexable_post_status(); + + foreach ( $post_types as $type ) { + + $type_count = wp_count_posts( $type ); + $post_count[ $type ] = 0; + + foreach ( $post_statuses as $status ) { + + $count = absint( $type_count->$status ); + + $post_count['total'] += $count; + $post_count[ $type ] += $count; + + } + } + + set_transient( 'ep_post_count', $post_count, 600 ); + + if ( false === get_transient( 'ep_index_offset' ) ) { + + // Deactivate our search integration. + Jovo_Lib::ep_deactivate(); + + $mapping_success = Jovo_Lib::put_mapping(); + + if ( ! $mapping_success ) { + wp_send_json_error( esc_html__( 'Mappings could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); + } + } + + $network = false; + + if ( is_multisite() ) { + $network = true; + } + + $indexer = new EP_Index_Worker(); + $index_success = $indexer->index( $network ); + + if ( ! $index_success ) { + wp_send_json_error( esc_html__( 'Indexing could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); + } + + if ( false === get_transient( 'ep_index_offset' ) ) { + + // Reactivate our search integration. + Jovo_Lib::ep_activate(); + + $data = array( + 'ep_sync_complete' => 1, + ); + + } else { + + $total = get_transient( 'ep_post_count' ); + + $data = array( + 'ep_sync_complete' => 0, + 'ep_posts_synced' => get_transient( 'ep_index_synced' ), + 'ep_posts_total' => absint( $total['total'] ), + ); + } + + wp_send_json_success( $data ); + + } +} diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php new file mode 100644 index 0000000000..5b8671873c --- /dev/null +++ b/classes/class-ep-index-worker.php @@ -0,0 +1,408 @@ + + */ + +/** + * Worker Process for Indexing posts + * + * Handles and dispatches the indexing of posts. + */ +class EP_Index_Worker { + + /** + * Holds the posts that will be bulk synced. + * + * @since 0.1.0 + * + * @var array + */ + protected $posts; + + /** + * Initiate Index Worker + * + * Initiates the index worker process. + * + * @since 0.1.0 + * + * @return EP_Index_Worker + */ + public function __construct() { + + $this->posts = array(); + + } + + /** + * Create network alias + * + * Helper method for creating the network alias + * + * @since 0.1.0 + * + * @return array|bool Array of indexes or false on error + */ + protected function _create_network_alias() { + + $sites = ep_get_sites(); + $indexes = array(); + + foreach ( $sites as $site ) { + + switch_to_blog( $site['blog_id'] ); + + $indexes[] = ep_get_index_name(); + + restore_current_blog(); + + } + + return ep_create_network_alias( $indexes ); + + } + + /** + * Index all posts + * + * Index all posts for a site or network wide. + * + * @since 0.1.0 + * + * @param bool $network_wide To index network wide or not. + * + * @return bool True on success or false + */ + public function index( $network_wide = false ) { + + Jovo_Lib::check_host(); + + $total_indexed = 0; + + if ( true === $network_wide && is_multisite() ) { + + $sites = ep_get_sites(); + + foreach ( $sites as $site ) { + + switch_to_blog( $site['blog_id'] ); + + $result = $this->_index_helper(); + + $total_indexed += $result['synced']; + + if ( ! empty( $result['errors'] ) ) { + return false; + } + + restore_current_blog(); + } + + $this->_create_network_alias(); + + } else { + + $result = $this->_index_helper(); + + if ( ! empty( $result['errors'] ) ) { + return false; + } + } + + return true; + + } + + /** + * Helper method for indexing posts + * + * Handles the sync operation for individual posts. + * + * @since 0.1.0 + * + * @return array Array of posts successfully synced as well as errors + */ + protected function _index_helper() { + + global $wpdb, $wp_object_cache; + + $posts_per_page = apply_filters( 'ep_index_posts_per_page', 350 ); + + $offset_transient = get_transient( 'ep_index_offset' ); + $sync_transient = get_transient( 'ep_index_synced' ); + + $synced = false === $sync_transient ? 0 : absint( $sync_transient ); + $errors = array(); + $offset = false === $offset_transient ? 0 : absint( $offset_transient ); + $complete = false; + + $args = apply_filters( 'ep_index_posts_args', array( + 'posts_per_page' => $posts_per_page, + 'post_type' => ep_get_indexable_post_types(), + 'post_status' => ep_get_indexable_post_status(), + 'offset' => $offset, + 'ignore_sticky_posts' => true, + ) ); + + $query = new \WP_Query( $args ); + + if ( $query->have_posts() ) { + + while ( $query->have_posts() ) { + + $query->the_post(); + + $result = $this->queue_post( get_the_ID(), $query->post_count, $offset ); + + if ( ! $result ) { + + $errors[] = get_the_ID(); + + } else { + + $synced ++; + + } + } + + $totals = get_transient( 'ep_post_count' ); + + if ( $totals['total'] === $synced ) { + $complete = true; + } + } else { + + $complete = true; + + } + + $offset += $posts_per_page; + + usleep( 500 ); // Delay to let $wpdb catch up. + + // Avoid running out of memory. + $wpdb->queries = array(); + + if ( is_object( $wp_object_cache ) ) { + + $wp_object_cache->group_ops = array(); + $wp_object_cache->stats = array(); + $wp_object_cache->memcache_debug = array(); + $wp_object_cache->cache = array(); + + if ( is_callable( array( $wp_object_cache, '__remoteset' ) ) ) { + call_user_func( array( $wp_object_cache, '__remoteset' ) ); // Important. + } + } + + set_transient( 'ep_index_offset', $offset, 600 ); + set_transient( 'ep_index_synced', $synced, 600 ); + + if ( true === $complete ) { + + delete_transient( 'ep_index_offset' ); + delete_transient( 'ep_index_synced' ); + delete_transient( 'ep_post_count' ); + $this->send_bulk_errors(); + + } + + wp_reset_postdata(); + + return array( 'synced' => $synced, 'errors' => $errors ); + + } + + /** + * Queues up a post for bulk indexing + * + * Adds individual posts to a queue for later processing. + * + * @since 0.1.0 + * + * @param int $post_id The post ID to add. + * @param int $bulk_trigger The maximum number of posts to hold in the queue before triggering a bulk-update operation. + * @param int $offset The current offset to keep track of. + * + * @return bool True on success or false + */ + protected function queue_post( $post_id, $bulk_trigger, $offset ) { + + static $post_count = 0; + + // Put the post into the queue. + $this->posts[ $post_id ][] = '{ "index": { "_id": "' . absint( $post_id ) . '" } }'; + $this->posts[ $post_id ][] = addcslashes( wp_json_encode( ep_prepare_post( $post_id ) ), "\n" ); + + // Augment the counter. + ++ $post_count; + + // If we have hit the trigger, initiate the bulk request. + if ( absint( $bulk_trigger ) === $post_count ) { + + $this->bulk_index( $offset ); + + // Reset the post count. + $post_count = 0; + + // Reset the posts. + $this->posts = array(); + + } + + return true; + + } + + /** + * Perform the bulk index operation + * + * Sends multiple posts to the ES server at once. + * + * @since 0.1.0 + * + * @param int $offset The current offset to keep track of. + * + * @return bool|WP_Error true on success or WP_Error on failure + */ + protected function bulk_index( $offset ) { + + $failed_transient = get_transient( 'ep_index_failed_posts' ); + + $failed_posts = is_array( $failed_transient ) ? $failed_transient : array(); + $failed_blocks = array(); + + // Monitor how many times we attempt to add this particular bulk request. + static $attempts = 0; + + // Augment the attempts. + ++ $attempts; + + // Make sure we actually have something to index. + if ( empty( $this->posts ) ) { + return 0; + } + + $flatten = array(); + + foreach ( $this->posts as $post ) { + + $flatten[] = $post[0]; + $flatten[] = $post[1]; + + } + + // Make sure to add a new line at the end or the request will fail. + $body = rtrim( implode( PHP_EOL, $flatten ) ) . PHP_EOL; + + // Decode the response. + $response = ep_bulk_index_posts( $body ); + + if ( is_wp_error( $response ) ) { + + $failed_blocks = is_array( get_transient( 'ep_index_failed_blocks' ) ) ? get_transient( 'ep_index_failed_blocks' ) : array(); + $failed_blocks[] = $offset; + + return $response; + + } + + // If we did have errors, try to add the documents again. + if ( isset( $response['errors'] ) && true === $response['errors'] ) { + + if ( $attempts < 5 ) { + + foreach ( $response['items'] as $item ) { + + if ( empty( $item['index']['error'] ) ) { + unset( $this->posts[ $item['index']['_id'] ] ); + } + } + + $this->bulk_index( $offset ); + + } else { + + foreach ( $response['items'] as $item ) { + + if ( ! empty( $item['index']['_id'] ) ) { + + $failed_blocks[] = $offset; + $failed_posts[] = $item['index']['_id']; + + } + } + + $attempts = 0; + } + } else { + + // There were no errors, all the posts were added. + $attempts = 0; + + } + + if ( empty( $failed_posts ) ) { + + delete_transient( 'ep_index_failed_posts' ); + + } else { + + set_transient( 'ep_index_failed_posts', $failed_posts, 600 ); + + } + + if ( empty( $failed_blocks ) ) { + + delete_transient( 'ep_index_failed_blocks' ); + + } else { + + set_transient( 'ep_index_failed_blocks', $failed_blocks, 600 ); + + } + + return true; + + } + + /** + * Send any bulk indexing errors + * + * Emails bulk errors regarding any posts that failed to index. + * + * @since 0.1.0 + * + * @return void + */ + protected function send_bulk_errors() { + + $failed_posts = get_transient( 'ep_index_failed_posts' ); + + if ( false !== $failed_posts && is_array( $failed_posts ) ) { + + $email_text = esc_html__( 'The following posts failed to index:' . PHP_EOL . PHP_EOL, 'elasticpress' ); + + foreach ( $failed_posts as $failed ) { + + $failed_post = get_post( $failed ); + + if ( $failed_post ) { + $email_text .= "- {$failed}: " . $failed_post->post_title . PHP_EOL; + } + } + + wp_mail( get_option( 'admin_email' ), wp_specialchars_decode( get_option( 'blogname' ) ) . esc_html__( ': ElasticPress Index Errors', 'elasticpress' ), $email_text ); + + // Clear failed posts after sending emails. + delete_transient( 'ep_index_failed_posts' ); + + } + } +} diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 866497a48e..0c0554d8ce 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -2,24 +2,24 @@ /** * Create an ElasticPress settings page. * - * @package Jovosearch + * @package elasticpress * - * @since 0.1.0 + * @since 1.7 * * @author Allan Collins */ /** - * Jovosearch Settings Page + * ElasticPress Settings Page * * Sets up the settings page to handle ElasticPress configuration. */ -class Jovo_Settings { +class EP_Settings { /** * WordPress options page * - * @since 0.1.0 + * @since 1.7 * * @var object */ @@ -30,9 +30,9 @@ class Jovo_Settings { * * Loads initial actions. * - * @since 0.1.0 + * @since 1.7 * - * @return Jovo_Settings + * @return EP_Settings */ public function __construct() { @@ -61,7 +61,7 @@ public function __construct() { * * Registers and enqueues the necessary JavaScripts for the interface. * - * @since 0.1.0 + * @since 1.7 * * @return void */ @@ -70,27 +70,27 @@ public function action_admin_enqueue_scripts() { // Enqueue more easily debugged version if applicable. if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { - wp_register_script( 'jovo_admin', JOVO_URL . 'assets/js/jovosearch-admin.js', array( 'jquery' ), JOVO_VERSION ); + wp_register_script( 'ep_admin', EP_URL . 'assets/js/elasticpress-admin.js', array( 'jquery' ), EP_VERSION ); - wp_register_style( 'jovo_progress_style', JOVO_URL . 'assets/css/jquery-ui.css', array(), JOVO_VERSION ); - wp_register_style( 'jovo_styles', JOVO_URL . 'assets/css/jovosearch.css', array(), JOVO_VERSION ); + wp_register_style( 'ep_progress_style', EP_URL . 'assets/css/jquery-ui.css', array(), EP_VERSION ); + wp_register_style( 'ep_styles', EP_URL . 'assets/css/elasticpress.css', array(), EP_VERSION ); } else { - wp_register_script( 'jovo_admin', JOVO_URL . 'assets/js/jovosearch-admin.min.js', array( 'jquery' ), JOVO_VERSION ); + wp_register_script( 'ep_admin', EP_URL . 'assets/js/elasticpress-admin.min.js', array( 'jquery' ), EP_VERSION ); - wp_register_style( 'jovo_progress_style', JOVO_URL . 'assets/css/jquery-ui.min.css', array(), JOVO_VERSION ); - wp_register_style( 'jovo_styles', JOVO_URL . 'assets/css/jovosearch.min.css', array(), JOVO_VERSION ); + wp_register_style( 'ep_progress_style', EP_URL . 'assets/css/jquery-ui.min.css', array(), EP_VERSION ); + wp_register_style( 'ep_styles', EP_URL . 'assets/css/elasticpress.min.css', array(), EP_VERSION ); } // Only add the following to the settings page. if ( isset( get_current_screen()->id ) && strpos( get_current_screen()->id, 'settings_page_elasticpress' ) !== false ) { - wp_enqueue_style( 'jovo_progress_style' ); - wp_enqueue_style( 'jovo_styles' ); + wp_enqueue_style( 'ep_progress_style' ); + wp_enqueue_style( 'ep_styles' ); - wp_enqueue_script( 'jovo_admin' ); + wp_enqueue_script( 'ep_admin' ); } } @@ -100,50 +100,50 @@ public function action_admin_enqueue_scripts() { * * Sets up Settings API. * - * @since 0.1.0 + * @since 1.7 * * @return void */ public function action_admin_init() { //Save options for multisite - if ( is_multisite() && ( isset( $_POST['jovo_host'] ) || isset( $_POST['jovo_activate'] ) ) ) { + if ( is_multisite() && ( isset( $_POST['ep_host'] ) || isset( $_POST['ep_activate'] ) ) ) { - if ( ! check_admin_referer( 'jovosearch-options' ) ) { - die( esc_html__( 'Security error!', 'jovosearch' ) ); + if ( ! check_admin_referer( 'elasticpress-options' ) ) { + die( esc_html__( 'Security error!', 'elasticpress' ) ); } - if ( isset( $_POST['jovo_host'] ) ) { + if ( isset( $_POST['ep_host'] ) ) { - $host = $this->sanitize_jovo_host( $_POST['jovo_host'] ); - update_site_option( 'jovo_host', $host ); + $host = $this->sanitize_ep_host( $_POST['ep_host'] ); + update_site_option( 'ep_host', $host ); } - if ( isset( $_POST['jovo_api_key'] ) ) { + if ( isset( $_POST['ep_api_key'] ) ) { - $host = sanitize_text_field( $_POST['jovo_api_key'] ); - update_site_option( 'jovo_api_key', $host ); + $host = sanitize_text_field( $_POST['ep_api_key'] ); + update_site_option( 'ep_api_key', $host ); } - if ( isset( $_POST['jovo_activate'] ) ) { + if ( isset( $_POST['ep_activate'] ) ) { - $this->sanitize_jovo_activate( $_POST['jovo_activate'] ); + $this->sanitize_ep_activate( $_POST['ep_activate'] ); } else { - $this->sanitize_jovo_activate( false ); + $this->sanitize_ep_activate( false ); } } - add_settings_section( 'jovo_settings_section_main', '', array( $this, 'jovo_settings_section_hightlight' ), 'jovosearch' ); + add_settings_section( 'ep_settings_section_main', '', array( $this, 'ep_settings_section_hightlight' ), 'elasticpress' ); - if ( is_wp_error( Jovo_Lib::check_host() ) || get_site_option( 'jovo_host' ) ) { + if ( is_wp_error( Jovo_Lib::check_host() ) || get_site_option( 'ep_host' ) ) { - add_settings_field( 'jovo_host', esc_html__( 'ElasticSearch Host:', 'jovosearch' ), array( $this, 'setting_callback_host' ), 'jovosearch', 'jovo_settings_section_main' ); - add_settings_field( 'jovo_api_key', esc_html__( 'ElasticPress API Key:', 'jovosearch' ), array( $this, 'setting_callback_api_key' ), 'jovosearch', 'jovo_settings_section_main' ); + add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( $this, 'setting_callback_host' ), 'elasticpress', 'ep_settings_section_main' ); + add_settings_field( 'ep_api_key', esc_html__( 'ElasticPress API Key:', 'elasticpress' ), array( $this, 'setting_callback_api_key' ), 'elasticpress', 'ep_settings_section_main' ); } @@ -151,13 +151,13 @@ public function action_admin_init() { if ( $stats['status'] && ! is_wp_error( Jovo_Lib::check_host() ) ) { - add_settings_field( 'jovo_activate', esc_html__( 'Use ElasticSearch:', 'jovosearch' ), array( $this, 'setting_callback_activate' ), 'jovosearch', 'jovo_settings_section_main' ); + add_settings_field( 'ep_activate', esc_html__( 'Use ElasticSearch:', 'elasticpress' ), array( $this, 'setting_callback_activate' ), 'elasticpress', 'ep_settings_section_main' ); } - register_setting( 'jovosearch', 'jovo_host', array( $this, 'sanitize_jovo_host' ) ); - register_setting( 'jovosearch', 'jovo_api_key', 'sanitize_text_field' ); - register_setting( 'jovosearch', 'jovo_activate', array( $this, 'sanitize_jovo_activate' ) ); + register_setting( 'elasticpress', 'ep_host', array( $this, 'sanitize_ep_host' ) ); + register_setting( 'elasticpress', 'ep_api_key', 'sanitize_text_field' ); + register_setting( 'elasticpress', 'ep_activate', array( $this, 'sanitize_ep_activate' ) ); } @@ -166,7 +166,7 @@ public function action_admin_init() { * * Adds options page to admin menu. * - * @since 0.1.0 + * @since 1.7 * * @return void */ @@ -176,8 +176,10 @@ public function action_admin_menu() { $capability = 'manage_options'; if ( is_multisite() ) { + $parent_slug = 'settings.php'; $capability = 'manage_network'; + } $this->options_page = add_submenu_page( @@ -195,7 +197,7 @@ public function action_admin_menu() { * * Callback for add_meta_box to load column view. * - * @since 0.1.0 + * @since 1.7 * * @param WP_Post|NULL $post Normally WP_Post object, but NULL in our case. * @param array $args Arguments passed from add_meta_box. @@ -216,7 +218,7 @@ public function load_view( $post, $args ) { * * Creates meta boxes for the settings page columns. * - * @since 0.1.0 + * @since 1.7 * * @return void */ @@ -255,9 +257,9 @@ protected function populate_columns() { * * @since 0.4.0 * - * @param Jovo_Settings $this Instance of Jovo_Settings. + * @param EP_Settings $this Instance of ep_Settings. */ - do_action( 'jovo_do_settings_meta', $this ); + do_action( 'ep_do_settings_meta', $this ); } @@ -272,7 +274,7 @@ protected function populate_columns() { * * @return string Sanitized input items */ - public function sanitize_jovo_activate( $input ) { + public function sanitize_ep_activate( $input ) { $input = ( isset( $input ) && 1 === intval( $input ) ? true : false ); @@ -301,7 +303,7 @@ public function sanitize_jovo_activate( $input ) { * * @return string Sanitized input items */ - public function sanitize_jovo_host( $input ) { + public function sanitize_ep_host( $input ) { $input = esc_url_raw( $input ); @@ -320,7 +322,7 @@ public function sanitize_jovo_host( $input ) { */ public function setting_callback_activate() { - echo ''; + echo ''; } @@ -335,7 +337,7 @@ public function setting_callback_activate() { */ public function setting_callback_api_key() { - echo ''; + echo ''; } @@ -344,13 +346,13 @@ public function setting_callback_api_key() { * * Callback for settings field. Displays textbox to specify the EP_HOST. * - * @since 0.1.0 + * @since 1.7 * * @return void */ public function setting_callback_host() { - echo ''; + echo ''; } @@ -359,7 +361,7 @@ public function setting_callback_host() { * * Loads up the settings page. * - * @since 0.1.0 + * @since 1.7 * * @return void */ @@ -380,9 +382,9 @@ public function settings_page() { * * @return void */ - public function jovo_settings_section_hightlight() { + public function ep_settings_section_hightlight() { - echo '

' . esc_html__( 'ElasticSearch Integration Options', 'jovosearch' ) . '

'; + echo '

' . esc_html__( 'ElasticSearch Integration Options', 'elasticpress' ) . '

'; } } diff --git a/includes/settings-page.php b/includes/settings-page.php new file mode 100644 index 0000000000..7767ccd5f3 --- /dev/null +++ b/includes/settings-page.php @@ -0,0 +1,25 @@ + + */ +?> +
+ %s', esc_html__( 'ElasticPress', 'elasticpress' ) ); ?> + +
+
+ options_page, 'normal', null ); ?> +
+ +
+ options_page, 'side', null ); ?> +
+ +
+
diff --git a/includes/settings/form.php b/includes/settings/form.php new file mode 100644 index 0000000000..909777378c --- /dev/null +++ b/includes/settings/form.php @@ -0,0 +1,35 @@ + + */ +?> + + + +
+ +
diff --git a/includes/settings/index.php b/includes/settings/index.php new file mode 100644 index 0000000000..2744bad548 --- /dev/null +++ b/includes/settings/index.php @@ -0,0 +1,21 @@ + + */ +?> + + +

+ +

+

+

diff --git a/includes/settings/status.php b/includes/settings/status.php new file mode 100644 index 0000000000..0602745eb1 --- /dev/null +++ b/includes/settings/status.php @@ -0,0 +1,207 @@ + + */ + +$stats = Jovo_Lib::ep_get_index_status(); +$search_stats = Jovo_lib::ep_get_search_status(); + +echo '

'; + +?> + +
+ + + + + + + + + + + + + + + +
:
+
+ +%s', esc_html__( 'Plugin Status', 'elasticpress' ) ); + ?> +

+ + + +
+
+ + + + +
+ + + + %s', esc_html__( 'System Stats', 'elasticpress' ) ); ?> + +
+ + %s', esc_html__( 'Search Stats', 'elasticpress' ) ); ?> + +
    +
  • + query_total ); ?> +
  • +
  • + query_time_in_millis ); ?> + ms +
  • +
  • + fetch_total ); ?> +
    +
  • + fetch_time_in_millis ); ?> + ms +
  • +
+ +
+ +
+ + %s', esc_html__( 'Index Stats', 'elasticpress' ) ); ?> + +
    +
  • + index_total ); ?> +
  • +
  • + index_time_in_millis ); ?>ms +
  • +
+ +
+ + '; + + printf( '

%s

', esc_html__( 'Site Stats', 'elasticpress' ) ); + + $sites = ep_get_sites(); + + echo '
'; + echo '' . esc_html__( 'Select a site:', 'elasticpress' ) . ' '; + echo '
'; + + foreach ( $sites as $site ) { + + $stats = Jovo_Lib::ep_get_index_status( $site['blog_id'] ); + $search_stats = Jovo_Lib::ep_get_search_status( $site['blog_id'] ); + $details = get_blog_details( $site['blog_id'] ); + ?> +
+ +
+ %s', esc_html__( 'Search Stats', 'elasticpress' ) ); ?> +
    +
  • + query_total ); ?> +
  • +
  • + query_time_in_millis ); ?>ms +
  • +
  • + fetch_total ); ?> +
  • +
  • + fetch_time_in_millis ); ?>ms +
  • +
+ +
+
+ %s', esc_html__( 'Index Stats', 'elasticpress' ) ); ?> +
    +
  • + index_total ); ?> +
  • +
  • + index_time_in_millis ); ?>ms +
  • +
+
+ +
+ '; + + } + ?> + +
+ + %s', esc_html__( 'Cluster Stats', 'elasticpress' ) ); ?> + + nodes->fs; + $disk_usage = $fs->total_in_bytes - $fs->available_in_bytes; + ?> + +
    +
  • + total_in_bytes ) * 100, 0 ) ); ?>% +
  • +
  • + available_in_bytes ) ); ?> +
  • +
  • + total_in_bytes ) ); ?> +
  • +
+
+ + array(), + 'code' => array(), + ); + + echo ' ' . esc_html__( 'ERROR:', 'elasticpress' ) . ' ' . wp_kses( $stats['msg'], $allowed_tags ); + +} + +echo '
'; diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 1b739676c7..3fd8453da9 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -1,100 +1,313 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the ElasticPress package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: Elasticpress\n" -"POT-Creation-Date: 2014-07-08 01:41-0500\n" -"PO-Revision-Date: 2014-07-08 01:41-0500\n" -"Last-Translator: \n" -"Language-Team: \n" -"Language: en\n" +"Project-Id-Version: ElasticPress 1.0.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-11-20 13:40-0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" +"Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.6.6\n" -"X-Poedit-Basepath: ../\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Poedit-KeywordsList: __;_e\n" -"X-Poedit-SearchPath-0: .\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -#: classes/class-ep-cron.php:46 -msgid "Every 30 minutes" +#: bin/wp-cli.php:55 +#, php-format +msgid "Adding mapping for site %d..." msgstr "" -#: classes/class-ep-elasticpress.php:85 classes/class-ep-elasticpress.php:96 -msgid "ElasticPress" +#: bin/wp-cli.php:63 bin/wp-cli.php:79 +msgid "Mapping sent" +msgstr "" + +#: bin/wp-cli.php:65 bin/wp-cli.php:81 +msgid "Mapping failed" +msgstr "" + +#: bin/wp-cli.php:71 +msgid "Adding mapping..." +msgstr "" + +#: bin/wp-cli.php:109 +#, php-format +msgid "Deleting index for site %d..." msgstr "" -#: classes/class-ep-elasticpress.php:106 classes/class-ep-elasticpress.php:142 -#: classes/class-ep-elasticpress.php:166 classes/class-ep-elasticpress.php:206 -#: classes/class-ep-elasticpress.php:332 -msgid "You do not have sufficient permissions to access this page." +#: bin/wp-cli.php:114 bin/wp-cli.php:127 +msgid "Index deleted" msgstr "" -#: classes/class-ep-elasticpress.php:110 classes/class-ep-elasticpress.php:210 -msgid "Are you lost?" +#: bin/wp-cli.php:116 +msgid "Delete index failed" msgstr "" -#: classes/class-ep-elasticpress.php:276 -msgid "ElasticPress Settings" +#: bin/wp-cli.php:122 +msgid "Deleting index..." msgstr "" -#: classes/class-ep-elasticpress.php:279 classes/class-ep-elasticpress.php:352 -msgid "Host:" +#: bin/wp-cli.php:129 +msgid "Index delete failed" msgstr "" -#: classes/class-ep-elasticpress.php:284 classes/class-ep-elasticpress.php:357 -msgid "Index Name:" +#: bin/wp-cli.php:147 bin/wp-cli.php:253 +msgid "Recreating network alias..." msgstr "" -#: classes/class-ep-elasticpress.php:289 -msgid "Post Types to Index:" +#: bin/wp-cli.php:154 bin/wp-cli.php:277 +msgid "Done!" msgstr "" -#: classes/class-ep-elasticpress.php:305 -msgid "Post Sync" +#: bin/wp-cli.php:156 +msgid "An error occurred" msgstr "" -#: classes/class-ep-elasticpress.php:307 +#: bin/wp-cli.php:233 +msgid "Indexing posts network-wide..." +msgstr "" + +#: bin/wp-cli.php:244 bin/wp-cli.php:265 +#, php-format +msgid "Number of posts indexed on site %d: %d" +msgstr "" + +#: bin/wp-cli.php:247 bin/wp-cli.php:268 +#, php-format +msgid "Number of post index errors on site %d: %d" +msgstr "" + +#: bin/wp-cli.php:257 +#, php-format +msgid "Total number of posts indexed: %d" +msgstr "" + +#: bin/wp-cli.php:261 +msgid "Indexing posts..." +msgstr "" + +#: bin/wp-cli.php:272 +msgid "Total time elapsed: " +msgstr "" + +#: bin/wp-cli.php:503 msgid "" -"A sync will send all the posts in post types marked for sync to your " -"Elasticsearch server.\n" -"\t\t\t\tExisting posts will be updated. This can take hours depending on how " -"many posts you have in your\n" -"\t\t\t\tdatabase." +"The following posts failed to index:\r\n" +"\r\n" +msgstr "" + +#: bin/wp-cli.php:652 +msgid "EP_HOST is not defined! Check wp-config.php" msgstr "" -#: classes/class-ep-elasticpress.php:312 classes/class-ep-elasticpress.php:390 -msgid "Start Sync" +#: bin/wp-cli.php:656 +msgid "Unable to reach Elasticsearch Server! Check that service is running." msgstr "" -#: classes/class-ep-elasticpress.php:315 classes/class-ep-elasticpress.php:393 -msgid "Syncs are currently running." +#: classes/class-ep-config.php:56 classes/class-ep-config.php:81 +msgid "No running host available." msgstr "" -#: classes/class-ep-elasticpress.php:317 classes/class-ep-elasticpress.php:395 -msgid "Cancel Sync" +#: classes/class-ep-index-gui.php:102 includes/settings/index.php:14 +msgid "Running Index..." msgstr "" -#: classes/class-ep-elasticpress.php:344 -msgid "ElasticPress Network Settings" +#: classes/class-ep-index-gui.php:103 includes/settings/index.php:14 +msgid "Run Index" msgstr "" -#: classes/class-ep-elasticpress.php:347 -msgid "Activate Cross Site Search:" +#: classes/class-ep-index-gui.php:104 +msgid "items indexed" msgstr "" -#: classes/class-ep-elasticpress.php:368 -msgid "Post Types for Site:" +#: classes/class-ep-index-gui.php:105 +msgid "We're Still counting total items for the index. Please be patient" +msgstr "" + +#: classes/class-ep-index-gui.php:155 classes/class-ep-settings.php:113 +msgid "Security error!" +msgstr "" + +#: classes/class-ep-index-gui.php:187 +msgid "" +"Mappings could not be completed. If the error persists contact your system " +"administrator" +msgstr "" + +#: classes/class-ep-index-gui.php:201 +msgid "" +"Indexing could not be completed. If the error persists contact your system " +"administrator" +msgstr "" + +#: classes/class-ep-index-worker.php:390 +msgid "The following posts failed to index:" +msgstr "" + +#: classes/class-ep-index-worker.php:401 +msgid ": ElasticPress Index Errors" +msgstr "" + +#: classes/class-ep-settings.php:145 +msgid "ElasticSearch Host:" +msgstr "" + +#: classes/class-ep-settings.php:146 +msgid "ElasticPress API Key:" +msgstr "" + +#: classes/class-ep-settings.php:154 +msgid "Use ElasticSearch:" +msgstr "" + +#: classes/class-ep-settings.php:387 +msgid "ElasticSearch Integration Options" +msgstr "" + +#: classes/class-ep-wp-date-query.php:488 +#, php-format +msgid "" +"Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s." +msgstr "" + +#: classes/class-ep-wp-date-query.php:518 +#, php-format +msgid "" +"The following values do not describe a valid date: year %1$s, month %2$s, " +"day %3$s." +msgstr "" + +#: classes/class-ep-wp-date-query.php:535 +#, php-format +msgid "" +"The following values do not describe a valid date: month %1$s, day %2$s." +msgstr "" + +#: includes/settings-page.php:13 +msgid "ElasticPress" msgstr "" -#: classes/class-ep-elasticpress.php:383 -msgid "Site-wide Post Sync" +#: includes/settings/status.php:22 +msgid "ElasticSearch Host" msgstr "" -#: classes/class-ep-elasticpress.php:385 +#: includes/settings/status.php:27 msgid "" -"A site-wide sync will send all the posts in post types marked for sync to " -"your\n" -"\t\t\t\tElasticsearch server. Existing posts will be updated. This can take " -"hours depending on how many\n" -"\t\t\t\tposts you have across your network." +"Current host is set but cannot be contacted. Please contact the server " +"administrator." +msgstr "" + +#: includes/settings/status.php:31 +msgid "A host has not been set. You must set a host to continue." +msgstr "" + +#: includes/settings/status.php:42 +msgid "Plugin Status" +msgstr "" + +#: includes/settings/status.php:45 +msgid "Connected to ElasticSearch." +msgstr "" + +#: includes/settings/status.php:50 +msgid "ElasticPress can override WP search." +msgstr "" + +#: includes/settings/status.php:56 +msgid "" +"ElasticPress is not activated and cannot override WP search. You can " +"activate it on the form to the left." +msgstr "" + +#: includes/settings/status.php:61 +msgid "System Stats" +msgstr "" + +#: includes/settings/status.php:65 includes/settings/status.php:134 +msgid "Search Stats" +msgstr "" + +#: includes/settings/status.php:69 includes/settings/status.php:137 +msgid "Total Queries:" +msgstr "" + +#: includes/settings/status.php:72 includes/settings/status.php:140 +msgid "Query Time:" +msgstr "" + +#: includes/settings/status.php:76 includes/settings/status.php:143 +msgid "Total Fetches:" +msgstr "" + +#: includes/settings/status.php:79 includes/settings/status.php:146 +msgid "Fetch Time:" +msgstr "" + +#: includes/settings/status.php:88 includes/settings/status.php:152 +msgid "Index Stats" +msgstr "" + +#: includes/settings/status.php:92 includes/settings/status.php:155 +msgid "Index Total:" +msgstr "" + +#: includes/settings/status.php:95 includes/settings/status.php:158 +msgid "Index Time:" +msgstr "" + +#: includes/settings/status.php:106 +msgid "Site Stats" +msgstr "" + +#: includes/settings/status.php:111 +msgid "Select a site:" +msgstr "" + +#: includes/settings/status.php:112 +msgid "Select" +msgstr "" + +#: includes/settings/status.php:174 +msgid "Cluster Stats" +msgstr "" + +#: includes/settings/status.php:184 +msgid "Disk Usage:" +msgstr "" + +#: includes/settings/status.php:187 +msgid "Disk Space Available:" +msgstr "" + +#: includes/settings/status.php:190 +msgid "Total Disk Space:" +msgstr "" + +#: includes/settings/status.php:203 +msgid "ERROR:" +msgstr "" + +#: node_modules/grunt-pot/test/fixtures/some-file.php:3 +msgid "I'm a translatable string." +msgstr "" + +#: node_modules/grunt-pot/test/fixtures/some-other-file.php:4 +msgid "Me too" +msgstr "" + +#: node_modules/grunt-pot/test/fixtures/some-other-file.php:7 +#, php-format +msgid "I have %d apple" +msgid_plural "I have %d apples" +msgstr[0] "" +msgstr[1] "" + +#. / TRANSLATORS: This should be translated as a shorthand for YEAR-MONTH-DAY using 4, 2 and 2 digits. +#: node_modules/grunt-pot/test/fixtures/some-other-file.php:16 +msgid "yyyy-mm-dd" msgstr "" From 565d21d37d41dffb95650a231d03e83c3c8cb813 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Fri, 20 Nov 2015 14:09:15 -0500 Subject: [PATCH 011/117] Indexing GUI seems to be working --- assets/js/elasticpress-admin.js | 8 +- assets/js/elasticpress-admin.min.js | 2 +- assets/js/elasticpress-index-admin.js | 20 +- assets/js/elasticpress-index-admin.min.js | 2 +- classes/class-ep-index-gui.php | 10 +- classes/class-ep-index-status.php | 66 +++ classes/class-ep-index-worker.php | 2 +- classes/class-ep-lib.php | 566 ++++++++++++++++++++++ classes/class-ep-settings.php | 14 +- elasticpress.php | 40 +- includes/settings/form.php | 4 +- includes/settings/index.php | 6 +- includes/settings/status.php | 32 +- lang/elasticpress.pot | 129 +---- 14 files changed, 745 insertions(+), 156 deletions(-) create mode 100644 classes/class-ep-index-status.php create mode 100644 classes/class-ep-lib.php diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 9f2c383249..1814edb36f 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -4,15 +4,13 @@ jQuery ( document ).ready ( function ( $ ) { /** * Show site stats */ - $( '#jovo_site_select' ).change( function() { - - console.log( 'test' ); + $( '#ep_site_select' ).change( function() { var siteId = $( this ).val(); - $( '.jovo_site' ).hide(); + $( '.ep_site' ).hide(); - $( '#jovo_' + siteId ).show(); + $( '#ep_' + siteId ).show(); } ); diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index ad95876377..70e9eef4f1 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){a("#jovo_site_select").change(function(){console.log("test");var b=a(this).val();a(".jovo_site").hide(),a("#jovo_"+b).show()})}); \ No newline at end of file +jQuery(document).ready(function(a){a("#jovo_site_select").change(function(){var b=a(this).val();a(".jovo_site").hide(),a("#jovo_"+b).show()})}); \ No newline at end of file diff --git a/assets/js/elasticpress-index-admin.js b/assets/js/elasticpress-index-admin.js index 31eea62646..1649529e6f 100644 --- a/assets/js/elasticpress-index-admin.js +++ b/assets/js/elasticpress-index-admin.js @@ -5,7 +5,7 @@ jQuery ( document ).ready ( function ( $ ) { */ var performIndex = function ( resetBar, button ) { - $ ( button ).val ( jovo.running_index_text ).removeClass ( 'button-primary' ); + $ ( button ).val ( ep.running_index_text ).removeClass ( 'button-primary' ); //Make sure the progress bar is showing var bar = $ ( '#progressbar' ), @@ -17,14 +17,14 @@ jQuery ( document ).ready ( function ( $ ) { var progress = 0; - if ( parseInt ( jovo.total_posts ) > 0 ) { + if ( parseInt ( ep.total_posts ) > 0 ) { - progress = parseFloat ( jovo.synced_posts ) / parseFloat ( jovo.total_posts ); - status.html ( jovo.synced_posts + '/' + jovo.total_posts + 'items' ); + progress = parseFloat ( ep.synced_posts ) / parseFloat ( ep.total_posts ); + status.html ( ep.synced_posts + '/' + ep.total_posts + 'items' ); } else { - status.html ( jovo.counting_items ); + status.html ( ep.counting_items ); } @@ -47,7 +47,7 @@ jQuery ( document ).ready ( function ( $ ) { var data = { action : 'ep_launch_index', - nonce : jovo.nonce + nonce : ep.nonce }; //call the ajax @@ -68,7 +68,7 @@ jQuery ( document ).ready ( function ( $ ) { } ); - status.html ( response.responseJSON.data.ep_posts_synced + '/' + response.responseJSON.data.ep_posts_total + ' ' + jovo.items_indexed ); + status.html ( response.responseJSON.data.ep_posts_synced + '/' + response.responseJSON.data.ep_posts_total + ' ' + ep.items_indexed ); performIndex ( false, button ); @@ -84,7 +84,7 @@ jQuery ( document ).ready ( function ( $ ) { $ ( '#progressbar' ).fadeOut ( 'slow' ); $ ( '#progressstats' ).html ( 'Index complete Refresh the stats' ); - $ ( '#jovo_run_index' ).val ( jovo.index_complete_text ).addClass ( 'button-primary' ); + $ ( '#ep_run_index' ).val ( ep.index_complete_text ).addClass ( 'button-primary' ); }, 1000 ); @@ -98,12 +98,12 @@ jQuery ( document ).ready ( function ( $ ) { }; // The run index button - var run_index_button = $ ( '#jovo_run_index' ); + var run_index_button = $ ( '#ep_run_index' ); /** * Start the poll if we need it */ - if ( 1 === jovo.index_running ) { + if ( 1 === ep.index_running ) { performIndex ( true, run_index_button ); } diff --git a/assets/js/elasticpress-index-admin.min.js b/assets/js/elasticpress-index-admin.min.js index 342a03b1de..929aeb3c73 100644 --- a/assets/js/elasticpress-index-admin.min.js +++ b/assets/js/elasticpress-index-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,d){a(d).val(jovo.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(jovo.total_posts)>0?(g=parseFloat(jovo.synced_posts)/parseFloat(jovo.total_posts),f.html(jovo.synced_posts+"/"+jovo.total_posts+"items")):f.html(jovo.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:jovo.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+jovo.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#jovo_run_index").val(jovo.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#jovo_run_index");1===jovo.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index f3325fcbec..2594da2e0c 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -69,11 +69,11 @@ public function action_admin_enqueue_scripts() { // Enqueue more easily debugged version if applicable. if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { - wp_register_script( 'ep_index', EP_URL . 'assets/js/elasticpress-index-admin.js', array( 'jquery', 'jquery-ui-progressbar' ), JOVO_VERSION ); + wp_register_script( 'ep_index', EP_URL . 'assets/js/elasticpress-index-admin.js', array( 'jquery', 'jquery-ui-progressbar' ), EP_VERSION ); } else { - wp_register_script( 'ep_index', EP_URL . 'assets/js/elasticpress-index-admin.min.js', array( 'jquery', 'jquery-ui-progressbar' ), JOVO_VERSION ); + wp_register_script( 'ep_index', EP_URL . 'assets/js/elasticpress-index-admin.min.js', array( 'jquery', 'jquery-ui-progressbar' ), EP_VERSION ); } @@ -179,9 +179,9 @@ public function action_wp_ajax_ep_launch_index() { if ( false === get_transient( 'ep_index_offset' ) ) { // Deactivate our search integration. - Jovo_Lib::ep_deactivate(); + EP_Lib::ep_deactivate(); - $mapping_success = Jovo_Lib::put_mapping(); + $mapping_success = EP_Lib::put_mapping(); if ( ! $mapping_success ) { wp_send_json_error( esc_html__( 'Mappings could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); @@ -204,7 +204,7 @@ public function action_wp_ajax_ep_launch_index() { if ( false === get_transient( 'ep_index_offset' ) ) { // Reactivate our search integration. - Jovo_Lib::ep_activate(); + EP_Lib::ep_activate(); $data = array( 'ep_sync_complete' => 1, diff --git a/classes/class-ep-index-status.php b/classes/class-ep-index-status.php new file mode 100644 index 0000000000..08f1d00984 --- /dev/null +++ b/classes/class-ep-index-status.php @@ -0,0 +1,66 @@ + + */ + +/** + * Add index status to individual content + * + * Adds a status icon showing the current index status for the displayed content + * on the content's edit page. + */ +class EP_Index_Status { + + /** + * Setup the Index Status + * + * Wires actions and filters for the index status indicators. + * + * @since 1.7 + * + * @return EP_Index_Status + */ + public function __construct() { + + add_action( 'post_submitbox_misc_actions', array( $this, 'post_submitbox_misc_actions' ) ); + + } + + /** + * Lists index status + * + * Shows the index status of individual posts. + * + * @since 1.7 + * + * @return void + */ + public function post_submitbox_misc_actions() { + + global $post; + + $post_types = ep_get_indexable_post_types(); + + if ( in_array( $post->post_type, $post_types ) && ep_is_activated() && ep_index_exists() ) { + + $post_status = ep_get_post( $post->ID ); + $fill = 'red'; + + if ( $post_status ) { + $fill = '#90EE90'; + } + + echo '
'; + echo ' '; + echo ''; + echo '
'; + + } + } +} diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index 5b8671873c..0f37430c98 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -81,7 +81,7 @@ protected function _create_network_alias() { */ public function index( $network_wide = false ) { - Jovo_Lib::check_host(); + EP_Lib::check_host(); $total_indexed = 0; diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php new file mode 100644 index 0000000000..16c87d1a3d --- /dev/null +++ b/classes/class-ep-lib.php @@ -0,0 +1,566 @@ + + */ + +/** + * ElasticPress utility functions + * + * Various utility functions for use throughout ElasticPress + */ +class EP_Lib { + + /** + * Activate ElasticPress + * + * Activates ElasticPress search allowing the site to use ElasticPress search. + * + * @since 1.7 + * + * @return bool True on success or false + */ + public static function ep_activate() { + + EP_Lib::check_host(); + + $status = ep_is_activated(); + + if ( $status ) { + + return true; + + } else { + + $result = ep_activate(); + + if ( $result ) { + + return true; + + } else { + + return false; + + } + } + } + + /** + * Get ElasticSearch plugins + * + * Gets a list of available ElasticSearch plugins. + * + * @since 0.3.0 + * + * @return array Array of plugins and their version or error message + */ + public static function ep_get_plugins() { + + $plugins = get_transient( 'ep_installed_plugins' ); + + if ( is_array( $plugins ) ) { + return $plugins; + } + + $plugins = array(); + + if ( is_wp_error( ep_get_host() ) ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + ); + + } + + $path = '/_nodes?plugin=true'; + + $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); + + if ( ! is_wp_error( $request ) ) { + + $response = json_decode( wp_remote_retrieve_body( $request ), true ); + + if ( isset( $response['nodes'] ) ) { + + foreach ( $response['nodes'] as $node ) { + + if ( isset( $node['plugins'] ) && is_array( $node['plugins'] ) ) { + + foreach ( $node['plugins'] as $plugin ) { + + $plugins[ $plugin['name'] ] = $plugin['version']; + + } + + break; + + } + } + } + + set_transient( 'ep_installed_plugins', $plugins, apply_filters( 'ep_installed_plugins_exp', 3600 ) ); + + return $plugins; + + } + + return array( + 'status' => false, + 'msg' => $request->get_error_message(), + ); + + } + + /** + * Deactivate ElasticPress + * + * Deactivates ElasticPress search forcing the site to use native search. + * + * @since 1.7 + * + * @return bool True on success or false + */ + public static function ep_deactivate() { + + EP_Lib::check_host(); + + $status = ep_is_activated(); + + if ( ! $status ) { + + return true; + + } else { + + $result = ep_deactivate(); + + if ( $result ) { + + return true; + + } else { + + return false; + + } + } + } + + /** + * Check if connection is alive. + * + * Provide better error messaging for common connection errors + * + * @since 1.7 + * + * @return bool|WP_Error true on success or WP_Error + */ + public static function check_host() { + + global $ep_backup_host; + + if ( ! defined( 'EP_HOST' ) && ! is_array( $ep_backup_host ) ) { + EP_Lib::set_host(); + } + + if ( ! defined( 'EP_HOST' ) && ! is_array( $ep_backup_host ) ) { + return new WP_Error( 'elasticpress', esc_html__( 'EP_HOST is not defined! Check wp-config.php', 'elasticpress' ) ); + } + + if ( false === ep_elasticsearch_alive() ) { + return new WP_Error( 'elasticpress', esc_html__( 'Unable to reach Elasticsearch Server! Check that service is running.', 'elasticpress' ) ); + } + + return true; + + } + + /** + * Parse response from Elasticsearch + * + * Determines if there is an issue or if the response is valid. + * + * @since 1.7 + * + * @param object $response JSON decoded response from ElasticSearch. + * + * @return array Contains the status message or the returned statistics. + */ + public static function parse_response( $response ) { + + if ( null === $response ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'Invalid response from ElasticPress server. Please contact your administrator.' ), + ); + + } elseif ( isset( $response->error ) && stristr( $response->error, 'IndexMissingException' ) ) { + + if ( is_multisite() ) { + + $error = __( 'Site not indexed.

Please run: wp elasticpress index --setup --network-wide using WP-CLI. Or use the index button on the left of this screen.

', 'elasticpress' ); + + } else { + + $error = __( 'Site not indexed.

Please run: wp elasticpress index --setup using WP-CLI. Or use the index button on the left of this screen.

', 'elasticpress' ); + + } + + return array( + 'status' => false, + 'msg' => $error, + ); + + } + + return array( 'status' => true, 'data' => $response->_all->primaries->indexing ); + + } + + /** + * Set EP_HOST if needed + * + * Retrieves the value set in options the host and defines EP_HOST constant. + * + * @since 1.7 + * + * @return void + */ + public static function set_host() { + + $ep_host = get_site_option( 'ep_host' ); + + if ( $ep_host && ! defined( 'EP_HOST' ) ) { + define( 'EP_HOST', $ep_host ); + } + } + + /** + * Set EP_API_KEY if needed + * + * Retrieves the value set in options the api key and defines EP_API_KEY constant. + * + * @since 0.3.0 + * + * @return void + */ + public static function set_api_key() { + + $ep_api_key = get_site_option( 'ep_api_key' ); + + if ( $ep_api_key && ! defined( 'EP_API_KEY' ) ) { + define( 'EP_API_KEY', $ep_api_key ); + } + } + + /** + * Retrieve Index status + * + * Retrieves index stats from ElasticSearch. + * + * @since 1.7 + * + * @param int $blog_id Id of blog to get stats. + * + * @return array Contains the status message or the returned statistics. + */ + public static function ep_get_index_status( $blog_id = null ) { + + return EP_Lib::get_index_status( $blog_id ); + + } + + /** + * Retrieve cluster stats + * + * Retrieves cluster stats from ElasticSearch. + * + * @since 1.7 + * + * @return array Contains the status message or the returned statistics. + */ + public static function ep_get_cluster_status() { + + return EP_Lib::get_cluster_status(); + + } + + /** + * Retrieve search stats + * + * Retrieves search stats from ElasticSearch. + * + * @since 1.7 + * + * @param int $blog_id Id of blog to get stats. + * + * @return array Contains the status message or the returned statistics. + */ + public static function ep_get_search_status( $blog_id = null ) { + + return EP_Lib::get_search_status( $blog_id ); + + } + + /** + * Easily read bytes + * + * Converts bytes to human-readable format. + * + * @since 1.7 + * + * @param int $bytes The raw bytes to convert. + * @param int $precision The precision with which to display the conversion. + * + * @return string + */ + public static function ep_byte_size( $bytes, $precision = 2 ) { + + $kilobyte = 1024; + $megabyte = $kilobyte * 1024; + $gigabyte = $megabyte * 1024; + $terabyte = $gigabyte * 1024; + + if ( ( $bytes >= 0 ) && ( $bytes < $kilobyte ) ) { + + return $bytes . ' B'; + + } elseif ( ( $bytes >= $kilobyte ) && ( $bytes < $megabyte ) ) { + + return round( $bytes / $kilobyte, $precision ) . ' KB'; + + } elseif ( ( $bytes >= $megabyte ) && ( $bytes < $gigabyte ) ) { + + return round( $bytes / $megabyte, $precision ) . ' MB'; + + } elseif ( ( $bytes >= $gigabyte ) && ( $bytes < $terabyte ) ) { + + return round( $bytes / $gigabyte, $precision ) . ' GB'; + + } elseif ( $bytes >= $terabyte ) { + + return round( $bytes / $terabyte, $precision ) . ' TB'; + + } else { + + return $bytes . ' B'; + + } + } + + /** + * Add the document mapping + * + * Creates the document mapping for the index. + * + * @since 1.7 + * + * @param bool $network_wide whether to index network wide or not. + * + * @return bool true on success or false + */ + public static function put_mapping( $network_wide = false ) { + + EP_Lib::check_host(); + + if ( true === $network_wide && is_multisite() ) { + + $sites = ep_get_sites(); + $success = array(); + + foreach ( $sites as $site ) { + + switch_to_blog( $site['blog_id'] ); + + // Deletes index first. + ep_delete_index(); + + $result = ep_put_mapping(); + + if ( $result ) { + + $success[ $site['blog_id'] ] = true; + + } else { + + $success[ $site['blog_id'] ] = false; + + } + + restore_current_blog(); + } + + if ( array_search( false, $success ) ) { + return $success; + } + + return true; + + } else { + + // Deletes index first. + ep_delete_index(); + + $result = ep_put_mapping(); + + if ( $result ) { + return true; + } + + return false; + + } + } + + /** + * Get cluster status + * + * Retrieves cluster stats from ElasticSearch. + * + * @since 1.7 + * + * @return array Contains the status message or the returned statistics. + */ + public static function get_cluster_status() { + + if ( is_wp_error( ep_get_host() ) ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + ); + + } else { + + $request = ep_remote_request( '_cluster/stats', array( 'method' => 'GET' ) ); + + if ( ! is_wp_error( $request ) ) { + + $response = json_decode( wp_remote_retrieve_body( $request ) ); + + return $response; + + } + + return array( + 'status' => false, + 'msg' => $request->get_error_message(), + ); + + } + } + + /** + * Get index status + * + * Retrieves index stats from ElasticSearch. + * + * @since 1.7 + * + * @param int $blog_id Id of blog to get stats. + * + * @return array Contains the status message or the returned statistics. + */ + public static function get_index_status( $blog_id = null ) { + + if ( is_wp_error( ep_get_host( true ) ) ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + ); + + } else { + + if ( is_multisite() && null === $blog_id ) { + + $path = ep_get_network_alias() . '/_stats/indexing/'; + + } else { + + $path = ep_get_index_name( $blog_id ) . '/_stats/indexing/'; + + } + + $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); + + } + + if ( ! is_wp_error( $request ) ) { + + $response = json_decode( wp_remote_retrieve_body( $request ) ); + + return EP_Lib::parse_response( $response ); + + } + + return array( + 'status' => false, + 'msg' => $request->get_error_message(), + ); + + } + + /** + * Retrieves search stats from ElasticSearch. + * + * Retrieves various search statistics from the ES server. + * + * @since 1.0.0 + * + * @param int $blog_id Id of blog to get stats. + * + * @return array Contains the status message or the returned statistics. + */ + public static function get_search_status( $blog_id = null ) { + + if ( is_wp_error( ep_get_host() ) ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + ); + + } else { + + if ( is_multisite() && null === $blog_id ) { + + $path = ep_get_network_alias() . '/_stats/search/'; + + } else { + + $path = ep_get_index_name( $blog_id ) . '/_stats/search/'; + + } + + $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); + + } + + if ( ! is_wp_error( $request ) ) { + + $stats = json_decode( wp_remote_retrieve_body( $request ) ); + + if ( isset( $stats->_all ) ) { + return $stats->_all->primaries->search; + } + + return false; + + } + + return array( + 'status' => false, + 'msg' => $request->get_error_message(), + ); + + } +} diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 0c0554d8ce..5a3c8356a8 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -36,8 +36,8 @@ class EP_Settings { */ public function __construct() { - Jovo_Lib::set_api_key(); - Jovo_Lib::check_host(); + EP_Lib::set_api_key(); + EP_Lib::check_host(); if ( is_multisite() ) { // Must be network admin in multisite. @@ -140,16 +140,16 @@ public function action_admin_init() { add_settings_section( 'ep_settings_section_main', '', array( $this, 'ep_settings_section_hightlight' ), 'elasticpress' ); - if ( is_wp_error( Jovo_Lib::check_host() ) || get_site_option( 'ep_host' ) ) { + if ( is_wp_error( EP_Lib::check_host() ) || get_site_option( 'ep_host' ) ) { add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( $this, 'setting_callback_host' ), 'elasticpress', 'ep_settings_section_main' ); add_settings_field( 'ep_api_key', esc_html__( 'ElasticPress API Key:', 'elasticpress' ), array( $this, 'setting_callback_api_key' ), 'elasticpress', 'ep_settings_section_main' ); } - $stats = Jovo_Lib::ep_get_index_status(); + $stats = EP_Lib::ep_get_index_status(); - if ( $stats['status'] && ! is_wp_error( Jovo_Lib::check_host() ) ) { + if ( $stats['status'] && ! is_wp_error( EP_Lib::check_host() ) ) { add_settings_field( 'ep_activate', esc_html__( 'Use ElasticSearch:', 'elasticpress' ), array( $this, 'setting_callback_activate' ), 'elasticpress', 'ep_settings_section_main' ); @@ -280,11 +280,11 @@ public function sanitize_ep_activate( $input ) { if ( true === $input ) { - Jovo_Lib::ep_activate(); + EP_Lib::ep_activate(); } else { - Jovo_Lib::ep_deactivate(); + EP_Lib::ep_deactivate(); } diff --git a/elasticpress.php b/elasticpress.php index 92627d3c4b..578bb38b19 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -15,8 +15,8 @@ * Copyright (C) 2013 SearchPress */ - if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly. +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly. } define( 'EP_URL', plugin_dir_url( __FILE__ ) ); @@ -35,3 +35,39 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) { require_once 'bin/wp-cli.php'; } + +add_action( 'plugins_loaded', 'ep_loader' ); + +/** + * Loads GUI classes if needed. + */ +function ep_loader() { + + if ( class_exists( 'EP_Config' ) ) { + + load_plugin_textdomain( 'elasticpress', false, dirname( dirname( __FILE__ ) ) . '/lang' ); // Load any available translations first. + + // Load the common library. + require( dirname( __FILE__ ) . '/classes/class-ep-lib.php' ); + + // Load the settings page. + require( dirname( __FILE__ ) . '/classes/class-ep-settings.php' ); + new EP_Settings(); + + // Load the indexing GUI. + if ( ! is_multisite() && true === apply_filters( 'ep_load_index_gui', true ) ) { + + require( dirname( __FILE__ ) . '/classes/class-ep-index-gui.php' ); + new EP_Index_GUI(); + + } + + // Load index statuses. + if ( true === apply_filters( 'ep_load_index_status', true ) ) { + + require( dirname( __FILE__ ) . '/classes/class-ep-index-status.php' ); + new EP_Index_Status(); + + } + } +} diff --git a/includes/settings/form.php b/includes/settings/form.php index 909777378c..0def75d4b0 100644 --- a/includes/settings/form.php +++ b/includes/settings/form.php @@ -25,9 +25,9 @@ settings_fields( 'elasticpress' ); do_settings_sections( 'elasticpress' ); - $stats = Jovo_Lib::ep_get_index_status(); + $stats = EP_Lib::ep_get_index_status(); - if ( ( $stats['status'] && ! is_wp_error( Jovo_Lib::check_host() ) ) || is_wp_error( Jovo_Lib::check_host() ) || get_site_option( 'jovo_host' ) ) { + if ( ( $stats['status'] && ! is_wp_error( EP_Lib::check_host() ) ) || is_wp_error( EP_Lib::check_host() ) || get_site_option( 'ep_host' ) ) { submit_button(); } diff --git a/includes/settings/index.php b/includes/settings/index.php index 2744bad548..650188bd71 100644 --- a/includes/settings/index.php +++ b/includes/settings/index.php @@ -10,12 +10,12 @@ */ ?>

- +

diff --git a/includes/settings/status.php b/includes/settings/status.php index 0602745eb1..721e7cde87 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -2,17 +2,17 @@ /** * Template for displaying Elasticsearch statistics * - * @since 1.7 + * @since 0.1.0 * - * @package elasticpress + * @package Jovosearch * * @author Allan Collins */ -$stats = Jovo_Lib::ep_get_index_status(); -$search_stats = Jovo_lib::ep_get_search_status(); +$stats = EP_Lib::ep_get_index_status(); +$search_stats = EP_Lib::ep_get_search_status(); -echo '

'; +echo '
'; ?> @@ -20,7 +20,7 @@ - + @@ -101,14 +101,14 @@ '; + echo '
'; printf( '

%s

', esc_html__( 'Site Stats', 'elasticpress' ) ); $sites = ep_get_sites(); - echo '
'; - echo '' . esc_html__( 'Select a site:', 'elasticpress' ) . ' '; echo ''; foreach ( $sites as $site ) { @@ -124,11 +124,11 @@ foreach ( $sites as $site ) { - $stats = Jovo_Lib::ep_get_index_status( $site['blog_id'] ); - $search_stats = Jovo_Lib::ep_get_search_status( $site['blog_id'] ); + $stats = EP_Lib::ep_get_index_status( $site['blog_id'] ); + $search_stats = EP_Lib::ep_get_search_status( $site['blog_id'] ); $details = get_blog_details( $site['blog_id'] ); ?> -
+
%s', esc_html__( 'Search Stats', 'elasticpress' ) ); ?> @@ -169,12 +169,12 @@ } ?> -
+
%s', esc_html__( 'Cluster Stats', 'elasticpress' ) ); ?> nodes->fs; $disk_usage = $fs->total_in_bytes - $fs->available_in_bytes; ?> @@ -184,10 +184,10 @@ total_in_bytes ) * 100, 0 ) ); ?>%
  • - available_in_bytes ) ); ?> + available_in_bytes ) ); ?>
  • - total_in_bytes ) ); ?> + total_in_bytes ) ); ?>
  • diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 3fd8453da9..594984b144 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-11-20 13:40-0500\n" +"POT-Creation-Date: 2015-11-20 14:04-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -101,11 +101,11 @@ msgid "" "\r\n" msgstr "" -#: bin/wp-cli.php:652 +#: bin/wp-cli.php:652 classes/class-ep-lib.php:174 msgid "EP_HOST is not defined! Check wp-config.php" msgstr "" -#: bin/wp-cli.php:656 +#: bin/wp-cli.php:656 classes/class-ep-lib.php:178 msgid "Unable to reach Elasticsearch Server! Check that service is running." msgstr "" @@ -153,6 +153,29 @@ msgstr "" msgid ": ElasticPress Index Errors" msgstr "" +#: classes/class-ep-lib.php:77 classes/class-ep-lib.php:438 +#: classes/class-ep-lib.php:478 classes/class-ep-lib.php:529 +msgid "ElasticSearch Host is not available." +msgstr "" + +#: classes/class-ep-lib.php:202 +msgid "" +"Invalid response from ElasticPress server. Please contact your administrator." +msgstr "" + +#: classes/class-ep-lib.php:209 +msgid "" +"Site not indexed.

    Please run: wp elasticpress index --setup --" +"network-wide using WP-CLI. Or use the index button on the left of " +"this screen.

    " +msgstr "" + +#: classes/class-ep-lib.php:213 +msgid "" +"Site not indexed.

    Please run: wp elasticpress index --setup " +"using WP-CLI. Or use the index button on the left of this screen.

    " +msgstr "" + #: classes/class-ep-settings.php:145 msgid "ElasticSearch Host:" msgstr "" @@ -192,106 +215,6 @@ msgstr "" msgid "ElasticPress" msgstr "" -#: includes/settings/status.php:22 -msgid "ElasticSearch Host" -msgstr "" - -#: includes/settings/status.php:27 -msgid "" -"Current host is set but cannot be contacted. Please contact the server " -"administrator." -msgstr "" - -#: includes/settings/status.php:31 -msgid "A host has not been set. You must set a host to continue." -msgstr "" - -#: includes/settings/status.php:42 -msgid "Plugin Status" -msgstr "" - -#: includes/settings/status.php:45 -msgid "Connected to ElasticSearch." -msgstr "" - -#: includes/settings/status.php:50 -msgid "ElasticPress can override WP search." -msgstr "" - -#: includes/settings/status.php:56 -msgid "" -"ElasticPress is not activated and cannot override WP search. You can " -"activate it on the form to the left." -msgstr "" - -#: includes/settings/status.php:61 -msgid "System Stats" -msgstr "" - -#: includes/settings/status.php:65 includes/settings/status.php:134 -msgid "Search Stats" -msgstr "" - -#: includes/settings/status.php:69 includes/settings/status.php:137 -msgid "Total Queries:" -msgstr "" - -#: includes/settings/status.php:72 includes/settings/status.php:140 -msgid "Query Time:" -msgstr "" - -#: includes/settings/status.php:76 includes/settings/status.php:143 -msgid "Total Fetches:" -msgstr "" - -#: includes/settings/status.php:79 includes/settings/status.php:146 -msgid "Fetch Time:" -msgstr "" - -#: includes/settings/status.php:88 includes/settings/status.php:152 -msgid "Index Stats" -msgstr "" - -#: includes/settings/status.php:92 includes/settings/status.php:155 -msgid "Index Total:" -msgstr "" - -#: includes/settings/status.php:95 includes/settings/status.php:158 -msgid "Index Time:" -msgstr "" - -#: includes/settings/status.php:106 -msgid "Site Stats" -msgstr "" - -#: includes/settings/status.php:111 -msgid "Select a site:" -msgstr "" - -#: includes/settings/status.php:112 -msgid "Select" -msgstr "" - -#: includes/settings/status.php:174 -msgid "Cluster Stats" -msgstr "" - -#: includes/settings/status.php:184 -msgid "Disk Usage:" -msgstr "" - -#: includes/settings/status.php:187 -msgid "Disk Space Available:" -msgstr "" - -#: includes/settings/status.php:190 -msgid "Total Disk Space:" -msgstr "" - -#: includes/settings/status.php:203 -msgid "ERROR:" -msgstr "" - #: node_modules/grunt-pot/test/fixtures/some-file.php:3 msgid "I'm a translatable string." msgstr "" From 374944cd01c41fbac1e67ba08ec5ec0b97bfd7f5 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Fri, 20 Nov 2015 14:28:39 -0500 Subject: [PATCH 012/117] Update uninstall --- uninstall.php | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 uninstall.php diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 0000000000..a07a3726f1 --- /dev/null +++ b/uninstall.php @@ -0,0 +1,96 @@ + + */ + +/** + * Class EP_Uninstaller + */ +class EP_Uninstaller { + + /** + * Initialize uninstaller + * + * Perform some checks to make sure plugin can/should be uninstalled + * + * @since 1.7 + * + * @return EP_Uninstaller + */ + public function __construct() { + + // Exit if accessed directly. + if ( ! defined( 'ABSPATH' ) ) { + $this->exit_uninstaller(); + } + + // Not uninstalling. + if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { + $this->exit_uninstaller(); + } + + // Not uninstalling. + if ( ! WP_UNINSTALL_PLUGIN ) { + $this->exit_uninstaller(); + } + + // Not uninstalling this plugin. + if ( dirname( WP_UNINSTALL_PLUGIN ) !== dirname( plugin_basename( __FILE__ ) ) ) { + $this->exit_uninstaller(); + } + + // Uninstall ElasticPress. + self::clean_options(); + } + + /** + * Cleanup options + * + * Deletes ElasticPress options and transients. + * + * @since 1.7 + * + * @return void + */ + protected static function clean_options() { + + // Delete options. + delete_site_option( 'ep_host' ); + delete_site_option( 'ep_activate' ); + + // Delete transients. + delete_transient( 'ep_post_count' ); + delete_transient( 'ep_index_offset' ); + delete_transient( 'ep_index_synced' ); + delete_transient( 'ep_index_failed_posts' ); + delete_transient( 'ep_index_failed_blocks' ); + delete_transient( 'ep_installed_plugins' ); + + } + + /** + * Exit uninstaller + * + * Gracefully exit the uninstaller if we should not be here + * + * @since 1.7 + * + * @return void + */ + protected function exit_uninstaller() { + + status_header( 404 ); + exit; + + } +} + +new EP_Uninstaller(); From 4ca4733f0832f2a4d4514d0a448acc438158ff3a Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:12:16 -0500 Subject: [PATCH 013/117] Move check host from lib to config --- classes/class-ep-config.php | 33 +++++++++++++++++++++++++++++ classes/class-ep-index-worker.php | 2 +- classes/class-ep-lib.php | 35 +++---------------------------- classes/class-ep-settings.php | 6 +++--- 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index 121b37f979..e01467d62e 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -143,6 +143,35 @@ public function get_network_alias() { return apply_filters( 'ep_global_alias', $alias ); } + + /** + * Check if connection is alive. + * + * Provide better error messaging for common connection errors + * + * @since 1.7 + * + * @return bool|WP_Error true on success or WP_Error + */ + public static function check_host() { + + global $ep_backup_host; + + if ( ! defined( 'EP_HOST' ) && ! is_array( $ep_backup_host ) ) { + EP_Lib::set_host(); + } + + if ( ! defined( 'EP_HOST' ) && ! is_array( $ep_backup_host ) ) { + return new WP_Error( 'elasticpress', esc_html__( 'EP_HOST is not defined! Check wp-config.php', 'elasticpress' ) ); + } + + if ( false === ep_elasticsearch_alive() ) { + return new WP_Error( 'elasticpress', esc_html__( 'Unable to reach Elasticsearch Server! Check that service is running.', 'elasticpress' ) ); + } + + return true; + + } } EP_Config::factory(); @@ -170,3 +199,7 @@ function ep_get_indexable_post_status() { function ep_get_network_alias() { return EP_Config::factory()->get_network_alias(); } + +function ep_check_host() { + return EP_Config::factory()->check_host(); +} diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index 0f37430c98..bfdef8e5a2 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -81,7 +81,7 @@ protected function _create_network_alias() { */ public function index( $network_wide = false ) { - EP_Lib::check_host(); + ep_check_host(); $total_indexed = 0; diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 16c87d1a3d..1a0fea9304 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -27,7 +27,7 @@ class EP_Lib { */ public static function ep_activate() { - EP_Lib::check_host(); + ep_check_host(); $status = ep_is_activated(); @@ -129,7 +129,7 @@ public static function ep_get_plugins() { */ public static function ep_deactivate() { - EP_Lib::check_host(); + ep_check_host(); $status = ep_is_activated(); @@ -153,35 +153,6 @@ public static function ep_deactivate() { } } - /** - * Check if connection is alive. - * - * Provide better error messaging for common connection errors - * - * @since 1.7 - * - * @return bool|WP_Error true on success or WP_Error - */ - public static function check_host() { - - global $ep_backup_host; - - if ( ! defined( 'EP_HOST' ) && ! is_array( $ep_backup_host ) ) { - EP_Lib::set_host(); - } - - if ( ! defined( 'EP_HOST' ) && ! is_array( $ep_backup_host ) ) { - return new WP_Error( 'elasticpress', esc_html__( 'EP_HOST is not defined! Check wp-config.php', 'elasticpress' ) ); - } - - if ( false === ep_elasticsearch_alive() ) { - return new WP_Error( 'elasticpress', esc_html__( 'Unable to reach Elasticsearch Server! Check that service is running.', 'elasticpress' ) ); - } - - return true; - - } - /** * Parse response from Elasticsearch * @@ -369,7 +340,7 @@ public static function ep_byte_size( $bytes, $precision = 2 ) { */ public static function put_mapping( $network_wide = false ) { - EP_Lib::check_host(); + ep_check_host(); if ( true === $network_wide && is_multisite() ) { diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 5a3c8356a8..1b659b38bc 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -37,7 +37,7 @@ class EP_Settings { public function __construct() { EP_Lib::set_api_key(); - EP_Lib::check_host(); + ep_check_host(); if ( is_multisite() ) { // Must be network admin in multisite. @@ -140,7 +140,7 @@ public function action_admin_init() { add_settings_section( 'ep_settings_section_main', '', array( $this, 'ep_settings_section_hightlight' ), 'elasticpress' ); - if ( is_wp_error( EP_Lib::check_host() ) || get_site_option( 'ep_host' ) ) { + if ( is_wp_error( ep_check_host() ) || get_site_option( 'ep_host' ) ) { add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( $this, 'setting_callback_host' ), 'elasticpress', 'ep_settings_section_main' ); add_settings_field( 'ep_api_key', esc_html__( 'ElasticPress API Key:', 'elasticpress' ), array( $this, 'setting_callback_api_key' ), 'elasticpress', 'ep_settings_section_main' ); @@ -149,7 +149,7 @@ public function action_admin_init() { $stats = EP_Lib::ep_get_index_status(); - if ( $stats['status'] && ! is_wp_error( EP_Lib::check_host() ) ) { + if ( $stats['status'] && ! is_wp_error( ep_check_host() ) ) { add_settings_field( 'ep_activate', esc_html__( 'Use ElasticSearch:', 'elasticpress' ), array( $this, 'setting_callback_activate' ), 'elasticpress', 'ep_settings_section_main' ); From 41132ed5622f58d63b7b078124824cf1aa47da7b Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:18:36 -0500 Subject: [PATCH 014/117] Moved functions don't need to be static --- classes/class-ep-config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index e01467d62e..e92c0eca40 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -153,7 +153,7 @@ public function get_network_alias() { * * @return bool|WP_Error true on success or WP_Error */ - public static function check_host() { + public function check_host() { global $ep_backup_host; From 98a6a80fb565c1b75642f1facf84dcff0f62f0d2 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:19:00 -0500 Subject: [PATCH 015/117] Check hosts on activation and deactivation to avoid issues --- classes/class-ep-api.php | 8 +++++ classes/class-ep-lib.php | 70 ---------------------------------------- 2 files changed, 8 insertions(+), 70 deletions(-) diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index 3d7ea7fe19..3e3a3395cf 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -1475,7 +1475,11 @@ public function elasticpress_enabled( $query ) { * @since 1.0.0 */ public function deactivate() { + + ep_check_host(); + return delete_site_option( 'ep_is_active' ); + } /** @@ -1485,7 +1489,11 @@ public function deactivate() { * @since 1.0.0 */ public function activate() { + + ep_check_host(); + return update_site_option( 'ep_is_active', true ); + } /** diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 1a0fea9304..a0b4af26b6 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -16,41 +16,6 @@ */ class EP_Lib { - /** - * Activate ElasticPress - * - * Activates ElasticPress search allowing the site to use ElasticPress search. - * - * @since 1.7 - * - * @return bool True on success or false - */ - public static function ep_activate() { - - ep_check_host(); - - $status = ep_is_activated(); - - if ( $status ) { - - return true; - - } else { - - $result = ep_activate(); - - if ( $result ) { - - return true; - - } else { - - return false; - - } - } - } - /** * Get ElasticSearch plugins * @@ -118,41 +83,6 @@ public static function ep_get_plugins() { } - /** - * Deactivate ElasticPress - * - * Deactivates ElasticPress search forcing the site to use native search. - * - * @since 1.7 - * - * @return bool True on success or false - */ - public static function ep_deactivate() { - - ep_check_host(); - - $status = ep_is_activated(); - - if ( ! $status ) { - - return true; - - } else { - - $result = ep_deactivate(); - - if ( $result ) { - - return true; - - } else { - - return false; - - } - } - } - /** * Parse response from Elasticsearch * From 74f812c835803131ed66735e221372edd356990b Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:30:07 -0500 Subject: [PATCH 016/117] Move set_host method to config class --- classes/class-ep-config.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index e92c0eca40..64f1f6242d 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -158,7 +158,7 @@ public function check_host() { global $ep_backup_host; if ( ! defined( 'EP_HOST' ) && ! is_array( $ep_backup_host ) ) { - EP_Lib::set_host(); + ep_set_host(); } if ( ! defined( 'EP_HOST' ) && ! is_array( $ep_backup_host ) ) { @@ -172,6 +172,31 @@ public function check_host() { return true; } + + /** + * Set EP_HOST if needed + * + * Retrieves the value set in options the host and defines EP_HOST constant. + * + * @since 1.7 + * + * @return string The set host. + */ + public function set_host() { + + $ep_host = get_site_option( 'ep_host' ); + + if ( $ep_host && ! defined( 'EP_HOST' ) ) { + define( 'EP_HOST', $ep_host ); + } + + if ( defined( 'EP_HOST' ) ) { + return EP_HOST; + } + + return ''; + + } } EP_Config::factory(); @@ -203,3 +228,7 @@ function ep_get_network_alias() { function ep_check_host() { return EP_Config::factory()->check_host(); } + +function ep_set_host() { + return EP_Config::factory()->set_host(); +} From 66fbed557b1a52b53c12a6666a27fc704b316992 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:30:18 -0500 Subject: [PATCH 017/117] Remove set_host from lib --- classes/class-ep-lib.php | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index a0b4af26b6..fa794af25d 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -126,24 +126,6 @@ public static function parse_response( $response ) { } - /** - * Set EP_HOST if needed - * - * Retrieves the value set in options the host and defines EP_HOST constant. - * - * @since 1.7 - * - * @return void - */ - public static function set_host() { - - $ep_host = get_site_option( 'ep_host' ); - - if ( $ep_host && ! defined( 'EP_HOST' ) ) { - define( 'EP_HOST', $ep_host ); - } - } - /** * Set EP_API_KEY if needed * From 5621f7dba706e2cba1a8b6fcf828d881dc9ed240 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:30:35 -0500 Subject: [PATCH 018/117] Catch remaining instances of check_host --- includes/settings/form.php | 2 +- includes/settings/status.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/settings/form.php b/includes/settings/form.php index 0def75d4b0..480a3fc6f2 100644 --- a/includes/settings/form.php +++ b/includes/settings/form.php @@ -27,7 +27,7 @@ $stats = EP_Lib::ep_get_index_status(); - if ( ( $stats['status'] && ! is_wp_error( EP_Lib::check_host() ) ) || is_wp_error( EP_Lib::check_host() ) || get_site_option( 'ep_host' ) ) { + if ( ( $stats['status'] && ! is_wp_error( ep_check_host() ) ) || is_wp_error( ep_check_host() ) || get_site_option( 'ep_host' ) ) { submit_button(); } diff --git a/includes/settings/status.php b/includes/settings/status.php index 721e7cde87..b22ed99a06 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -20,7 +20,7 @@
    :
    - + From 2bbd34d2f5ae9ffa69ef7a01112e11b6f2280590 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:35:53 -0500 Subject: [PATCH 019/117] Update parse_response for newer error format --- classes/class-ep-lib.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index fa794af25d..0ed4cfdb8a 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -103,7 +103,13 @@ public static function parse_response( $response ) { 'msg' => esc_html__( 'Invalid response from ElasticPress server. Please contact your administrator.' ), ); - } elseif ( isset( $response->error ) && stristr( $response->error, 'IndexMissingException' ) ) { + } elseif ( + isset( $response->error ) && + ( + ( is_string( $response->error ) && stristr( $response->error, 'IndexMissingException' ) ) || + ( isset( $response->error->reason ) && stristr( $response->error-> reason, 'no such index' ) ) + ) + ) { if ( is_multisite() ) { From b12989d3fbb757d7b9680a3df365597174bf3d4e Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:41:04 -0500 Subject: [PATCH 020/117] Move set_api_key to config class --- classes/class-ep-config.php | 29 +++++++++++++++++++++++++++++ classes/class-ep-lib.php | 18 ------------------ classes/class-ep-settings.php | 2 +- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index 64f1f6242d..4d6f125ae5 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -173,6 +173,31 @@ public function check_host() { } + /** + * Set EP_API_KEY if needed + * + * Retrieves the value set in options the api key and defines EP_API_KEY constant. + * + * @since 0.3.0 + * + * @return string The set API key. + */ + public function set_api_key() { + + $ep_api_key = get_site_option( 'ep_api_key' ); + + if ( $ep_api_key && ! defined( 'EP_API_KEY' ) ) { + define( 'EP_API_KEY', $ep_api_key ); + } + + if ( defined( 'EP_API_KEY' ) ) { + return EP_API_KEY; + } + + return ''; + + } + /** * Set EP_HOST if needed * @@ -232,3 +257,7 @@ function ep_check_host() { function ep_set_host() { return EP_Config::factory()->set_host(); } + +function ep_set_api_key() { + return EP_Config::factory()->set_api_key(); +} diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 0ed4cfdb8a..0edb2178be 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -132,24 +132,6 @@ public static function parse_response( $response ) { } - /** - * Set EP_API_KEY if needed - * - * Retrieves the value set in options the api key and defines EP_API_KEY constant. - * - * @since 0.3.0 - * - * @return void - */ - public static function set_api_key() { - - $ep_api_key = get_site_option( 'ep_api_key' ); - - if ( $ep_api_key && ! defined( 'EP_API_KEY' ) ) { - define( 'EP_API_KEY', $ep_api_key ); - } - } - /** * Retrieve Index status * diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 1b659b38bc..b6fcdae54d 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -36,7 +36,7 @@ class EP_Settings { */ public function __construct() { - EP_Lib::set_api_key(); + ep_set_api_key(); ep_check_host(); if ( is_multisite() ) { // Must be network admin in multisite. From e3edce61c0a019041216afb5520bc82560bea860 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:44:57 -0500 Subject: [PATCH 021/117] Move parse response method to api class --- classes/class-ep-lib.php | 49 +--------------------------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 0edb2178be..7822b4df32 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -83,54 +83,7 @@ public static function ep_get_plugins() { } - /** - * Parse response from Elasticsearch - * - * Determines if there is an issue or if the response is valid. - * - * @since 1.7 - * - * @param object $response JSON decoded response from ElasticSearch. - * - * @return array Contains the status message or the returned statistics. - */ - public static function parse_response( $response ) { - - if ( null === $response ) { - - return array( - 'status' => false, - 'msg' => esc_html__( 'Invalid response from ElasticPress server. Please contact your administrator.' ), - ); - - } elseif ( - isset( $response->error ) && - ( - ( is_string( $response->error ) && stristr( $response->error, 'IndexMissingException' ) ) || - ( isset( $response->error->reason ) && stristr( $response->error-> reason, 'no such index' ) ) - ) - ) { - - if ( is_multisite() ) { - $error = __( 'Site not indexed.

    Please run: wp elasticpress index --setup --network-wide using WP-CLI. Or use the index button on the left of this screen.

    ', 'elasticpress' ); - - } else { - - $error = __( 'Site not indexed.

    Please run: wp elasticpress index --setup using WP-CLI. Or use the index button on the left of this screen.

    ', 'elasticpress' ); - - } - - return array( - 'status' => false, - 'msg' => $error, - ); - - } - - return array( 'status' => true, 'data' => $response->_all->primaries->indexing ); - - } /** * Retrieve Index status @@ -369,7 +322,7 @@ public static function get_index_status( $blog_id = null ) { $response = json_decode( wp_remote_retrieve_body( $request ) ); - return EP_Lib::parse_response( $response ); + return ep_parse_api_resonse( $response ); } From e1f02c3f4ac6455ec36ba040f7e6c81ab45d61f0 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:47:07 -0500 Subject: [PATCH 022/117] Move get_plugins method to ep_api --- classes/class-ep-lib.php | 67 ---------------------------------------- 1 file changed, 67 deletions(-) diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 7822b4df32..68ff46928d 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -16,73 +16,6 @@ */ class EP_Lib { - /** - * Get ElasticSearch plugins - * - * Gets a list of available ElasticSearch plugins. - * - * @since 0.3.0 - * - * @return array Array of plugins and their version or error message - */ - public static function ep_get_plugins() { - - $plugins = get_transient( 'ep_installed_plugins' ); - - if ( is_array( $plugins ) ) { - return $plugins; - } - - $plugins = array(); - - if ( is_wp_error( ep_get_host() ) ) { - - return array( - 'status' => false, - 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), - ); - - } - - $path = '/_nodes?plugin=true'; - - $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); - - if ( ! is_wp_error( $request ) ) { - - $response = json_decode( wp_remote_retrieve_body( $request ), true ); - - if ( isset( $response['nodes'] ) ) { - - foreach ( $response['nodes'] as $node ) { - - if ( isset( $node['plugins'] ) && is_array( $node['plugins'] ) ) { - - foreach ( $node['plugins'] as $plugin ) { - - $plugins[ $plugin['name'] ] = $plugin['version']; - - } - - break; - - } - } - } - - set_transient( 'ep_installed_plugins', $plugins, apply_filters( 'ep_installed_plugins_exp', 3600 ) ); - - return $plugins; - - } - - return array( - 'status' => false, - 'msg' => $request->get_error_message(), - ); - - } - /** From 8042eefcd64fd8162e9de8e3c052434bd38779f5 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:47:57 -0500 Subject: [PATCH 023/117] Fix typo in function call --- classes/class-ep-lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 68ff46928d..898027ef98 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -255,7 +255,7 @@ public static function get_index_status( $blog_id = null ) { $response = json_decode( wp_remote_retrieve_body( $request ) ); - return ep_parse_api_resonse( $response ); + return ep_parse_api_response( $response ); } From 44b199e8e523696ec4f66c3b7563bb48b61f8fe0 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 09:57:37 -0500 Subject: [PATCH 024/117] Move status methods to ep_api class --- classes/class-ep-index-gui.php | 4 +- classes/class-ep-lib.php | 193 --------------------------------- classes/class-ep-settings.php | 6 +- includes/settings/form.php | 2 +- includes/settings/status.php | 10 +- 5 files changed, 11 insertions(+), 204 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 2594da2e0c..4e5d66528e 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -179,7 +179,7 @@ public function action_wp_ajax_ep_launch_index() { if ( false === get_transient( 'ep_index_offset' ) ) { // Deactivate our search integration. - EP_Lib::ep_deactivate(); + ep_deactivate(); $mapping_success = EP_Lib::put_mapping(); @@ -204,7 +204,7 @@ public function action_wp_ajax_ep_launch_index() { if ( false === get_transient( 'ep_index_offset' ) ) { // Reactivate our search integration. - EP_Lib::ep_activate(); + ep_activate(); $data = array( 'ep_sync_complete' => 1, diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 898027ef98..1a82c40866 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -16,57 +16,6 @@ */ class EP_Lib { - - - /** - * Retrieve Index status - * - * Retrieves index stats from ElasticSearch. - * - * @since 1.7 - * - * @param int $blog_id Id of blog to get stats. - * - * @return array Contains the status message or the returned statistics. - */ - public static function ep_get_index_status( $blog_id = null ) { - - return EP_Lib::get_index_status( $blog_id ); - - } - - /** - * Retrieve cluster stats - * - * Retrieves cluster stats from ElasticSearch. - * - * @since 1.7 - * - * @return array Contains the status message or the returned statistics. - */ - public static function ep_get_cluster_status() { - - return EP_Lib::get_cluster_status(); - - } - - /** - * Retrieve search stats - * - * Retrieves search stats from ElasticSearch. - * - * @since 1.7 - * - * @param int $blog_id Id of blog to get stats. - * - * @return array Contains the status message or the returned statistics. - */ - public static function ep_get_search_status( $blog_id = null ) { - - return EP_Lib::get_search_status( $blog_id ); - - } - /** * Easily read bytes * @@ -177,147 +126,5 @@ public static function put_mapping( $network_wide = false ) { } } - /** - * Get cluster status - * - * Retrieves cluster stats from ElasticSearch. - * - * @since 1.7 - * - * @return array Contains the status message or the returned statistics. - */ - public static function get_cluster_status() { - - if ( is_wp_error( ep_get_host() ) ) { - - return array( - 'status' => false, - 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), - ); - - } else { - - $request = ep_remote_request( '_cluster/stats', array( 'method' => 'GET' ) ); - - if ( ! is_wp_error( $request ) ) { - - $response = json_decode( wp_remote_retrieve_body( $request ) ); - - return $response; - - } - return array( - 'status' => false, - 'msg' => $request->get_error_message(), - ); - - } - } - - /** - * Get index status - * - * Retrieves index stats from ElasticSearch. - * - * @since 1.7 - * - * @param int $blog_id Id of blog to get stats. - * - * @return array Contains the status message or the returned statistics. - */ - public static function get_index_status( $blog_id = null ) { - - if ( is_wp_error( ep_get_host( true ) ) ) { - - return array( - 'status' => false, - 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), - ); - - } else { - - if ( is_multisite() && null === $blog_id ) { - - $path = ep_get_network_alias() . '/_stats/indexing/'; - - } else { - - $path = ep_get_index_name( $blog_id ) . '/_stats/indexing/'; - - } - - $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); - - } - - if ( ! is_wp_error( $request ) ) { - - $response = json_decode( wp_remote_retrieve_body( $request ) ); - - return ep_parse_api_response( $response ); - - } - - return array( - 'status' => false, - 'msg' => $request->get_error_message(), - ); - - } - - /** - * Retrieves search stats from ElasticSearch. - * - * Retrieves various search statistics from the ES server. - * - * @since 1.0.0 - * - * @param int $blog_id Id of blog to get stats. - * - * @return array Contains the status message or the returned statistics. - */ - public static function get_search_status( $blog_id = null ) { - - if ( is_wp_error( ep_get_host() ) ) { - - return array( - 'status' => false, - 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), - ); - - } else { - - if ( is_multisite() && null === $blog_id ) { - - $path = ep_get_network_alias() . '/_stats/search/'; - - } else { - - $path = ep_get_index_name( $blog_id ) . '/_stats/search/'; - - } - - $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); - - } - - if ( ! is_wp_error( $request ) ) { - - $stats = json_decode( wp_remote_retrieve_body( $request ) ); - - if ( isset( $stats->_all ) ) { - return $stats->_all->primaries->search; - } - - return false; - - } - - return array( - 'status' => false, - 'msg' => $request->get_error_message(), - ); - - } } diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index b6fcdae54d..755352adc3 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -147,7 +147,7 @@ public function action_admin_init() { } - $stats = EP_Lib::ep_get_index_status(); + $stats = ep_get_index_status(); if ( $stats['status'] && ! is_wp_error( ep_check_host() ) ) { @@ -280,11 +280,11 @@ public function sanitize_ep_activate( $input ) { if ( true === $input ) { - EP_Lib::ep_activate(); + ep_activate(); } else { - EP_Lib::ep_deactivate(); + ep_deactivate(); } diff --git a/includes/settings/form.php b/includes/settings/form.php index 480a3fc6f2..c9fedf0aeb 100644 --- a/includes/settings/form.php +++ b/includes/settings/form.php @@ -25,7 +25,7 @@ settings_fields( 'elasticpress' ); do_settings_sections( 'elasticpress' ); - $stats = EP_Lib::ep_get_index_status(); + $stats = ep_get_index_status(); if ( ( $stats['status'] && ! is_wp_error( ep_check_host() ) ) || is_wp_error( ep_check_host() ) || get_site_option( 'ep_host' ) ) { submit_button(); diff --git a/includes/settings/status.php b/includes/settings/status.php index b22ed99a06..dcf613b8c6 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -9,8 +9,8 @@ * @author Allan Collins */ -$stats = EP_Lib::ep_get_index_status(); -$search_stats = EP_Lib::ep_get_search_status(); +$stats = ep_get_index_status(); +$search_stats = ep_get_search_status(); echo '
    '; @@ -124,8 +124,8 @@ foreach ( $sites as $site ) { - $stats = EP_Lib::ep_get_index_status( $site['blog_id'] ); - $search_stats = EP_Lib::ep_get_search_status( $site['blog_id'] ); + $stats = ep_get_index_status( $site['blog_id'] ); + $search_stats = ep_get_search_status( $site['blog_id'] ); $details = get_blog_details( $site['blog_id'] ); ?>
    @@ -174,7 +174,7 @@ %s', esc_html__( 'Cluster Stats', 'elasticpress' ) ); ?> nodes->fs; $disk_usage = $fs->total_in_bytes - $fs->available_in_bytes; ?> From 62a204d567e47e80c2296098258009fc4fcc51b6 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 10:06:06 -0500 Subject: [PATCH 025/117] Move ep_byte_size to EP_Settings --- classes/class-ep-lib.php | 46 ------------------------ classes/class-ep-settings.php | 66 ++++++++++++++++++++++++++++++++--- includes/settings/status.php | 4 +-- 3 files changed, 64 insertions(+), 52 deletions(-) diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 1a82c40866..0cc5421bfa 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -16,52 +16,6 @@ */ class EP_Lib { - /** - * Easily read bytes - * - * Converts bytes to human-readable format. - * - * @since 1.7 - * - * @param int $bytes The raw bytes to convert. - * @param int $precision The precision with which to display the conversion. - * - * @return string - */ - public static function ep_byte_size( $bytes, $precision = 2 ) { - - $kilobyte = 1024; - $megabyte = $kilobyte * 1024; - $gigabyte = $megabyte * 1024; - $terabyte = $gigabyte * 1024; - - if ( ( $bytes >= 0 ) && ( $bytes < $kilobyte ) ) { - - return $bytes . ' B'; - - } elseif ( ( $bytes >= $kilobyte ) && ( $bytes < $megabyte ) ) { - - return round( $bytes / $kilobyte, $precision ) . ' KB'; - - } elseif ( ( $bytes >= $megabyte ) && ( $bytes < $gigabyte ) ) { - - return round( $bytes / $megabyte, $precision ) . ' MB'; - - } elseif ( ( $bytes >= $gigabyte ) && ( $bytes < $terabyte ) ) { - - return round( $bytes / $gigabyte, $precision ) . ' GB'; - - } elseif ( $bytes >= $terabyte ) { - - return round( $bytes / $terabyte, $precision ) . ' TB'; - - } else { - - return $bytes . ' B'; - - } - } - /** * Add the document mapping * diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 755352adc3..8237a15530 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -138,12 +138,21 @@ public function action_admin_init() { } } - add_settings_section( 'ep_settings_section_main', '', array( $this, 'ep_settings_section_hightlight' ), 'elasticpress' ); + add_settings_section( 'ep_settings_section_main', '', array( + $this, + 'ep_settings_section_hightlight', + ), 'elasticpress' ); if ( is_wp_error( ep_check_host() ) || get_site_option( 'ep_host' ) ) { - add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( $this, 'setting_callback_host' ), 'elasticpress', 'ep_settings_section_main' ); - add_settings_field( 'ep_api_key', esc_html__( 'ElasticPress API Key:', 'elasticpress' ), array( $this, 'setting_callback_api_key' ), 'elasticpress', 'ep_settings_section_main' ); + add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( + $this, + 'setting_callback_host', + ), 'elasticpress', 'ep_settings_section_main' ); + add_settings_field( 'ep_api_key', esc_html__( 'ElasticPress API Key:', 'elasticpress' ), array( + $this, + 'setting_callback_api_key', + ), 'elasticpress', 'ep_settings_section_main' ); } @@ -151,7 +160,10 @@ public function action_admin_init() { if ( $stats['status'] && ! is_wp_error( ep_check_host() ) ) { - add_settings_field( 'ep_activate', esc_html__( 'Use ElasticSearch:', 'elasticpress' ), array( $this, 'setting_callback_activate' ), 'elasticpress', 'ep_settings_section_main' ); + add_settings_field( 'ep_activate', esc_html__( 'Use ElasticSearch:', 'elasticpress' ), array( + $this, + 'setting_callback_activate', + ), 'elasticpress', 'ep_settings_section_main' ); } @@ -387,4 +399,50 @@ public function ep_settings_section_hightlight() { echo '

    ' . esc_html__( 'ElasticSearch Integration Options', 'elasticpress' ) . '

    '; } + + /** + * Easily read bytes + * + * Converts bytes to human-readable format. + * + * @since 1.7 + * + * @param int $bytes The raw bytes to convert. + * @param int $precision The precision with which to display the conversion. + * + * @return string + */ + public static function ep_byte_size( $bytes, $precision = 2 ) { + + $kilobyte = 1024; + $megabyte = $kilobyte * 1024; + $gigabyte = $megabyte * 1024; + $terabyte = $gigabyte * 1024; + + if ( ( $bytes >= 0 ) && ( $bytes < $kilobyte ) ) { + + return $bytes . ' B'; + + } elseif ( ( $bytes >= $kilobyte ) && ( $bytes < $megabyte ) ) { + + return round( $bytes / $kilobyte, $precision ) . ' KB'; + + } elseif ( ( $bytes >= $megabyte ) && ( $bytes < $gigabyte ) ) { + + return round( $bytes / $megabyte, $precision ) . ' MB'; + + } elseif ( ( $bytes >= $gigabyte ) && ( $bytes < $terabyte ) ) { + + return round( $bytes / $gigabyte, $precision ) . ' GB'; + + } elseif ( $bytes >= $terabyte ) { + + return round( $bytes / $terabyte, $precision ) . ' TB'; + + } else { + + return $bytes . ' B'; + + } + } } diff --git a/includes/settings/status.php b/includes/settings/status.php index dcf613b8c6..2e669a412c 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -184,10 +184,10 @@ total_in_bytes ) * 100, 0 ) ); ?>%
  • - available_in_bytes ) ); ?> + ep_byte_size( $fs->available_in_bytes ) ); ?>
  • - total_in_bytes ) ); ?> + ep_byte_size( $fs->total_in_bytes ) ); ?>
  • From 30d3e194acc36b5758d386252b06fa6fb0f40cbd Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 10:09:37 -0500 Subject: [PATCH 026/117] Move process mappings to ep_api --- classes/class-ep-index-gui.php | 2 +- classes/class-ep-lib.php | 65 ---------------------------------- 2 files changed, 1 insertion(+), 66 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 4e5d66528e..58fbef3abd 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -181,7 +181,7 @@ public function action_wp_ajax_ep_launch_index() { // Deactivate our search integration. ep_deactivate(); - $mapping_success = EP_Lib::put_mapping(); + $mapping_success = ep_process_site_mappings(); if ( ! $mapping_success ) { wp_send_json_error( esc_html__( 'Mappings could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php index 0cc5421bfa..9d0ee65822 100644 --- a/classes/class-ep-lib.php +++ b/classes/class-ep-lib.php @@ -16,69 +16,4 @@ */ class EP_Lib { - /** - * Add the document mapping - * - * Creates the document mapping for the index. - * - * @since 1.7 - * - * @param bool $network_wide whether to index network wide or not. - * - * @return bool true on success or false - */ - public static function put_mapping( $network_wide = false ) { - - ep_check_host(); - - if ( true === $network_wide && is_multisite() ) { - - $sites = ep_get_sites(); - $success = array(); - - foreach ( $sites as $site ) { - - switch_to_blog( $site['blog_id'] ); - - // Deletes index first. - ep_delete_index(); - - $result = ep_put_mapping(); - - if ( $result ) { - - $success[ $site['blog_id'] ] = true; - - } else { - - $success[ $site['blog_id'] ] = false; - - } - - restore_current_blog(); - } - - if ( array_search( false, $success ) ) { - return $success; - } - - return true; - - } else { - - // Deletes index first. - ep_delete_index(); - - $result = ep_put_mapping(); - - if ( $result ) { - return true; - } - - return false; - - } - } - - } From 4b370a61f5f199d10cf0d9e90c18bbfdc600cd68 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 10:10:46 -0500 Subject: [PATCH 027/117] Remove EP_Lib class --- classes/class-ep-lib.php | 19 ------------------- elasticpress.php | 3 --- 2 files changed, 22 deletions(-) delete mode 100644 classes/class-ep-lib.php diff --git a/classes/class-ep-lib.php b/classes/class-ep-lib.php deleted file mode 100644 index 9d0ee65822..0000000000 --- a/classes/class-ep-lib.php +++ /dev/null @@ -1,19 +0,0 @@ - - */ - -/** - * ElasticPress utility functions - * - * Various utility functions for use throughout ElasticPress - */ -class EP_Lib { - -} diff --git a/elasticpress.php b/elasticpress.php index 578bb38b19..572ee8a455 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -47,9 +47,6 @@ function ep_loader() { load_plugin_textdomain( 'elasticpress', false, dirname( dirname( __FILE__ ) ) . '/lang' ); // Load any available translations first. - // Load the common library. - require( dirname( __FILE__ ) . '/classes/class-ep-lib.php' ); - // Load the settings page. require( dirname( __FILE__ ) . '/classes/class-ep-settings.php' ); new EP_Settings(); From caf26f3a6ca35ff574f165aeac4d7a1aec3ac842 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 10:28:19 -0500 Subject: [PATCH 028/117] Minor formatting fixes --- classes/class-ep-settings.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 8237a15530..d045659b4f 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -239,10 +239,7 @@ protected function populate_columns() { add_meta_box( 'ep-contentbox-1', 'Settings', - array( - $this, - 'load_view', - ), + array( $this, 'load_view' ), $this->options_page, 'normal', 'core', @@ -252,10 +249,7 @@ protected function populate_columns() { add_meta_box( 'ep-contentbox-2', 'Current Status', - array( - $this, - 'load_view', - ), + array( $this, 'load_view' ), $this->options_page, 'side', 'core', From 41a5d9e377cfe646833612cb721eef9a0b9b897e Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 10:40:07 -0500 Subject: [PATCH 029/117] Better form usability. Allows tracking of how EP_HOST was set for a more usable settings form. --- classes/class-ep-config.php | 31 ++++++++++++++++++++++++++++++- classes/class-ep-settings.php | 29 +++++++++++++++++------------ 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index 4d6f125ae5..b92906e1c0 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -5,6 +5,15 @@ } class EP_Config { + /** + * True if EP_HOST has been set via option or false. + * + * @since 1.8 + * + * @var bool + */ + public $option_host = false; + /** * Get a singleton instance of the class * @@ -209,9 +218,10 @@ public function set_api_key() { */ public function set_host() { - $ep_host = get_site_option( 'ep_host' ); + $ep_host = get_site_option( 'ep_host' ); if ( $ep_host && ! defined( 'EP_HOST' ) ) { + $this->option_host = true; define( 'EP_HOST', $ep_host ); } @@ -222,6 +232,21 @@ public function set_host() { return ''; } + + /** + * Tracks how EP_HOST was set + * + * Tracks how EP_HOST was set for easer use. + * + * @since 1.8 + * + * @return bool True if option is used to set host or false. + */ + public function host_by_option() { + + return $this->option_host; + + } } EP_Config::factory(); @@ -261,3 +286,7 @@ function ep_set_host() { function ep_set_api_key() { return EP_Config::factory()->set_api_key(); } + +function ep_host_by_option() { + return EP_Config::factory()->host_by_option(); +} diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index d045659b4f..5f09798f0c 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -143,18 +143,15 @@ public function action_admin_init() { 'ep_settings_section_hightlight', ), 'elasticpress' ); - if ( is_wp_error( ep_check_host() ) || get_site_option( 'ep_host' ) ) { - - add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( - $this, - 'setting_callback_host', - ), 'elasticpress', 'ep_settings_section_main' ); - add_settings_field( 'ep_api_key', esc_html__( 'ElasticPress API Key:', 'elasticpress' ), array( - $this, - 'setting_callback_api_key', - ), 'elasticpress', 'ep_settings_section_main' ); + add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( + $this, + 'setting_callback_host', + ), 'elasticpress', 'ep_settings_section_main' ); - } + add_settings_field( 'ep_api_key', esc_html__( 'ElasticPress API Key:', 'elasticpress' ), array( + $this, + 'setting_callback_api_key', + ), 'elasticpress', 'ep_settings_section_main' ); $stats = ep_get_index_status(); @@ -358,7 +355,15 @@ public function setting_callback_api_key() { */ public function setting_callback_host() { - echo ''; + $read_only = ''; + $host = get_site_option( 'ep_host' ); + + if ( false === ep_host_by_option() ) { + $read_only = 'readonly'; + $host = EP_HOST; + } + + echo ''; } From f63b385345b98d26dc5fce12f187deeb73b5ebbb Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 12:20:50 -0500 Subject: [PATCH 030/117] add ep_is_network_activated --- classes/class-ep-config.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index b92906e1c0..e376968635 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -247,6 +247,29 @@ public function host_by_option() { return $this->option_host; } + + /** + * Whether plugin is network activated + * + * Determines whether plugin is network activated or just on the local site. + * + * @since 1.8 + * + * @param string $plugin the plugin base name. + * + * @return bool True if network activated or false + */ + public function is_network( $plugin ) { + + $plugins = get_site_option( 'active_sitewide_plugins'); + + if ( is_multisite() && isset( $plugins[ $plugin ] ) ) { + return true; + } + + return false; + + } } EP_Config::factory(); From 414d9448cb2535860a90a48382fccba3b1d5f196 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 12:21:28 -0500 Subject: [PATCH 031/117] properly check if plugin is activated --- classes/class-ep-config.php | 4 ++++ classes/class-ep-settings.php | 6 +++--- elasticpress.php | 6 ++++++ includes/settings/form.php | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index e376968635..ed6423c7bc 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -313,3 +313,7 @@ function ep_set_api_key() { function ep_host_by_option() { return EP_Config::factory()->host_by_option(); } + +function ep_is_network_activated( $plugin ) { + return EP_Config::factory()->is_network( $plugin ); +} \ No newline at end of file diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 5f09798f0c..6f52176163 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -39,7 +39,7 @@ public function __construct() { ep_set_api_key(); ep_check_host(); - if ( is_multisite() ) { // Must be network admin in multisite. + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { // Must be network admin in multisite. add_action( 'network_admin_menu', array( $this, 'action_admin_menu' ) ); @@ -107,7 +107,7 @@ public function action_admin_enqueue_scripts() { public function action_admin_init() { //Save options for multisite - if ( is_multisite() && ( isset( $_POST['ep_host'] ) || isset( $_POST['ep_activate'] ) ) ) { + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK && ( isset( $_POST['ep_host'] ) || isset( $_POST['ep_activate'] ) ) ) { if ( ! check_admin_referer( 'elasticpress-options' ) ) { die( esc_html__( 'Security error!', 'elasticpress' ) ); @@ -184,7 +184,7 @@ public function action_admin_menu() { $parent_slug = 'options-general.php'; $capability = 'manage_options'; - if ( is_multisite() ) { + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { $parent_slug = 'settings.php'; $capability = 'manage_network'; diff --git a/elasticpress.php b/elasticpress.php index 572ee8a455..0615944b2b 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -29,6 +29,12 @@ require_once( 'classes/class-ep-wp-query-integration.php' ); require_once( 'classes/class-ep-wp-date-query.php' ); +$network_activated = ep_is_network_activated( plugin_basename( __FILE__ ) ); + +if ( $network_activated ) { + define( 'EP_IS_NETWORK', true ); +} + /** * WP CLI Commands */ diff --git a/includes/settings/form.php b/includes/settings/form.php index c9fedf0aeb..810d0cda12 100644 --- a/includes/settings/form.php +++ b/includes/settings/form.php @@ -14,7 +14,7 @@ //Set form action $action = 'options.php'; -if ( is_multisite() ) { +if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { $action = ''; } ?> From 151ce118093038664501d6dd3e1a0639ca789ce7 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 12:31:38 -0500 Subject: [PATCH 032/117] Make sure setup button works. --- includes/settings/form.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/includes/settings/form.php b/includes/settings/form.php index 810d0cda12..5f2bae8108 100644 --- a/includes/settings/form.php +++ b/includes/settings/form.php @@ -25,9 +25,7 @@ settings_fields( 'elasticpress' ); do_settings_sections( 'elasticpress' ); - $stats = ep_get_index_status(); - - if ( ( $stats['status'] && ! is_wp_error( ep_check_host() ) ) || is_wp_error( ep_check_host() ) || get_site_option( 'ep_host' ) ) { + if ( ( ! ep_host_by_option() && ! is_wp_error( ep_check_host() ) ) || is_wp_error( ep_check_host() ) || get_site_option( 'ep_host' ) ) { submit_button(); } From 9f552f0ba69cdf4ae5b8fd3ba89fe72bc5fc85e5 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 12:56:38 -0500 Subject: [PATCH 033/117] Reintroduce GUI indexing to multisite --- elasticpress.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticpress.php b/elasticpress.php index 0615944b2b..ac0be84dfa 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -58,7 +58,7 @@ function ep_loader() { new EP_Settings(); // Load the indexing GUI. - if ( ! is_multisite() && true === apply_filters( 'ep_load_index_gui', true ) ) { + if ( true === apply_filters( 'ep_load_index_gui', true ) ) { require( dirname( __FILE__ ) . '/classes/class-ep-index-gui.php' ); new EP_Index_GUI(); From cb91ae2718ab30dc6072b7eaf10a261cfb901ef1 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 13:03:13 -0500 Subject: [PATCH 034/117] Only index the current site if not a network activation --- classes/class-ep-index-gui.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 58fbef3abd..cbd9889eb8 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -190,7 +190,7 @@ public function action_wp_ajax_ep_launch_index() { $network = false; - if ( is_multisite() ) { + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { $network = true; } From c6be9f8ef324e727532f25645dd859e5e80e8728 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 13:16:07 -0500 Subject: [PATCH 035/117] Limit mappings to current site only if not network activated --- classes/class-ep-index-gui.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index cbd9889eb8..b818267606 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -176,24 +176,24 @@ public function action_wp_ajax_ep_launch_index() { set_transient( 'ep_post_count', $post_count, 600 ); + $network = false; + + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + $network = true; + } + if ( false === get_transient( 'ep_index_offset' ) ) { // Deactivate our search integration. ep_deactivate(); - $mapping_success = ep_process_site_mappings(); + $mapping_success = ep_process_site_mappings( $network ); if ( ! $mapping_success ) { wp_send_json_error( esc_html__( 'Mappings could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); } } - $network = false; - - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { - $network = true; - } - $indexer = new EP_Index_Worker(); $index_success = $indexer->index( $network ); From 2a779d26c13cef984e69628677ce42fb66898b7b Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 1 Dec 2015 13:20:19 -0500 Subject: [PATCH 036/117] Handle stats appropriately depending on network activation status --- includes/settings/status.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/settings/status.php b/includes/settings/status.php index 2e669a412c..30c60a6d96 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -9,8 +9,14 @@ * @author Allan Collins */ -$stats = ep_get_index_status(); -$search_stats = ep_get_search_status(); +$site_stats_id = null; + +if ( is_multisite() && ( ! defined( 'EP_IS_NETWORK' ) || ! EP_IS_NETWORK ) ) { + $site_stats_id = get_current_blog_id(); +} + +$stats = ep_get_index_status( $site_stats_id ); +$search_stats = ep_get_search_status( $site_stats_id ); echo '
    '; @@ -99,7 +105,7 @@
    '; From ecde7461161d0f957f7c45bbead35526c1fc971c Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 2 Dec 2015 09:47:51 -0500 Subject: [PATCH 037/117] Mapping is now done 10 sites at a time. --- assets/js/elasticpress-admin.min.js | 2 +- assets/js/elasticpress-index-admin.js | 8 +- assets/js/elasticpress-index-admin.min.js | 2 +- classes/class-ep-index-gui.php | 11 +- lang/elasticpress.pot | 188 +++++++++++++++++----- 5 files changed, 164 insertions(+), 47 deletions(-) diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index 70e9eef4f1..126de1e57d 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){a("#jovo_site_select").change(function(){var b=a(this).val();a(".jovo_site").hide(),a("#jovo_"+b).show()})}); \ No newline at end of file +jQuery(document).ready(function(a){a("#ep_site_select").change(function(){var b=a(this).val();a(".ep_site").hide(),a("#ep_"+b).show()})}); \ No newline at end of file diff --git a/assets/js/elasticpress-index-admin.js b/assets/js/elasticpress-index-admin.js index 1649529e6f..c2f86b6884 100644 --- a/assets/js/elasticpress-index-admin.js +++ b/assets/js/elasticpress-index-admin.js @@ -58,7 +58,13 @@ jQuery ( document ).ready ( function ( $ ) { data : data, complete : function ( response ) { - if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete + console.log( response.responseJSON.data.ep_mapping_complete ); + + if ( 'undefined' !== typeof response.responseJSON.data.ep_mapping_complete ) { + + performIndex ( false, button ); + + } else if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete var progress = parseFloat ( response.responseJSON.data.ep_posts_synced ) / parseFloat ( response.responseJSON.data.ep_posts_total ); diff --git a/assets/js/elasticpress-index-admin.min.js b/assets/js/elasticpress-index-admin.min.js index 929aeb3c73..1b48f40386 100644 --- a/assets/js/elasticpress-index-admin.min.js +++ b/assets/js/elasticpress-index-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if(console.log(f.responseJSON.data.ep_mapping_complete),"undefined"!=typeof f.responseJSON.data.ep_mapping_complete)b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index b818267606..10b20b9708 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -189,8 +189,15 @@ public function action_wp_ajax_ep_launch_index() { $mapping_success = ep_process_site_mappings( $network ); - if ( ! $mapping_success ) { - wp_send_json_error( esc_html__( 'Mappings could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); + if ( true !== $mapping_success ) { + + if ( false === $mapping_success ) { + wp_send_json_error( esc_html__( 'Mappings could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); + } + + wp_send_json_success( $mapping_success ); + exit(); + } } diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 594984b144..72678e1bca 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-11-20 14:04-0500\n" +"POT-Creation-Date: 2015-12-02 09:47-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -56,11 +56,11 @@ msgstr "" msgid "Index delete failed" msgstr "" -#: bin/wp-cli.php:147 bin/wp-cli.php:253 +#: bin/wp-cli.php:147 bin/wp-cli.php:257 msgid "Recreating network alias..." msgstr "" -#: bin/wp-cli.php:154 bin/wp-cli.php:277 +#: bin/wp-cli.php:154 bin/wp-cli.php:281 msgid "Done!" msgstr "" @@ -68,48 +68,71 @@ msgstr "" msgid "An error occurred" msgstr "" -#: bin/wp-cli.php:233 +#: bin/wp-cli.php:237 msgid "Indexing posts network-wide..." msgstr "" -#: bin/wp-cli.php:244 bin/wp-cli.php:265 +#: bin/wp-cli.php:248 bin/wp-cli.php:269 #, php-format msgid "Number of posts indexed on site %d: %d" msgstr "" -#: bin/wp-cli.php:247 bin/wp-cli.php:268 +#: bin/wp-cli.php:251 bin/wp-cli.php:272 #, php-format msgid "Number of post index errors on site %d: %d" msgstr "" -#: bin/wp-cli.php:257 +#: bin/wp-cli.php:261 #, php-format msgid "Total number of posts indexed: %d" msgstr "" -#: bin/wp-cli.php:261 +#: bin/wp-cli.php:265 msgid "Indexing posts..." msgstr "" -#: bin/wp-cli.php:272 +#: bin/wp-cli.php:276 msgid "Total time elapsed: " msgstr "" -#: bin/wp-cli.php:503 +#: bin/wp-cli.php:536 msgid "" "The following posts failed to index:\r\n" "\r\n" msgstr "" -#: bin/wp-cli.php:652 classes/class-ep-lib.php:174 +#: bin/wp-cli.php:685 classes/class-ep-config.php:174 msgid "EP_HOST is not defined! Check wp-config.php" msgstr "" -#: bin/wp-cli.php:656 classes/class-ep-lib.php:178 +#: bin/wp-cli.php:689 classes/class-ep-config.php:178 msgid "Unable to reach Elasticsearch Server! Check that service is running." msgstr "" -#: classes/class-ep-config.php:56 classes/class-ep-config.php:81 +#: classes/class-ep-api.php:1728 +msgid "" +"Invalid response from ElasticPress server. Please contact your administrator." +msgstr "" + +#: classes/class-ep-api.php:1741 +msgid "" +"Site not indexed.

    Please run: wp elasticpress index --setup --" +"network-wide using WP-CLI. Or use the index button on the left of " +"this screen.

    " +msgstr "" + +#: classes/class-ep-api.php:1745 +msgid "" +"Site not indexed.

    Please run: wp elasticpress index --setup " +"using WP-CLI. Or use the index button on the left of this screen.

    " +msgstr "" + +#: classes/class-ep-api.php:1783 classes/class-ep-api.php:1842 +#: classes/class-ep-api.php:1882 classes/class-ep-api.php:1933 +msgid "ElasticSearch Host is not available." +msgstr "" + +#: classes/class-ep-config.php:65 classes/class-ep-config.php:90 msgid "No running host available." msgstr "" @@ -133,18 +156,22 @@ msgstr "" msgid "Security error!" msgstr "" -#: classes/class-ep-index-gui.php:187 +#: classes/class-ep-index-gui.php:195 msgid "" "Mappings could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:201 +#: classes/class-ep-index-gui.php:208 msgid "" "Indexing could not be completed. If the error persists contact your system " "administrator" msgstr "" +#: classes/class-ep-index-status.php:60 +msgid "Index Status" +msgstr "" + #: classes/class-ep-index-worker.php:390 msgid "The following posts failed to index:" msgstr "" @@ -153,42 +180,19 @@ msgstr "" msgid ": ElasticPress Index Errors" msgstr "" -#: classes/class-ep-lib.php:77 classes/class-ep-lib.php:438 -#: classes/class-ep-lib.php:478 classes/class-ep-lib.php:529 -msgid "ElasticSearch Host is not available." -msgstr "" - -#: classes/class-ep-lib.php:202 -msgid "" -"Invalid response from ElasticPress server. Please contact your administrator." -msgstr "" - -#: classes/class-ep-lib.php:209 -msgid "" -"Site not indexed.

    Please run: wp elasticpress index --setup --" -"network-wide using WP-CLI. Or use the index button on the left of " -"this screen.

    " -msgstr "" - -#: classes/class-ep-lib.php:213 -msgid "" -"Site not indexed.

    Please run: wp elasticpress index --setup " -"using WP-CLI. Or use the index button on the left of this screen.

    " -msgstr "" - -#: classes/class-ep-settings.php:145 +#: classes/class-ep-settings.php:146 msgid "ElasticSearch Host:" msgstr "" -#: classes/class-ep-settings.php:146 +#: classes/class-ep-settings.php:151 msgid "ElasticPress API Key:" msgstr "" -#: classes/class-ep-settings.php:154 +#: classes/class-ep-settings.php:160 msgid "Use ElasticSearch:" msgstr "" -#: classes/class-ep-settings.php:387 +#: classes/class-ep-settings.php:398 msgid "ElasticSearch Integration Options" msgstr "" @@ -215,6 +219,106 @@ msgstr "" msgid "ElasticPress" msgstr "" +#: includes/settings/status.php:28 +msgid "ElasticSearch Host" +msgstr "" + +#: includes/settings/status.php:33 +msgid "" +"Current host is set but cannot be contacted. Please contact the server " +"administrator." +msgstr "" + +#: includes/settings/status.php:37 +msgid "A host has not been set. You must set a host to continue." +msgstr "" + +#: includes/settings/status.php:48 +msgid "Plugin Status" +msgstr "" + +#: includes/settings/status.php:51 +msgid "Connected to ElasticSearch." +msgstr "" + +#: includes/settings/status.php:56 +msgid "ElasticPress can override WP search." +msgstr "" + +#: includes/settings/status.php:62 +msgid "" +"ElasticPress is not activated and cannot override WP search. You can " +"activate it on the form to the left." +msgstr "" + +#: includes/settings/status.php:67 +msgid "System Stats" +msgstr "" + +#: includes/settings/status.php:71 includes/settings/status.php:140 +msgid "Search Stats" +msgstr "" + +#: includes/settings/status.php:75 includes/settings/status.php:143 +msgid "Total Queries:" +msgstr "" + +#: includes/settings/status.php:78 includes/settings/status.php:146 +msgid "Query Time:" +msgstr "" + +#: includes/settings/status.php:82 includes/settings/status.php:149 +msgid "Total Fetches:" +msgstr "" + +#: includes/settings/status.php:85 includes/settings/status.php:152 +msgid "Fetch Time:" +msgstr "" + +#: includes/settings/status.php:94 includes/settings/status.php:158 +msgid "Index Stats" +msgstr "" + +#: includes/settings/status.php:98 includes/settings/status.php:161 +msgid "Index Total:" +msgstr "" + +#: includes/settings/status.php:101 includes/settings/status.php:164 +msgid "Index Time:" +msgstr "" + +#: includes/settings/status.php:112 +msgid "Site Stats" +msgstr "" + +#: includes/settings/status.php:117 +msgid "Select a site:" +msgstr "" + +#: includes/settings/status.php:118 +msgid "Select" +msgstr "" + +#: includes/settings/status.php:180 +msgid "Cluster Stats" +msgstr "" + +#: includes/settings/status.php:190 +msgid "Disk Usage:" +msgstr "" + +#: includes/settings/status.php:193 +msgid "Disk Space Available:" +msgstr "" + +#: includes/settings/status.php:196 +msgid "Total Disk Space:" +msgstr "" + +#: includes/settings/status.php:209 +msgid "ERROR:" +msgstr "" + #: node_modules/grunt-pot/test/fixtures/some-file.php:3 msgid "I'm a translatable string." msgstr "" From d6487b5501fb39ec735cdc807d50f929012c831d Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 2 Dec 2015 10:21:08 -0500 Subject: [PATCH 038/117] Better status messages --- assets/js/elasticpress-index-admin.js | 2 ++ assets/js/elasticpress-index-admin.min.js | 2 +- classes/class-ep-index-gui.php | 2 ++ lang/elasticpress.pot | 16 ++++++++++++---- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/assets/js/elasticpress-index-admin.js b/assets/js/elasticpress-index-admin.js index c2f86b6884..056f6c6b66 100644 --- a/assets/js/elasticpress-index-admin.js +++ b/assets/js/elasticpress-index-admin.js @@ -62,6 +62,8 @@ jQuery ( document ).ready ( function ( $ ) { if ( 'undefined' !== typeof response.responseJSON.data.ep_mapping_complete ) { + status.html ( ep.mapping_sites + '
    '+ response.responseJSON.data.ep_mapping_complete + ' ' + ep.sites_to_index ); + performIndex ( false, button ); } else if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete diff --git a/assets/js/elasticpress-index-admin.min.js b/assets/js/elasticpress-index-admin.min.js index 1b48f40386..3eee847c58 100644 --- a/assets/js/elasticpress-index-admin.min.js +++ b/assets/js/elasticpress-index-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if(console.log(f.responseJSON.data.ep_mapping_complete),"undefined"!=typeof f.responseJSON.data.ep_mapping_complete)b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if(console.log(f.responseJSON.data.ep_mapping_complete),"undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
    "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 10b20b9708..2d0278883d 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -102,6 +102,8 @@ public function action_admin_enqueue_scripts() { 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), 'items_indexed' => esc_html__( 'items indexed', 'elasticpress' ), + 'sites_to_index' => esc_html__( 'site(s) remain to be indexed', 'elasticpress' ), + 'mapping_sites' => esc_html__( 'We are settings up your site(s) for indexing. Please be patient.', 'elasticpress' ), 'counting_items' => esc_html__( 'We\'re Still counting total items for the index. Please be patient', 'elasticpress' ), 'index_running' => $running, 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 72678e1bca..74fc9a3c6a 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-12-02 09:47-0500\n" +"POT-Creation-Date: 2015-12-02 09:55-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -149,20 +149,28 @@ msgid "items indexed" msgstr "" #: classes/class-ep-index-gui.php:105 +msgid "site(s) remain to be indexed" +msgstr "" + +#: classes/class-ep-index-gui.php:106 +msgid "We are settings up your site(s) for indexing. Please be patient." +msgstr "" + +#: classes/class-ep-index-gui.php:107 msgid "We're Still counting total items for the index. Please be patient" msgstr "" -#: classes/class-ep-index-gui.php:155 classes/class-ep-settings.php:113 +#: classes/class-ep-index-gui.php:157 classes/class-ep-settings.php:113 msgid "Security error!" msgstr "" -#: classes/class-ep-index-gui.php:195 +#: classes/class-ep-index-gui.php:197 msgid "" "Mappings could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:208 +#: classes/class-ep-index-gui.php:210 msgid "" "Indexing could not be completed. If the error persists contact your system " "administrator" From 9610d084ae00f5508ed4c0d9c860d053b7ae0c4f Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 2 Dec 2015 10:58:55 -0500 Subject: [PATCH 039/117] Don't show debugging statement --- assets/js/elasticpress-index-admin.js | 2 -- assets/js/elasticpress-index-admin.min.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/assets/js/elasticpress-index-admin.js b/assets/js/elasticpress-index-admin.js index 056f6c6b66..2a22ac52c1 100644 --- a/assets/js/elasticpress-index-admin.js +++ b/assets/js/elasticpress-index-admin.js @@ -58,8 +58,6 @@ jQuery ( document ).ready ( function ( $ ) { data : data, complete : function ( response ) { - console.log( response.responseJSON.data.ep_mapping_complete ); - if ( 'undefined' !== typeof response.responseJSON.data.ep_mapping_complete ) { status.html ( ep.mapping_sites + '
    '+ response.responseJSON.data.ep_mapping_complete + ' ' + ep.sites_to_index ); diff --git a/assets/js/elasticpress-index-admin.min.js b/assets/js/elasticpress-index-admin.min.js index 3eee847c58..7b0a6fbb05 100644 --- a/assets/js/elasticpress-index-admin.min.js +++ b/assets/js/elasticpress-index-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if(console.log(f.responseJSON.data.ep_mapping_complete),"undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
    "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if("undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
    "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file From e1028bfa6e0f2b4ae1c426273fca9afbe312fbd8 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 2 Dec 2015 13:13:28 -0500 Subject: [PATCH 040/117] Serve site stats in chunks. --- Gruntfile.js | 3 - assets/css/elasticpress.css | 3 - assets/css/elasticpress.css.map | 2 +- assets/css/elasticpress.min.css | 2 +- assets/css/elasticpress.scss | 4 - assets/js/elasticpress-admin.js | 163 +++++++++++++++++++++- assets/js/elasticpress-admin.min.js | 2 +- assets/js/elasticpress-index-admin.js | 133 ------------------ assets/js/elasticpress-index-admin.min.js | 1 - classes/class-ep-index-gui.php | 123 ++++++++-------- classes/class-ep-settings.php | 34 ++++- includes/settings/status.php | 74 ++++------ lang/elasticpress.pot | 129 ++++++++--------- 13 files changed, 342 insertions(+), 331 deletions(-) delete mode 100644 assets/js/elasticpress-index-admin.js delete mode 100644 assets/js/elasticpress-index-admin.min.js diff --git a/Gruntfile.js b/Gruntfile.js index e5604716cc..53cb8c43d8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -21,9 +21,6 @@ module.exports = function ( grunt ) { files : { 'assets/js/elasticpress-admin.min.js' : [ 'assets/js/elasticpress-admin.js' - ], - 'assets/js/elasticpress-index-admin.min.js' : [ - 'assets/js/elasticpress-index-admin.js' ] } diff --git a/assets/css/elasticpress.css b/assets/css/elasticpress.css index 2440b8da81..b379f022f1 100644 --- a/assets/css/elasticpress.css +++ b/assets/css/elasticpress.css @@ -1,6 +1,3 @@ -#ep_stats .ep_site { - display: none; } - #ep_stats #ep_site_sel { padding: 15px 0 0 0; } diff --git a/assets/css/elasticpress.css.map b/assets/css/elasticpress.css.map index 51cd373e97..c848cfc7ac 100644 --- a/assets/css/elasticpress.css.map +++ b/assets/css/elasticpress.css.map @@ -1 +1 @@ -{"version":3,"sources":["elasticpress.scss"],"names":[],"mappings":"AAAA;EAGE,cAAe,EACf;;AAJF;EAOE,oBAAqB,EACrB;;AARF;EAWE,gBAAiB,EACjB;;AAZF;EAeE,eAAgB;EAChB,YAAe;EACf,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AApBF;EAuBE,eAAgB;EAChB,aAAgB;EAChB,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AA5BF;;EAgCE,YAAa;EACb,YAAa,EACb;;AAlCF;EAqCE,UAAY;EACZ,WAAY,EACZ;;AAvCF;EA2CE,iBAAkB;EAClB,UAAe;EACf,WAAe,EAMf;EAnDF;IAgDG,kBAAmB,EACnB","file":"elasticpress.css"} \ No newline at end of file +{"version":3,"sources":["elasticpress.scss"],"names":[],"mappings":"AAAA;EAGE,oBAAqB,EACrB;;AAJF;EAOE,gBAAiB,EACjB;;AARF;EAWE,eAAgB;EAChB,YAAe;EACf,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AAhBF;EAmBE,eAAgB;EAChB,aAAgB;EAChB,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AAxBF;;EA4BE,YAAa;EACb,YAAa,EACb;;AA9BF;EAiCE,UAAY;EACZ,WAAY,EACZ;;AAnCF;EAuCE,iBAAkB;EAClB,UAAe;EACf,WAAe,EAMf;EA/CF;IA4CG,kBAAmB,EACnB","file":"elasticpress.css"} \ No newline at end of file diff --git a/assets/css/elasticpress.min.css b/assets/css/elasticpress.min.css index 0ad2e733b1..6a1fd71e6d 100644 --- a/assets/css/elasticpress.min.css +++ b/assets/css/elasticpress.min.css @@ -1 +1 @@ -#ep_stats .ep_site{display:none}#ep_stats #ep_site_sel{padding:15px 0 0}#ep_stats .ep_stats_section{padding:20px 0}#ep_stats .index_stats,#ep_stats .search_stats{display:block;margin:0;padding:10px 0;width:50%}#ep_stats .search_stats{float:left}#ep_stats .index_stats{float:right}#ep_stats h3,#ep_stats ul{margin:0;padding:0}#ep_stats #ep_cluster_stats,#ep_stats #ep_ind_stats{clear:both;width:100%}#ep_stats ul{list-style:disc}#ep_stats ul li{margin-left:20px} \ No newline at end of file +#ep_stats #ep_site_sel{padding:15px 0 0}#ep_stats .ep_stats_section{padding:20px 0}#ep_stats .index_stats,#ep_stats .search_stats{display:block;margin:0;padding:10px 0;width:50%}#ep_stats .search_stats{float:left}#ep_stats .index_stats{float:right}#ep_stats h3,#ep_stats ul{margin:0;padding:0}#ep_stats #ep_cluster_stats,#ep_stats #ep_ind_stats{clear:both;width:100%}#ep_stats ul{list-style:disc}#ep_stats ul li{margin-left:20px} \ No newline at end of file diff --git a/assets/css/elasticpress.scss b/assets/css/elasticpress.scss index ca7b16b0d1..f1eff9a580 100644 --- a/assets/css/elasticpress.scss +++ b/assets/css/elasticpress.scss @@ -1,9 +1,5 @@ #ep_stats { - .ep_site { - display : none; - } - #ep_site_sel { padding : 15px 0 0 0; } diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 1814edb36f..342a9a6d46 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -1,16 +1,167 @@ -jQuery ( document ).ready ( function ( $ ) { +jQuery( document ).ready ( function ( $ ) { + /** + * Update the progress bar every 3 seconds + */ + var performIndex = function ( resetBar, button ) { + + $( button ).val ( ep.running_index_text ).removeClass ( 'button-primary' ); + + //Make sure the progress bar is showing + var bar = $( '#progressbar' ), + status = $( '#progressstats' ); + + bar.show (); + + if ( resetBar ) { + + var progress = 0; + + if ( parseInt( ep.total_posts ) > 0 ) { + + progress = parseFloat( ep.synced_posts ) / parseFloat( ep.total_posts ); + status.html ( ep.synced_posts + '/' + ep.total_posts + 'items' ); + + } else { + + status.html ( ep.counting_items ); + + } + + bar.progressbar ( + { + value : progress * 100 + } + ); + + } + + processIndex( bar, button, status ); + + }; + + /** + * Send request to server and process response + */ + var processIndex = function ( bar, button, status ) { + + var data = { + action : 'ep_launch_index', + nonce : ep.nonce + }; + + //call the ajax + $.ajax ( + { + url : ajaxurl, + type : 'POST', + data : data, + complete : function ( response ) { + + if ( 'undefined' !== typeof response.responseJSON.data.ep_mapping_complete ) { + + status.html ( ep.mapping_sites + '
    ' + response.responseJSON.data.ep_mapping_complete + ' ' + ep.sites_to_index ); + + performIndex( false, button ); + + } else if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete + + var progress = parseFloat( response.responseJSON.data.ep_posts_synced ) / parseFloat( response.responseJSON.data.ep_posts_total ); + + bar.progressbar ( + { + value : progress * 100 + } + ); + + status.html ( response.responseJSON.data.ep_posts_synced + '/' + response.responseJSON.data.ep_posts_total + ' ' + ep.items_indexed ); + + performIndex( false, button ); + + } else { //indexing complete + + bar.progressbar ( + { + value : 100 + } + ); + + setTimeout( function () { + + $( '#progressbar' ).fadeOut ( 'slow' ); + $( '#progressstats' ).html ( 'Index complete Refresh the stats' ); + $( '#ep_run_index' ).val ( ep.index_complete_text ).addClass ( 'button-primary' ); + + }, 1000 ); + + } + + } + + } + ); + + }; + + // The run index button + var run_index_button = $( '#ep_run_index' ); + + /** + * Start the poll if we need it + */ + if ( 1 === ep.index_running ) { + performIndex( true, run_index_button ); + } /** - * Show site stats + * Process indexing operation */ - $( '#ep_site_select' ).change( function() { + run_index_button.click ( function ( event ) { + + event.preventDefault (); + + var button = this; + + if ( ! $( button ).hasClass ( 'button-primary' ) ) { + return; + } + + performIndex( true, button ); //start the polling + + } ); + + // The stats selector + var selector = $( '#ep_site_select' ); + + /** + * Process changing site stats. + */ + selector.change( function ( event ) { + + event.preventDefault (); + + var data = { + action : 'ep_get_site_stats', + nonce : ep.stats_nonce, + site : selector.val() + }; + + //call the ajax + $.ajax ( + { + url : ajaxurl, + type : 'POST', + data : data, + complete : function ( response ) { + + console.log( $( '#ep_site_stats' ) ); - var siteId = $( this ).val(); + $( '#ep_site_stats' ).html( response.responseJSON.data ); - $( '.ep_site' ).hide(); + } - $( '#ep_' + siteId ).show(); + } + ); } ); diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index 126de1e57d..43b6372c81 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){a("#ep_site_select").change(function(){var b=a(this).val();a(".ep_site").hide(),a("#ep_"+b).show()})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if("undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
    "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var e=a("#ep_site_select");e.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:e.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){console.log(a("#ep_site_stats")),a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/assets/js/elasticpress-index-admin.js b/assets/js/elasticpress-index-admin.js deleted file mode 100644 index 2a22ac52c1..0000000000 --- a/assets/js/elasticpress-index-admin.js +++ /dev/null @@ -1,133 +0,0 @@ -jQuery ( document ).ready ( function ( $ ) { - - /** - * Update the progress bar every 3 seconds - */ - var performIndex = function ( resetBar, button ) { - - $ ( button ).val ( ep.running_index_text ).removeClass ( 'button-primary' ); - - //Make sure the progress bar is showing - var bar = $ ( '#progressbar' ), - status = $ ( '#progressstats' ); - - bar.show (); - - if ( resetBar ) { - - var progress = 0; - - if ( parseInt ( ep.total_posts ) > 0 ) { - - progress = parseFloat ( ep.synced_posts ) / parseFloat ( ep.total_posts ); - status.html ( ep.synced_posts + '/' + ep.total_posts + 'items' ); - - } else { - - status.html ( ep.counting_items ); - - } - - bar.progressbar ( - { - value : progress * 100 - } - ); - - } - - processIndex ( bar, button, status ); - - }; - - /** - * Send request to server and process response - */ - var processIndex = function ( bar, button, status ) { - - var data = { - action : 'ep_launch_index', - nonce : ep.nonce - }; - - //call the ajax - $.ajax ( - { - url : ajaxurl, - type : 'POST', - data : data, - complete : function ( response ) { - - if ( 'undefined' !== typeof response.responseJSON.data.ep_mapping_complete ) { - - status.html ( ep.mapping_sites + '
    '+ response.responseJSON.data.ep_mapping_complete + ' ' + ep.sites_to_index ); - - performIndex ( false, button ); - - } else if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete - - var progress = parseFloat ( response.responseJSON.data.ep_posts_synced ) / parseFloat ( response.responseJSON.data.ep_posts_total ); - - bar.progressbar ( - { - value : progress * 100 - } - ); - - status.html ( response.responseJSON.data.ep_posts_synced + '/' + response.responseJSON.data.ep_posts_total + ' ' + ep.items_indexed ); - - performIndex ( false, button ); - - } else { //indexing complete - - bar.progressbar ( - { - value : 100 - } - ); - - setTimeout ( function () { - - $ ( '#progressbar' ).fadeOut ( 'slow' ); - $ ( '#progressstats' ).html ( 'Index complete Refresh the stats' ); - $ ( '#ep_run_index' ).val ( ep.index_complete_text ).addClass ( 'button-primary' ); - - }, 1000 ); - - } - - } - - } - ); - - }; - - // The run index button - var run_index_button = $ ( '#ep_run_index' ); - - /** - * Start the poll if we need it - */ - if ( 1 === ep.index_running ) { - performIndex ( true, run_index_button ); - } - - /** - * Process indexing operation - */ - run_index_button.click ( function ( event ) { - - event.preventDefault (); - - var button = this; - - if ( ! $ ( button ).hasClass ( 'button-primary' ) ) { - return; - } - - performIndex ( true, button ); //start the polling - - } ); - -} ); diff --git a/assets/js/elasticpress-index-admin.min.js b/assets/js/elasticpress-index-admin.min.js deleted file mode 100644 index 7b0a6fbb05..0000000000 --- a/assets/js/elasticpress-index-admin.min.js +++ /dev/null @@ -1 +0,0 @@ -jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if("undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
    "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)})}); \ No newline at end of file diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 2d0278883d..03a985da01 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -44,76 +44,15 @@ public function __construct() { // Load the class files. require( dirname( __FILE__ ) . '/class-ep-index-worker.php' ); - // Add JavaScripts. - add_action( 'admin_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts' ) ); - // Add Ajax Actions. add_action( 'wp_ajax_ep_launch_index', array( $this, 'action_wp_ajax_ep_launch_index' ) ); + add_action( 'wp_ajax_ep_get_site_stats', array( $this, 'action_wp_ajax_ep_get_site_stats' ) ); add_action( 'ep_do_settings_meta', array( $this, 'action_ep_do_settings_meta' ) ); return $this; } - /** - * Register and Enqueue JavaScripts - * - * Registers and enqueues the necessary JavaScripts for the interface. - * - * @since 0.1.0 - * - * @return void - */ - public function action_admin_enqueue_scripts() { - - // Enqueue more easily debugged version if applicable. - if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { - - wp_register_script( 'ep_index', EP_URL . 'assets/js/elasticpress-index-admin.js', array( 'jquery', 'jquery-ui-progressbar' ), EP_VERSION ); - - } else { - - wp_register_script( 'ep_index', EP_URL . 'assets/js/elasticpress-index-admin.min.js', array( 'jquery', 'jquery-ui-progressbar' ), EP_VERSION ); - - } - - // Only add the following to the settings page. - if ( isset( get_current_screen()->id ) && strpos( get_current_screen()->id, 'settings_page_elasticpress' ) !== false ) { - - wp_enqueue_script( 'ep_index' ); - - $running = 0; - $total_posts = 0; - $synced_posts = 0; - - if ( false !== get_transient( 'ep_index_offset' ) ) { - - $running = 1; - $synced_posts = get_transient( 'ep_index_synced' ); - $total_posts = get_transient( 'ep_post_count' ); - - } - - wp_localize_script( - 'ep_index', - 'ep', - array( - 'nonce' => wp_create_nonce( 'ep_manual_index' ), - 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), - 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), - 'items_indexed' => esc_html__( 'items indexed', 'elasticpress' ), - 'sites_to_index' => esc_html__( 'site(s) remain to be indexed', 'elasticpress' ), - 'mapping_sites' => esc_html__( 'We are settings up your site(s) for indexing. Please be patient.', 'elasticpress' ), - 'counting_items' => esc_html__( 'We\'re Still counting total items for the index. Please be patient', 'elasticpress' ), - 'index_running' => $running, - 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, - 'synced_posts' => $synced_posts, - ) - ); - - } - } - /** * Add index settings box * @@ -233,4 +172,64 @@ public function action_wp_ajax_ep_launch_index() { wp_send_json_success( $data ); } + + /** + * Process site stats + * + * Returns the HTML for stats for an individual site. + * + * @since 1.8 + * + * @return void + */ + public function action_wp_ajax_ep_get_site_stats() { + + // Verify nonce and make sure this is run by an admin. + if ( ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'ep_site_stats' ) || ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( esc_html__( 'Security error!', 'elasticpress' ) ); + } + + $site = intval( $_POST['site'] ); + + $index_stats = ep_get_index_status( $site ); + $search_stats = ep_get_search_status( $site ); + + $stats = '
    '; + + if ( $index_stats['status'] ) { + + $stats .= '
    '; + $stats .= sprintf( '

    %s

    ', esc_html__( 'Search Stats', 'elasticpress' ) ); + $stats .= '
      '; + $stats .= '
    • '; + $stats .= '' . esc_html__( 'Total Queries:', 'elasticpress' ) . ' ' . esc_html( $search_stats->query_total ); + $stats .= '
    • '; + $stats .= '
    • '; + $stats .= '' . esc_html__( 'Query Time:', 'elasticpress' ) . ' ' . esc_html( $search_stats->query_time_in_millis ) . 'ms'; + $stats .= '
    • '; + $stats .= '
    • '; + $stats .= '' . esc_html__( 'Total Fetches:', 'elasticpress' ) . ' ' . esc_html( $search_stats->fetch_total ); + $stats .= '
    • '; + $stats .= '
    • '; + $stats .= '' . esc_html__( 'Fetch Time:', 'elasticpress' ) . ' ' . esc_html( $search_stats->fetch_time_in_millis ) . 'ms'; + $stats .= '
    • '; + $stats .= '
    '; + $stats .= '
    '; + $stats .= '
    '; + $stats .= sprintf( '

    %s

    ', esc_html__( 'Index Stats', 'elasticpress' ) ); + $stats .= '
      '; + $stats .= '
    • '; + $stats .= '' . esc_html__( 'Index Total:', 'elasticpress' ) . ' ' . esc_html( $index_stats['data']->index_total ); + $stats .= '
    • '; + $stats .= '
    • '; + $stats .= '' . esc_html__( 'Index Time:', 'elasticpress' ) . ' ' . esc_html( $index_stats['data']->index_time_in_millis ) . 'ms'; + $stats .= '
    • '; + $stats .= '
    '; + $stats .= '
    '; + } + $stats .= '
    '; + + wp_send_json_success( $stats ); + + } } diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 6f52176163..56e15bc4b2 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -70,14 +70,14 @@ public function action_admin_enqueue_scripts() { // Enqueue more easily debugged version if applicable. if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { - wp_register_script( 'ep_admin', EP_URL . 'assets/js/elasticpress-admin.js', array( 'jquery' ), EP_VERSION ); + wp_register_script( 'ep_admin', EP_URL . 'assets/js/elasticpress-admin.js', array( 'jquery', 'jquery-ui-progressbar' ), EP_VERSION ); wp_register_style( 'ep_progress_style', EP_URL . 'assets/css/jquery-ui.css', array(), EP_VERSION ); wp_register_style( 'ep_styles', EP_URL . 'assets/css/elasticpress.css', array(), EP_VERSION ); } else { - wp_register_script( 'ep_admin', EP_URL . 'assets/js/elasticpress-admin.min.js', array( 'jquery' ), EP_VERSION ); + wp_register_script( 'ep_admin', EP_URL . 'assets/js/elasticpress-admin.min.js', array( 'jquery', 'jquery-ui-progressbar' ), EP_VERSION ); wp_register_style( 'ep_progress_style', EP_URL . 'assets/css/jquery-ui.min.css', array(), EP_VERSION ); wp_register_style( 'ep_styles', EP_URL . 'assets/css/elasticpress.min.css', array(), EP_VERSION ); @@ -92,6 +92,36 @@ public function action_admin_enqueue_scripts() { wp_enqueue_script( 'ep_admin' ); + $running = 0; + $total_posts = 0; + $synced_posts = 0; + + if ( false !== get_transient( 'ep_index_offset' ) ) { + + $running = 1; + $synced_posts = get_transient( 'ep_index_synced' ); + $total_posts = get_transient( 'ep_post_count' ); + + } + + wp_localize_script( + 'ep_admin', + 'ep', + array( + 'nonce' => wp_create_nonce( 'ep_manual_index' ), + 'stats_nonce' => wp_create_nonce( 'ep_site_stats' ), + 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), + 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), + 'items_indexed' => esc_html__( 'items indexed', 'elasticpress' ), + 'sites_to_index' => esc_html__( 'site(s) remain to be indexed', 'elasticpress' ), + 'mapping_sites' => esc_html__( 'We are settings up your site(s) for indexing. Please be patient.', 'elasticpress' ), + 'counting_items' => esc_html__( 'We\'re Still counting total items for the index. Please be patient', 'elasticpress' ), + 'index_running' => $running, + 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, + 'synced_posts' => $synced_posts, + ) + ); + } } diff --git a/includes/settings/status.php b/includes/settings/status.php index 30c60a6d96..cc1d256322 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -11,7 +11,7 @@ $site_stats_id = null; -if ( is_multisite() && ( ! defined( 'EP_IS_NETWORK' ) || ! EP_IS_NETWORK ) ) { +if ( is_multisite() && ( ! defined( 'EP_IS_NETWORK' ) || ! EP_IS_NETWORK ) ) { $site_stats_id = get_current_blog_id(); } @@ -53,7 +53,8 @@
    + style="color:green;"> +

    @@ -98,7 +99,8 @@ index_total ); ?>
  • - index_time_in_millis ); ?>ms + index_time_in_millis ); ?> + ms
  • @@ -111,64 +113,35 @@ printf( '

    %s

    ', esc_html__( 'Site Stats', 'elasticpress' ) ); - $sites = ep_get_sites(); - echo '
    '; echo '' . esc_html__( 'Select a site:', 'elasticpress' ) . ' '; echo '
    '; - foreach ( $sites as $site ) { - - $stats = ep_get_index_status( $site['blog_id'] ); - $search_stats = ep_get_search_status( $site['blog_id'] ); - $details = get_blog_details( $site['blog_id'] ); - ?> -
    - -
    - %s', esc_html__( 'Search Stats', 'elasticpress' ) ); ?> -
      -
    • - query_total ); ?> -
    • -
    • - query_time_in_millis ); ?>ms -
    • -
    • - fetch_total ); ?> -
    • -
    • - fetch_time_in_millis ); ?>ms -
    • -
    - -
    -
    - %s', esc_html__( 'Index Stats', 'elasticpress' ) ); ?> -
      -
    • - index_total ); ?> -
    • -
    • - index_time_in_millis ); ?>ms -
    • -
    -
    - -
    -
    '; echo ''; @@ -187,7 +160,8 @@
    • - total_in_bytes ) * 100, 0 ) ); ?>% + total_in_bytes ) * 100, 0 ) ); ?> + %
    • ep_byte_size( $fs->available_in_bytes ) ); ?> diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 74fc9a3c6a..39945d5530 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-12-02 09:55-0500\n" +"POT-Creation-Date: 2015-12-02 13:07-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -136,44 +136,53 @@ msgstr "" msgid "No running host available." msgstr "" -#: classes/class-ep-index-gui.php:102 includes/settings/index.php:14 -msgid "Running Index..." +#: classes/class-ep-index-gui.php:96 classes/class-ep-index-gui.php:189 +#: classes/class-ep-settings.php:143 +msgid "Security error!" msgstr "" -#: classes/class-ep-index-gui.php:103 includes/settings/index.php:14 -msgid "Run Index" +#: classes/class-ep-index-gui.php:136 +msgid "" +"Mappings could not be completed. If the error persists contact your system " +"administrator" msgstr "" -#: classes/class-ep-index-gui.php:104 -msgid "items indexed" +#: classes/class-ep-index-gui.php:149 +msgid "" +"Indexing could not be completed. If the error persists contact your system " +"administrator" msgstr "" -#: classes/class-ep-index-gui.php:105 -msgid "site(s) remain to be indexed" +#: classes/class-ep-index-gui.php:202 includes/settings/status.php:71 +msgid "Search Stats" msgstr "" -#: classes/class-ep-index-gui.php:106 -msgid "We are settings up your site(s) for indexing. Please be patient." +#: classes/class-ep-index-gui.php:205 includes/settings/status.php:75 +msgid "Total Queries:" msgstr "" -#: classes/class-ep-index-gui.php:107 -msgid "We're Still counting total items for the index. Please be patient" +#: classes/class-ep-index-gui.php:208 includes/settings/status.php:78 +msgid "Query Time:" msgstr "" -#: classes/class-ep-index-gui.php:157 classes/class-ep-settings.php:113 -msgid "Security error!" +#: classes/class-ep-index-gui.php:211 includes/settings/status.php:82 +msgid "Total Fetches:" msgstr "" -#: classes/class-ep-index-gui.php:197 -msgid "" -"Mappings could not be completed. If the error persists contact your system " -"administrator" +#: classes/class-ep-index-gui.php:214 includes/settings/status.php:85 +msgid "Fetch Time:" msgstr "" -#: classes/class-ep-index-gui.php:210 -msgid "" -"Indexing could not be completed. If the error persists contact your system " -"administrator" +#: classes/class-ep-index-gui.php:219 includes/settings/status.php:94 +msgid "Index Stats" +msgstr "" + +#: classes/class-ep-index-gui.php:222 includes/settings/status.php:98 +msgid "Index Total:" +msgstr "" + +#: classes/class-ep-index-gui.php:225 includes/settings/status.php:101 +msgid "Index Time:" msgstr "" #: classes/class-ep-index-status.php:60 @@ -188,19 +197,43 @@ msgstr "" msgid ": ElasticPress Index Errors" msgstr "" -#: classes/class-ep-settings.php:146 +#: classes/class-ep-settings.php:113 includes/settings/index.php:14 +msgid "Running Index..." +msgstr "" + +#: classes/class-ep-settings.php:114 includes/settings/index.php:14 +msgid "Run Index" +msgstr "" + +#: classes/class-ep-settings.php:115 +msgid "items indexed" +msgstr "" + +#: classes/class-ep-settings.php:116 +msgid "site(s) remain to be indexed" +msgstr "" + +#: classes/class-ep-settings.php:117 +msgid "We are settings up your site(s) for indexing. Please be patient." +msgstr "" + +#: classes/class-ep-settings.php:118 +msgid "We're Still counting total items for the index. Please be patient" +msgstr "" + +#: classes/class-ep-settings.php:176 msgid "ElasticSearch Host:" msgstr "" -#: classes/class-ep-settings.php:151 +#: classes/class-ep-settings.php:181 msgid "ElasticPress API Key:" msgstr "" -#: classes/class-ep-settings.php:160 +#: classes/class-ep-settings.php:190 msgid "Use ElasticSearch:" msgstr "" -#: classes/class-ep-settings.php:398 +#: classes/class-ep-settings.php:428 msgid "ElasticSearch Integration Options" msgstr "" @@ -263,38 +296,6 @@ msgstr "" msgid "System Stats" msgstr "" -#: includes/settings/status.php:71 includes/settings/status.php:140 -msgid "Search Stats" -msgstr "" - -#: includes/settings/status.php:75 includes/settings/status.php:143 -msgid "Total Queries:" -msgstr "" - -#: includes/settings/status.php:78 includes/settings/status.php:146 -msgid "Query Time:" -msgstr "" - -#: includes/settings/status.php:82 includes/settings/status.php:149 -msgid "Total Fetches:" -msgstr "" - -#: includes/settings/status.php:85 includes/settings/status.php:152 -msgid "Fetch Time:" -msgstr "" - -#: includes/settings/status.php:94 includes/settings/status.php:158 -msgid "Index Stats" -msgstr "" - -#: includes/settings/status.php:98 includes/settings/status.php:161 -msgid "Index Total:" -msgstr "" - -#: includes/settings/status.php:101 includes/settings/status.php:164 -msgid "Index Time:" -msgstr "" - #: includes/settings/status.php:112 msgid "Site Stats" msgstr "" @@ -307,23 +308,23 @@ msgstr "" msgid "Select" msgstr "" -#: includes/settings/status.php:180 +#: includes/settings/status.php:140 msgid "Cluster Stats" msgstr "" -#: includes/settings/status.php:190 +#: includes/settings/status.php:150 msgid "Disk Usage:" msgstr "" -#: includes/settings/status.php:193 +#: includes/settings/status.php:153 msgid "Disk Space Available:" msgstr "" -#: includes/settings/status.php:196 +#: includes/settings/status.php:156 msgid "Total Disk Space:" msgstr "" -#: includes/settings/status.php:209 +#: includes/settings/status.php:169 msgid "ERROR:" msgstr "" From 9e1345d05fb662c23239356dde89121e3538596d Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 2 Dec 2015 13:25:45 -0500 Subject: [PATCH 041/117] Some cleanup --- assets/js/elasticpress-admin.js | 2 +- assets/js/elasticpress-admin.min.js | 2 +- classes/class-ep-settings.php | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 342a9a6d46..392157c75c 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -24,7 +24,7 @@ jQuery( document ).ready ( function ( $ ) { } else { - status.html ( ep.counting_items ); + status.html ( ep.mapping_sites ); } diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index 43b6372c81..c8504c11d8 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.counting_items),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if("undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
      "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var e=a("#ep_site_select");e.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:e.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){console.log(a("#ep_site_stats")),a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.mapping_sites),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if("undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
      "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var e=a("#ep_site_select");e.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:e.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){console.log(a("#ep_site_stats")),a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 56e15bc4b2..c183ad8f0b 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -115,7 +115,6 @@ public function action_admin_enqueue_scripts() { 'items_indexed' => esc_html__( 'items indexed', 'elasticpress' ), 'sites_to_index' => esc_html__( 'site(s) remain to be indexed', 'elasticpress' ), 'mapping_sites' => esc_html__( 'We are settings up your site(s) for indexing. Please be patient.', 'elasticpress' ), - 'counting_items' => esc_html__( 'We\'re Still counting total items for the index. Please be patient', 'elasticpress' ), 'index_running' => $running, 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, 'synced_posts' => $synced_posts, From e04391450310110c79fb7d9bac117ee7f15b14d9 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 2 Dec 2015 13:29:00 -0500 Subject: [PATCH 042/117] Fix stats selector --- assets/js/elasticpress-admin.js | 4 ++-- assets/js/elasticpress-admin.min.js | 2 +- includes/settings/status.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 392157c75c..1517fe7701 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -140,6 +140,8 @@ jQuery( document ).ready ( function ( $ ) { event.preventDefault (); + console.log( selector.val() ); + var data = { action : 'ep_get_site_stats', nonce : ep.stats_nonce, @@ -154,8 +156,6 @@ jQuery( document ).ready ( function ( $ ) { data : data, complete : function ( response ) { - console.log( $( '#ep_site_stats' ) ); - $( '#ep_site_stats' ).html( response.responseJSON.data ); } diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index c8504c11d8..0e3965a7a2 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.mapping_sites),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if("undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
      "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var e=a("#ep_site_select");e.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:e.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){console.log(a("#ep_site_stats")),a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.mapping_sites),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if("undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
      "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var e=a("#ep_site_select");e.change(function(b){b.preventDefault(),console.log(e.val());var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:e.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/includes/settings/status.php b/includes/settings/status.php index cc1d256322..06860b0c74 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -136,7 +136,7 @@ } - echo wp_kses( $site_list, array( 'option' => array( 'value' ) ) ); + echo wp_kses( $site_list, array( 'option' => array( 'value' => array() ) ) ); echo ''; echo ''; From ddbce25ad0ab8cd381750bec2f6ba0c5ac8f9d0b Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 2 Dec 2015 14:26:10 -0500 Subject: [PATCH 043/117] Delete network alias for full index --- classes/class-ep-index-worker.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index bfdef8e5a2..d78909ef40 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -87,6 +87,8 @@ public function index( $network_wide = false ) { if ( true === $network_wide && is_multisite() ) { + ep_delete_network_alias(); + $sites = ep_get_sites(); foreach ( $sites as $site ) { From 8ffbd309bead137489e7583d5f66693fdf80a1e9 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 16 Dec 2015 09:36:38 -0500 Subject: [PATCH 044/117] Improve copy Improves copy when mapping sites --- classes/class-ep-settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index c183ad8f0b..c721d45b7d 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -113,7 +113,7 @@ public function action_admin_enqueue_scripts() { 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), 'items_indexed' => esc_html__( 'items indexed', 'elasticpress' ), - 'sites_to_index' => esc_html__( 'site(s) remain to be indexed', 'elasticpress' ), + 'sites_to_index' => esc_html__( 'site(s) remain to be mapped', 'elasticpress' ), 'mapping_sites' => esc_html__( 'We are settings up your site(s) for indexing. Please be patient.', 'elasticpress' ), 'index_running' => $running, 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, From 86cfc538f7aab9cf8d64b0c8e7f3c12ed16570d4 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 16 Dec 2015 10:45:49 -0500 Subject: [PATCH 045/117] We should know if it is a network first. --- classes/class-ep-index-gui.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 03a985da01..7f0c96b709 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -96,6 +96,12 @@ public function action_wp_ajax_ep_launch_index() { wp_send_json_error( esc_html__( 'Security error!', 'elasticpress' ) ); } + $network = false; + + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + $network = true; + } + $post_count = array( 'total' => 0 ); $post_types = ep_get_indexable_post_types(); $post_statuses = ep_get_indexable_post_status(); @@ -117,12 +123,6 @@ public function action_wp_ajax_ep_launch_index() { set_transient( 'ep_post_count', $post_count, 600 ); - $network = false; - - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { - $network = true; - } - if ( false === get_transient( 'ep_index_offset' ) ) { // Deactivate our search integration. From 256fe25b4b41bd1fd78cec521e99addb7d686c7a Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 16 Dec 2015 13:52:03 -0500 Subject: [PATCH 046/117] The GUI indexing now works like it should. Cleanup and a better status update to come. --- classes/class-ep-index-gui.php | 138 ++++++++++++++++++++++++++------- 1 file changed, 108 insertions(+), 30 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 7f0c96b709..c7b376e97d 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -80,27 +80,7 @@ public function action_ep_do_settings_meta( $ep_settings ) { } - /** - * Process manual indexing - * - * Processes the action when the manual indexing button is clicked. - * - * @since 0.1.0 - * - * @return void - */ - public function action_wp_ajax_ep_launch_index() { - - // Verify nonce and make sure this is run by an admin. - if ( ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'ep_manual_index' ) || ! current_user_can( 'manage_options' ) ) { - wp_send_json_error( esc_html__( 'Security error!', 'elasticpress' ) ); - } - - $network = false; - - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { - $network = true; - } + protected function _run_index() { $post_count = array( 'total' => 0 ); $post_types = ep_get_indexable_post_types(); @@ -128,7 +108,7 @@ public function action_wp_ajax_ep_launch_index() { // Deactivate our search integration. ep_deactivate(); - $mapping_success = ep_process_site_mappings( $network ); + $mapping_success = ep_process_site_mappings(); if ( true !== $mapping_success ) { @@ -143,33 +123,131 @@ public function action_wp_ajax_ep_launch_index() { } $indexer = new EP_Index_Worker(); - $index_success = $indexer->index( $network ); + $index_success = $indexer->index(); if ( ! $index_success ) { - wp_send_json_error( esc_html__( 'Indexing could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); + return new WP_Error( esc_html__( 'Indexing could not be completed. If the error persists contact your system administrator', 'elasticpress' ) ); } + $total = get_transient( 'ep_post_count' ); + if ( false === get_transient( 'ep_index_offset' ) ) { // Reactivate our search integration. ep_activate(); $data = array( - 'ep_sync_complete' => 1, + 'ep_sync_complete' => true, + 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), + 'ep_posts_total' => absint( $total['total'] ), ); } else { - $total = get_transient( 'ep_post_count' ); - $data = array( - 'ep_sync_complete' => 0, - 'ep_posts_synced' => get_transient( 'ep_index_synced' ), + 'ep_sync_complete' => false, + 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), 'ep_posts_total' => absint( $total['total'] ), ); } - wp_send_json_success( $data ); + return $data; + + } + + /** + * Process manual indexing + * + * Processes the action when the manual indexing button is clicked. + * + * @since 0.1.0 + * + * @return void + */ + public function action_wp_ajax_ep_launch_index() { + + // Verify nonce and make sure this is run by an admin. + if ( ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'ep_manual_index' ) || ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( esc_html__( 'Security error!', 'elasticpress' ) ); + } + + $network = false; + $site = false; + $sites = false; + $indexes = false; + + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + $network = true; + } + + if ( true === $network ) { + + $last_run = get_site_transient( 'ep_sites_to_index' ); + + if ( false === $last_run ) { + + $sites = ep_get_sites(); + $success = array(); + $indexes = array(); + + } else { + + $sites = ( isset( $last_run['sites'] ) ) ? $last_run['sites'] : ep_get_sites(); + $success = ( isset( $last_run['success'] ) ) ? $last_run['success'] : array(); + $indexes = ( isset( $last_run['indexes'] ) ) ? $last_run['indexes'] : array(); + + } + + $site_info = array_pop( $sites ); + $site = absint( $site_info['blog_id'] ); + } + + if ( false !== $site ) { + switch_to_blog( $site ); + } + + $result = $this->_run_index(); + + if ( false !== $site ) { + $indexes[] = ep_get_index_name(); + restore_current_blog(); + } + + if ( is_array( $result ) && isset( $result['ep_sync_complete'] ) ) { + + if ( true === $result['ep_sync_complete'] ) { + + if ( $network ) { + + $success[] = $site; + + $last_run = array( + 'sites' => $sites, + 'success' => $success, + 'indexes' => $indexes, + ); + + set_site_transient( 'ep_sites_to_index', $last_run, 600 ); + + if ( ! empty( $sites ) ) { + + $result['ep_sync_complete'] = 0; + + } else { + + $result['ep_sync_complete'] = 1; + delete_site_transient( 'ep_sites_to_index' ); + ep_create_network_alias( $indexes ); + + } + } + + ep_activate(); + + } + } + + wp_send_json_success( $result ); } From 0bb2ee578fcd6564a0254f649a8f071d47e59ff6 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 16 Dec 2015 13:56:53 -0500 Subject: [PATCH 047/117] Remove unnecessary complications. Removes overly-complicated code that had previously been used for multisite indexing. --- classes/class-ep-index-worker.php | 38 ++++--------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index d78909ef40..41bfee4f38 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -75,46 +75,16 @@ protected function _create_network_alias() { * * @since 0.1.0 * - * @param bool $network_wide To index network wide or not. - * * @return bool True on success or false */ - public function index( $network_wide = false ) { + public function index() { ep_check_host(); - $total_indexed = 0; - - if ( true === $network_wide && is_multisite() ) { - - ep_delete_network_alias(); - - $sites = ep_get_sites(); - - foreach ( $sites as $site ) { + $result = $this->_index_helper(); - switch_to_blog( $site['blog_id'] ); - - $result = $this->_index_helper(); - - $total_indexed += $result['synced']; - - if ( ! empty( $result['errors'] ) ) { - return false; - } - - restore_current_blog(); - } - - $this->_create_network_alias(); - - } else { - - $result = $this->_index_helper(); - - if ( ! empty( $result['errors'] ) ) { - return false; - } + if ( ! empty( $result['errors'] ) ) { + return false; } return true; From 53fa6c3c42adbfe14cf8e9bce2cfef55ff7bd324 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 16 Dec 2015 14:33:39 -0500 Subject: [PATCH 048/117] Make sure post counts can get through --- classes/class-ep-index-gui.php | 15 ++++++++++----- classes/class-ep-index-worker.php | 2 -- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index c7b376e97d..4b2a1f07cb 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -133,9 +133,6 @@ protected function _run_index() { if ( false === get_transient( 'ep_index_offset' ) ) { - // Reactivate our search integration. - ep_activate(); - $data = array( 'ep_sync_complete' => true, 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), @@ -193,8 +190,8 @@ public function action_wp_ajax_ep_launch_index() { } else { $sites = ( isset( $last_run['sites'] ) ) ? $last_run['sites'] : ep_get_sites(); - $success = ( isset( $last_run['success'] ) ) ? $last_run['success'] : array(); - $indexes = ( isset( $last_run['indexes'] ) ) ? $last_run['indexes'] : array(); + $success = ( isset( $last_run['success'] ) ) ? $last_run['success'] : array(); + $indexes = ( isset( $last_run['indexes'] ) ) ? $last_run['indexes'] : array(); } @@ -210,6 +207,14 @@ public function action_wp_ajax_ep_launch_index() { if ( false !== $site ) { $indexes[] = ep_get_index_name(); + + if ( is_array( $result ) && isset( $result['ep_sync_complete'] ) ) { + + delete_transient( 'ep_index_synced' ); + delete_transient( 'ep_post_count' ); + + } + restore_current_blog(); } diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index 41bfee4f38..8071e0cae0 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -179,8 +179,6 @@ protected function _index_helper() { if ( true === $complete ) { delete_transient( 'ep_index_offset' ); - delete_transient( 'ep_index_synced' ); - delete_transient( 'ep_post_count' ); $this->send_bulk_errors(); } From 2291428a3694af73d3f4427000b2c9a11d8cd5f9 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 16 Dec 2015 15:43:27 -0500 Subject: [PATCH 049/117] Status updates improved Post totals are working but posts synced now need to be repaired for sites with more than the max synced. --- assets/js/elasticpress-admin.js | 71 ++++++++++++++++++++++----------- classes/class-ep-index-gui.php | 28 ++++++++++++- classes/class-ep-settings.php | 2 - 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 1517fe7701..12a33bacb0 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -1,17 +1,17 @@ -jQuery( document ).ready ( function ( $ ) { +jQuery( document ).ready( function ( $ ) { /** * Update the progress bar every 3 seconds */ var performIndex = function ( resetBar, button ) { - $( button ).val ( ep.running_index_text ).removeClass ( 'button-primary' ); + $( button ).val( ep.running_index_text ).removeClass( 'button-primary' ); //Make sure the progress bar is showing var bar = $( '#progressbar' ), status = $( '#progressstats' ); - bar.show (); + bar.show(); if ( resetBar ) { @@ -20,15 +20,15 @@ jQuery( document ).ready ( function ( $ ) { if ( parseInt( ep.total_posts ) > 0 ) { progress = parseFloat( ep.synced_posts ) / parseFloat( ep.total_posts ); - status.html ( ep.synced_posts + '/' + ep.total_posts + 'items' ); + status.html( ep.synced_posts + '/' + ep.total_posts + 'items' ); } else { - status.html ( ep.mapping_sites ); + status.html( ep.mapping_sites ); } - bar.progressbar ( + bar.progressbar( { value : progress * 100 } @@ -40,6 +40,19 @@ jQuery( document ).ready ( function ( $ ) { }; + var epSitesRemaining = 0; + var epTotalToIndex = 0; + var epTotalIndexed = 0; + + // Resets index counts + var resetIndex = function () { + + epSitesRemaining = 0; + epTotalToIndex = 0; + epTotalIndexed = 0; + + }; + /** * Send request to server and process response */ @@ -51,36 +64,45 @@ jQuery( document ).ready ( function ( $ ) { }; //call the ajax - $.ajax ( + $.ajax( { url : ajaxurl, type : 'POST', data : data, complete : function ( response ) { - if ( 'undefined' !== typeof response.responseJSON.data.ep_mapping_complete ) { + console.log( response.responseJSON.data ); - status.html ( ep.mapping_sites + '
      ' + response.responseJSON.data.ep_mapping_complete + ' ' + ep.sites_to_index ); + if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete - performIndex( false, button ); + if ( 0 < response.responseJSON.data.ep_sites_remaining && epSitesRemaining !== response.responseJSON.data.ep_sites_remaining ) { - } else if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete + epSitesRemaining = response.responseJSON.data.ep_sites_remaining; + epTotalToIndex += response.responseJSON.data.ep_posts_total; - var progress = parseFloat( response.responseJSON.data.ep_posts_synced ) / parseFloat( response.responseJSON.data.ep_posts_total ); + } else if ( 0 === response.responseJSON.data.is_network ) { - bar.progressbar ( + epTotalToIndex = response.responseJSON.data.ep_posts_total; + + } + + epTotalIndexed += response.responseJSON.data.ep_posts_synced; + + var progress = parseFloat( epTotalIndexed ) / parseFloat( epTotalToIndex ); + + bar.progressbar( { value : progress * 100 } ); - status.html ( response.responseJSON.data.ep_posts_synced + '/' + response.responseJSON.data.ep_posts_total + ' ' + ep.items_indexed ); + status.html( epTotalIndexed + '/' + epTotalToIndex + ' ' + ep.items_indexed ); performIndex( false, button ); } else { //indexing complete - bar.progressbar ( + bar.progressbar( { value : 100 } @@ -88,9 +110,10 @@ jQuery( document ).ready ( function ( $ ) { setTimeout( function () { - $( '#progressbar' ).fadeOut ( 'slow' ); - $( '#progressstats' ).html ( 'Index complete Refresh the stats' ); - $( '#ep_run_index' ).val ( ep.index_complete_text ).addClass ( 'button-primary' ); + $( '#progressbar' ).fadeOut( 'slow' ); + $( '#progressstats' ).html( 'Index complete Refresh the stats' ); + $( '#ep_run_index' ).val( ep.index_complete_text ).addClass( 'button-primary' ); + resetIndex(); }, 1000 ); @@ -116,13 +139,15 @@ jQuery( document ).ready ( function ( $ ) { /** * Process indexing operation */ - run_index_button.click ( function ( event ) { + run_index_button.click( function ( event ) { + + event.preventDefault(); - event.preventDefault (); + resetIndex(); var button = this; - if ( ! $( button ).hasClass ( 'button-primary' ) ) { + if ( ! $( button ).hasClass( 'button-primary' ) ) { return; } @@ -138,7 +163,7 @@ jQuery( document ).ready ( function ( $ ) { */ selector.change( function ( event ) { - event.preventDefault (); + event.preventDefault(); console.log( selector.val() ); @@ -149,7 +174,7 @@ jQuery( document ).ready ( function ( $ ) { }; //call the ajax - $.ajax ( + $.ajax( { url : ajaxurl, type : 'POST', diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 4b2a1f07cb..3b1b4d7ea2 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -206,9 +206,10 @@ public function action_wp_ajax_ep_launch_index() { $result = $this->_run_index(); if ( false !== $site ) { + $indexes[] = ep_get_index_name(); - if ( is_array( $result ) && isset( $result['ep_sync_complete'] ) ) { + if ( is_array( $result ) && isset( $result['ep_sync_complete'] )&& true === $result['ep_sync_complete'] ) { delete_transient( 'ep_index_synced' ); delete_transient( 'ep_post_count' ); @@ -216,6 +217,15 @@ public function action_wp_ajax_ep_launch_index() { } restore_current_blog(); + + } else { + + if ( is_array( $result ) && isset( $result['ep_sync_complete'] ) && true === $result['ep_sync_complete'] ) { + + delete_transient( 'ep_index_synced' ); + delete_transient( 'ep_post_count' ); + + } } if ( is_array( $result ) && isset( $result['ep_sync_complete'] ) ) { @@ -245,6 +255,10 @@ public function action_wp_ajax_ep_launch_index() { ep_create_network_alias( $indexes ); } + } else { + + $result['ep_sync_complete'] = ( true === $result['ep_sync_complete'] ) ? 1 : 0; + } ep_activate(); @@ -252,6 +266,18 @@ public function action_wp_ajax_ep_launch_index() { } } + if ( ! empty( $sites ) ) { + + $result['ep_sites_remaining'] = sizeof( $sites ); + + } else { + + $result['ep_sites_remaining'] = 0; + + } + + $result['is_network'] = ( true === $network ) ? 1 : 0; + wp_send_json_success( $result ); } diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index c721d45b7d..837efa50fd 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -113,8 +113,6 @@ public function action_admin_enqueue_scripts() { 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), 'items_indexed' => esc_html__( 'items indexed', 'elasticpress' ), - 'sites_to_index' => esc_html__( 'site(s) remain to be mapped', 'elasticpress' ), - 'mapping_sites' => esc_html__( 'We are settings up your site(s) for indexing. Please be patient.', 'elasticpress' ), 'index_running' => $running, 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, 'synced_posts' => $synced_posts, From 7490de2b80b288b789a8f6b5bf98e03ffd91b8d6 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Thu, 17 Dec 2015 12:31:39 -0500 Subject: [PATCH 050/117] Much improved status improvements for GUI syncing --- assets/js/elasticpress-admin.js | 48 ++++++++++++++++--------------- classes/class-ep-index-gui.php | 22 +++++++------- classes/class-ep-index-worker.php | 14 +++++---- classes/class-ep-settings.php | 9 +++++- 4 files changed, 53 insertions(+), 40 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 12a33bacb0..f54f092283 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -22,10 +22,6 @@ jQuery( document ).ready( function ( $ ) { progress = parseFloat( ep.synced_posts ) / parseFloat( ep.total_posts ); status.html( ep.synced_posts + '/' + ep.total_posts + 'items' ); - } else { - - status.html( ep.mapping_sites ); - } bar.progressbar( @@ -43,6 +39,7 @@ jQuery( document ).ready( function ( $ ) { var epSitesRemaining = 0; var epTotalToIndex = 0; var epTotalIndexed = 0; + var epSitesCompleted = 0; // Resets index counts var resetIndex = function () { @@ -71,36 +68,39 @@ jQuery( document ).ready( function ( $ ) { data : data, complete : function ( response ) { - console.log( response.responseJSON.data ); + var sitesCompletedText = ''; - if ( 0 == response.responseJSON.data.ep_sync_complete ) { //incomplete + if ( 0 === response.responseJSON.data.is_network ) { - if ( 0 < response.responseJSON.data.ep_sites_remaining && epSitesRemaining !== response.responseJSON.data.ep_sites_remaining ) { + epTotalToIndex = response.responseJSON.data.ep_posts_total; - epSitesRemaining = response.responseJSON.data.ep_sites_remaining; - epTotalToIndex += response.responseJSON.data.ep_posts_total; + } else { - } else if ( 0 === response.responseJSON.data.is_network ) { + if ( epSitesRemaining !== response.responseJSON.data.ep_sites_remaining ) { - epTotalToIndex = response.responseJSON.data.ep_posts_total; + epSitesRemaining = response.responseJSON.data.ep_sites_remaining; + epTotalToIndex += response.responseJSON.data.ep_posts_total; + epSitesCompleted ++; } - epTotalIndexed += response.responseJSON.data.ep_posts_synced; + sitesCompletedText = epSitesCompleted + ep.sites; - var progress = parseFloat( epTotalIndexed ) / parseFloat( epTotalToIndex ); + } - bar.progressbar( - { - value : progress * 100 - } - ); + epTotalIndexed += response.responseJSON.data.ep_current_synced; - status.html( epTotalIndexed + '/' + epTotalToIndex + ' ' + ep.items_indexed ); + var progress = parseFloat( epTotalIndexed ) / parseFloat( epTotalToIndex ); - performIndex( false, button ); + bar.progressbar( + { + value : progress * 100 + } + ); - } else { //indexing complete + status.html( epTotalIndexed + '/' + epTotalToIndex + ' ' + ep.items_indexed + sitesCompletedText ); + + if ( 1 == response.responseJSON.data.ep_sync_complete ) { //indexing complete bar.progressbar( { @@ -117,10 +117,12 @@ jQuery( document ).ready( function ( $ ) { }, 1000 ); - } + } else { - } + performIndex( false, button ); + } + } } ); diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 3b1b4d7ea2..86eb0c0b78 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -134,18 +134,20 @@ protected function _run_index() { if ( false === get_transient( 'ep_index_offset' ) ) { $data = array( - 'ep_sync_complete' => true, - 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), - 'ep_posts_total' => absint( $total['total'] ), - ); + 'ep_sync_complete' => true, + 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), + 'ep_posts_total' => absint( $total['total'] ), + 'ep_current_synced' => $index_success['current_synced'], + ); } else { $data = array( - 'ep_sync_complete' => false, - 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), - 'ep_posts_total' => absint( $total['total'] ), - ); + 'ep_sync_complete' => false, + 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), + 'ep_posts_total' => absint( $total['total'] ), + 'ep_current_synced' => $index_success['current_synced'], + ); } return $data; @@ -209,7 +211,7 @@ public function action_wp_ajax_ep_launch_index() { $indexes[] = ep_get_index_name(); - if ( is_array( $result ) && isset( $result['ep_sync_complete'] )&& true === $result['ep_sync_complete'] ) { + if ( is_array( $result ) && isset( $result['ep_sync_complete'] ) && true === $result['ep_sync_complete'] ) { delete_transient( 'ep_index_synced' ); delete_transient( 'ep_post_count' ); @@ -220,7 +222,7 @@ public function action_wp_ajax_ep_launch_index() { } else { - if ( is_array( $result ) && isset( $result['ep_sync_complete'] ) && true === $result['ep_sync_complete'] ) { + if ( is_array( $result ) && isset( $result['ep_sync_complete'] ) && true === $result['ep_sync_complete'] ) { delete_transient( 'ep_index_synced' ); delete_transient( 'ep_post_count' ); diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index 8071e0cae0..240ca91aa6 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -87,7 +87,7 @@ public function index() { return false; } - return true; + return $result; } @@ -109,10 +109,11 @@ protected function _index_helper() { $offset_transient = get_transient( 'ep_index_offset' ); $sync_transient = get_transient( 'ep_index_synced' ); - $synced = false === $sync_transient ? 0 : absint( $sync_transient ); - $errors = array(); - $offset = false === $offset_transient ? 0 : absint( $offset_transient ); - $complete = false; + $synced = false === $sync_transient ? 0 : absint( $sync_transient ); + $errors = array(); + $offset = false === $offset_transient ? 0 : absint( $offset_transient ); + $complete = false; + $current_synced = 0; $args = apply_filters( 'ep_index_posts_args', array( 'posts_per_page' => $posts_per_page, @@ -138,6 +139,7 @@ protected function _index_helper() { } else { + $current_synced ++; $synced ++; } @@ -185,7 +187,7 @@ protected function _index_helper() { wp_reset_postdata(); - return array( 'synced' => $synced, 'errors' => $errors ); + return array( 'synced' => $synced, 'current_synced' => $current_synced, 'errors' => $errors ); } diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 837efa50fd..c5a15099e2 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -104,6 +104,12 @@ public function action_admin_enqueue_scripts() { } + $indexed = esc_html__( 'items indexed', 'elasticpress' ); + + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + $indexed = esc_html__( 'items indexed in ', 'elasticpress' ); + } + wp_localize_script( 'ep_admin', 'ep', @@ -112,7 +118,8 @@ public function action_admin_enqueue_scripts() { 'stats_nonce' => wp_create_nonce( 'ep_site_stats' ), 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), - 'items_indexed' => esc_html__( 'items indexed', 'elasticpress' ), + 'items_indexed' => $indexed, + 'sites' => esc_html__( ' site(s)', 'elasticpress' ), 'index_running' => $running, 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, 'synced_posts' => $synced_posts, From da9fa24473f5d5ff68f7108b145ca588b370a01a Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Thu, 17 Dec 2015 12:36:19 -0500 Subject: [PATCH 051/117] Make sure indexing can resume --- assets/js/elasticpress-admin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index f54f092283..44b7c183af 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -134,7 +134,7 @@ jQuery( document ).ready( function ( $ ) { /** * Start the poll if we need it */ - if ( 1 === ep.index_running ) { + if ( 1 == ep.index_running ) { performIndex( true, run_index_button ); } From cdefb8cdfa358d0273a2face588f9df6fe3e424f Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Thu, 17 Dec 2015 12:58:05 -0500 Subject: [PATCH 052/117] Better status when resuming sync On single sites the status will now be correct when resuming sync. Still a bit wonky in this case on multisite though. --- assets/js/elasticpress-admin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 44b7c183af..9ca9f28138 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -68,11 +68,12 @@ jQuery( document ).ready( function ( $ ) { data : data, complete : function ( response ) { - var sitesCompletedText = ''; + var sitesCompletedText = '' if ( 0 === response.responseJSON.data.is_network ) { epTotalToIndex = response.responseJSON.data.ep_posts_total; + epTotalIndexed = response.responseJSON.data.ep_posts_synced; } else { @@ -85,11 +86,10 @@ jQuery( document ).ready( function ( $ ) { } sitesCompletedText = epSitesCompleted + ep.sites; + epTotalIndexed += response.responseJSON.data.ep_current_synced; } - epTotalIndexed += response.responseJSON.data.ep_current_synced; - var progress = parseFloat( epTotalIndexed ) / parseFloat( epTotalToIndex ); bar.progressbar( From bfaf39a246c64a67ba4237b620a01c10b7bab0c9 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Thu, 17 Dec 2015 13:08:16 -0500 Subject: [PATCH 053/117] Execute Grunt --- assets/js/elasticpress-admin.min.js | 2 +- lang/elasticpress.pot | 84 ++++++++++++++--------------- package.json | 28 +++++----- 3 files changed, 55 insertions(+), 59 deletions(-) diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index 0e3965a7a2..e7bad76e4a 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,d){a(d).val(ep.running_index_text).removeClass("button-primary");var e=a("#progressbar"),f=a("#progressstats");if(e.show(),b){var g=0;parseInt(ep.total_posts)>0?(g=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),f.html(ep.synced_posts+"/"+ep.total_posts+"items")):f.html(ep.mapping_sites),e.progressbar({value:100*g})}c(e,d,f)},c=function(c,d,e){var f={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){if("undefined"!=typeof f.responseJSON.data.ep_mapping_complete)e.html(ep.mapping_sites+"
      "+f.responseJSON.data.ep_mapping_complete+" "+ep.sites_to_index),b(!1,d);else if(0==f.responseJSON.data.ep_sync_complete){var g=parseFloat(f.responseJSON.data.ep_posts_synced)/parseFloat(f.responseJSON.data.ep_posts_total);c.progressbar({value:100*g}),e.html(f.responseJSON.data.ep_posts_synced+"/"+f.responseJSON.data.ep_posts_total+" "+ep.items_indexed),b(!1,d)}else c.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary")},1e3)}})},d=a("#ep_run_index");1===ep.index_running&&b(!0,d),d.click(function(c){c.preventDefault();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var e=a("#ep_site_select");e.change(function(b){b.preventDefault(),console.log(e.val());var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:e.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.html(ep.synced_posts+"/"+ep.total_posts+"items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,complete:function(k){var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.html(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var j=a("#ep_site_select");j.change(function(b){b.preventDefault(),console.log(j.val());var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 39945d5530..965e0a6edf 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-12-02 13:07-0500\n" +"POT-Creation-Date: 2015-12-17 13:07-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -136,52 +136,52 @@ msgstr "" msgid "No running host available." msgstr "" -#: classes/class-ep-index-gui.php:96 classes/class-ep-index-gui.php:189 -#: classes/class-ep-settings.php:143 -msgid "Security error!" -msgstr "" - -#: classes/class-ep-index-gui.php:136 +#: classes/class-ep-index-gui.php:116 msgid "" "Mappings could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:149 +#: classes/class-ep-index-gui.php:129 msgid "" "Indexing could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:202 includes/settings/status.php:71 +#: classes/class-ep-index-gui.php:170 classes/class-ep-index-gui.php:300 +#: classes/class-ep-settings.php:147 +msgid "Security error!" +msgstr "" + +#: classes/class-ep-index-gui.php:313 includes/settings/status.php:72 msgid "Search Stats" msgstr "" -#: classes/class-ep-index-gui.php:205 includes/settings/status.php:75 +#: classes/class-ep-index-gui.php:316 includes/settings/status.php:76 msgid "Total Queries:" msgstr "" -#: classes/class-ep-index-gui.php:208 includes/settings/status.php:78 +#: classes/class-ep-index-gui.php:319 includes/settings/status.php:79 msgid "Query Time:" msgstr "" -#: classes/class-ep-index-gui.php:211 includes/settings/status.php:82 +#: classes/class-ep-index-gui.php:322 includes/settings/status.php:83 msgid "Total Fetches:" msgstr "" -#: classes/class-ep-index-gui.php:214 includes/settings/status.php:85 +#: classes/class-ep-index-gui.php:325 includes/settings/status.php:86 msgid "Fetch Time:" msgstr "" -#: classes/class-ep-index-gui.php:219 includes/settings/status.php:94 +#: classes/class-ep-index-gui.php:330 includes/settings/status.php:95 msgid "Index Stats" msgstr "" -#: classes/class-ep-index-gui.php:222 includes/settings/status.php:98 +#: classes/class-ep-index-gui.php:333 includes/settings/status.php:99 msgid "Index Total:" msgstr "" -#: classes/class-ep-index-gui.php:225 includes/settings/status.php:101 +#: classes/class-ep-index-gui.php:336 includes/settings/status.php:102 msgid "Index Time:" msgstr "" @@ -189,51 +189,47 @@ msgstr "" msgid "Index Status" msgstr "" -#: classes/class-ep-index-worker.php:390 +#: classes/class-ep-index-worker.php:362 msgid "The following posts failed to index:" msgstr "" -#: classes/class-ep-index-worker.php:401 +#: classes/class-ep-index-worker.php:373 msgid ": ElasticPress Index Errors" msgstr "" -#: classes/class-ep-settings.php:113 includes/settings/index.php:14 -msgid "Running Index..." -msgstr "" - -#: classes/class-ep-settings.php:114 includes/settings/index.php:14 -msgid "Run Index" +#: classes/class-ep-settings.php:107 +msgid "items indexed" msgstr "" -#: classes/class-ep-settings.php:115 -msgid "items indexed" +#: classes/class-ep-settings.php:110 +msgid "items indexed in " msgstr "" -#: classes/class-ep-settings.php:116 -msgid "site(s) remain to be indexed" +#: classes/class-ep-settings.php:119 includes/settings/index.php:14 +msgid "Running Index..." msgstr "" -#: classes/class-ep-settings.php:117 -msgid "We are settings up your site(s) for indexing. Please be patient." +#: classes/class-ep-settings.php:120 includes/settings/index.php:14 +msgid "Run Index" msgstr "" -#: classes/class-ep-settings.php:118 -msgid "We're Still counting total items for the index. Please be patient" +#: classes/class-ep-settings.php:122 +msgid " site(s)" msgstr "" -#: classes/class-ep-settings.php:176 +#: classes/class-ep-settings.php:180 msgid "ElasticSearch Host:" msgstr "" -#: classes/class-ep-settings.php:181 +#: classes/class-ep-settings.php:185 msgid "ElasticPress API Key:" msgstr "" -#: classes/class-ep-settings.php:190 +#: classes/class-ep-settings.php:194 msgid "Use ElasticSearch:" msgstr "" -#: classes/class-ep-settings.php:428 +#: classes/class-ep-settings.php:432 msgid "ElasticSearch Integration Options" msgstr "" @@ -286,17 +282,17 @@ msgstr "" msgid "ElasticPress can override WP search." msgstr "" -#: includes/settings/status.php:62 +#: includes/settings/status.php:63 msgid "" "ElasticPress is not activated and cannot override WP search. You can " "activate it on the form to the left." msgstr "" -#: includes/settings/status.php:67 +#: includes/settings/status.php:68 msgid "System Stats" msgstr "" -#: includes/settings/status.php:112 +#: includes/settings/status.php:114 msgid "Site Stats" msgstr "" @@ -308,23 +304,23 @@ msgstr "" msgid "Select" msgstr "" -#: includes/settings/status.php:140 +#: includes/settings/status.php:153 msgid "Cluster Stats" msgstr "" -#: includes/settings/status.php:150 +#: includes/settings/status.php:163 msgid "Disk Usage:" msgstr "" -#: includes/settings/status.php:153 +#: includes/settings/status.php:167 msgid "Disk Space Available:" msgstr "" -#: includes/settings/status.php:156 +#: includes/settings/status.php:170 msgid "Total Disk Space:" msgstr "" -#: includes/settings/status.php:169 +#: includes/settings/status.php:183 msgid "ERROR:" msgstr "" diff --git a/package.json b/package.json index a78b572c92..4eb1ada3e4 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,22 @@ { - "name" : "ElasticPress", - "private" : true, - "version" : "1.0.0", - "description" : "Grunt base for the ElasticPress Plugin.", - "dependencies" : { }, + "name": "ElasticPress", + "private": true, + "version": "1.0.0", + "description": "Grunt base for the ElasticPress Plugin.", + "dependencies": {}, "devDependencies": { - "grunt" : "*", + "grunt": "*", "grunt-contrib-uglify": "*", - "grunt-contrib-watch" : "*", - "grunt-sass" : "*", + "grunt-contrib-watch": "*", + "grunt-sass": "*", "grunt-contrib-cssmin": "*", - "load-grunt-tasks" : "*", - "grunt-autoprefixer" : "*", - "grunt-pot" : "*" + "load-grunt-tasks": "*", + "grunt-autoprefixer": "*", + "grunt-pot": "*" }, - "author" : "10up", - "repository" : { + "author": "10up", + "repository": { "type": "git", - "url" : "https://github.com/10up/ElasticPress" + "url": "https://github.com/10up/ElasticPress" } } \ No newline at end of file From 4bde19c3cc36912c6e08647354c19546a23f24e8 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Thu, 17 Dec 2015 14:19:50 -0500 Subject: [PATCH 054/117] Minor cleanup and some test tweaks --- classes/class-ep-config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index ed6423c7bc..255291297c 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -218,7 +218,7 @@ public function set_api_key() { */ public function set_host() { - $ep_host = get_site_option( 'ep_host' ); + $ep_host = get_site_option( 'ep_host' ); if ( $ep_host && ! defined( 'EP_HOST' ) ) { $this->option_host = true; From 5d40b45c06d0224013ba1a732df28dc22e4b085c Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Thu, 7 Jan 2016 13:12:30 -0500 Subject: [PATCH 055/117] Fix unit tests for GUI indexing --- tests/test-multisite.php | 123 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/tests/test-multisite.php b/tests/test-multisite.php index f55e3fe71a..10ab59ec90 100644 --- a/tests/test-multisite.php +++ b/tests/test-multisite.php @@ -1833,5 +1833,128 @@ public function testQueryWithIsSearch() { $check = ep_elasticpress_enabled( $query ); $this->assertTrue( $check ); } + + /** + * Test index status + * + * Tests index status when site is and is not indexed. + * + * @since 0.1.0 + * + * @group BBPE-251 + * + * @return void + */ + function testGetIndexStatus() { + + $blog = get_current_blog_id(); + + $status_indexed = ep_get_index_status( $blog ); + + ep_delete_index(); + + $status_unindexed = ep_get_index_status( $blog ); + + $this->setUp(); + + $this->assertTrue( $status_indexed['status'] ); + $this->assertFalse( $status_unindexed['status'] ); + + } + + /** + * Search status + * + * Test search status. + * + * @since 0.1.0 + * + * @group BBPE-251 + * + * @return void + */ + function testGetSearchStatus() { + + $blog = get_current_blog_id(); + + $status_indexed = ep_get_search_status( $blog ); + + ep_delete_index(); + + $status_unindexed = ep_get_search_status( $blog ); + + $this->setUp(); + + $this->assertInstanceOf( 'stdClass', $status_indexed ); + $this->assertFalse( $status_unindexed ); + + } + + /** + * Cluster status + * + * Test cluster status. + * + * @since 0.1.0 + * + * @group BBPE-251 + * + * @return void + */ + function testGetClusterStatus() { + + $status_indexed = ep_get_cluster_status(); + + ep_delete_index(); + + $status_unindexed = ep_get_cluster_status(); + + + $this->setUp(); + + if ( is_array( $status_indexed ) ) { + + $this->assertTrue( $status_indexed['status'] ); + + } else { + + $this->assertTrue( isset( $status_indexed->cluster_name ) ); + + } + + if ( is_array( $status_unindexed ) ) { + + $this->assertTrue( $status_unindexed['status'] ); + + } else { + + $this->assertTrue( isset( $status_unindexed->cluster_name ) ); + + } + } + + /** + * Test put mapping function + * + * Tests the index put mapping function. + * + * @since 0.1.0 + * + * @return void + */ + function testPutMapping() { + + $mapping_indexed = ep_process_site_mappings(); + + ep_delete_index(); + + $mapping_unindexed = ep_process_site_mappings(); + + $this->setUp(); + + $this->assertTrue( $mapping_indexed ); + $this->assertTrue( $mapping_unindexed ); + + } } From 63fa532bdc0c25646a325c3aa8426b88a4a42d3a Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Thu, 7 Jan 2016 13:27:03 -0500 Subject: [PATCH 056/117] Fix error on settings page --- classes/class-ep-settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index c5a15099e2..9e478b01fd 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -392,7 +392,7 @@ public function setting_callback_host() { $read_only = ''; $host = get_site_option( 'ep_host' ); - if ( false === ep_host_by_option() ) { + if ( false === ep_host_by_option() && defined( 'EP_HOST' ) ) { $read_only = 'readonly'; $host = EP_HOST; } From 706933ab4a3e0bd01bc68b978dacaf970f99f9b6 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:28:11 -0500 Subject: [PATCH 057/117] Use .text instead of .html to avoid any potential XSS issues --- assets/js/elasticpress-admin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 9ca9f28138..6c0b928933 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -20,7 +20,7 @@ jQuery( document ).ready( function ( $ ) { if ( parseInt( ep.total_posts ) > 0 ) { progress = parseFloat( ep.synced_posts ) / parseFloat( ep.total_posts ); - status.html( ep.synced_posts + '/' + ep.total_posts + 'items' ); + status.text( ep.synced_posts + '/' + ep.total_posts + 'items' ); } @@ -98,7 +98,7 @@ jQuery( document ).ready( function ( $ ) { } ); - status.html( epTotalIndexed + '/' + epTotalToIndex + ' ' + ep.items_indexed + sitesCompletedText ); + status.text( epTotalIndexed + '/' + epTotalToIndex + ' ' + ep.items_indexed + sitesCompletedText ); if ( 1 == response.responseJSON.data.ep_sync_complete ) { //indexing complete From f85b67bbe66d22bc7ca5ed5f0a832879b03a31fb Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:28:26 -0500 Subject: [PATCH 058/117] Remove extra debugging statement. --- assets/js/elasticpress-admin.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 6c0b928933..28f2508829 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -167,8 +167,6 @@ jQuery( document ).ready( function ( $ ) { event.preventDefault(); - console.log( selector.val() ); - var data = { action : 'ep_get_site_stats', nonce : ep.stats_nonce, From cacbeb9a43a7f5ad13f2abc47d13da4d0a2ff68b Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:42:38 -0500 Subject: [PATCH 059/117] fix references to Jovo --- classes/class-ep-index-gui.php | 6 +++--- classes/class-ep-index-worker.php | 2 +- includes/settings/status.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 86eb0c0b78..d17d96f619 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -1,8 +1,8 @@ */ From 0d9dac2d3d604339a1594b9261893eb271b3804c Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:43:32 -0500 Subject: [PATCH 060/117] Fix since information Use appropriate @since tag as we now know when this should be merged in --- classes/class-ep-index-gui.php | 12 ++++++------ classes/class-ep-index-worker.php | 18 +++++++++--------- includes/settings/status.php | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index d17d96f619..9f51eea16c 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -4,7 +4,7 @@ * * @package ElasticPress * - * @since 0.1.0 + * @since 1.9 * * @author Chris Wiegman */ @@ -21,7 +21,7 @@ class EP_Index_GUI { /** * Path to the class file * - * @since 0.1.0 + * @since 1.9 * * @var string */ @@ -33,7 +33,7 @@ class EP_Index_GUI { * Loads various hook functions required to build the * Easy EP interface. * - * @since 0.1.0 + * @since 1.9 * * @return EP_Index_GUI */ @@ -58,7 +58,7 @@ public function __construct() { * * Adds a meta box for allowing remote indexing. * - * @since 0.4.0 + * @since 1.9 * * @param EP_Settings $ep_settings Instance of EP_Settings. * @@ -159,7 +159,7 @@ protected function _run_index() { * * Processes the action when the manual indexing button is clicked. * - * @since 0.1.0 + * @since 1.9 * * @return void */ @@ -289,7 +289,7 @@ public function action_wp_ajax_ep_launch_index() { * * Returns the HTML for stats for an individual site. * - * @since 1.8 + * @since 1.9 * * @return void */ diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index 683334c246..f441ba82f0 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -4,7 +4,7 @@ * * @package ElasticPress * - * @since 0.1.0 + * @since 1.9 * * @author Chris Wiegman */ @@ -19,7 +19,7 @@ class EP_Index_Worker { /** * Holds the posts that will be bulk synced. * - * @since 0.1.0 + * @since 1.9 * * @var array */ @@ -30,7 +30,7 @@ class EP_Index_Worker { * * Initiates the index worker process. * - * @since 0.1.0 + * @since 1.9 * * @return EP_Index_Worker */ @@ -45,7 +45,7 @@ public function __construct() { * * Helper method for creating the network alias * - * @since 0.1.0 + * @since 1.9 * * @return array|bool Array of indexes or false on error */ @@ -73,7 +73,7 @@ protected function _create_network_alias() { * * Index all posts for a site or network wide. * - * @since 0.1.0 + * @since 1.9 * * @return bool True on success or false */ @@ -96,7 +96,7 @@ public function index() { * * Handles the sync operation for individual posts. * - * @since 0.1.0 + * @since 1.9 * * @return array Array of posts successfully synced as well as errors */ @@ -196,7 +196,7 @@ protected function _index_helper() { * * Adds individual posts to a queue for later processing. * - * @since 0.1.0 + * @since 1.9 * * @param int $post_id The post ID to add. * @param int $bulk_trigger The maximum number of posts to hold in the queue before triggering a bulk-update operation. @@ -237,7 +237,7 @@ protected function queue_post( $post_id, $bulk_trigger, $offset ) { * * Sends multiple posts to the ES server at once. * - * @since 0.1.0 + * @since 1.9 * * @param int $offset The current offset to keep track of. * @@ -349,7 +349,7 @@ protected function bulk_index( $offset ) { * * Emails bulk errors regarding any posts that failed to index. * - * @since 0.1.0 + * @since 1.9 * * @return void */ diff --git a/includes/settings/status.php b/includes/settings/status.php index cd51354316..80b78c8dd8 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -2,7 +2,7 @@ /** * Template for displaying Elasticsearch statistics * - * @since 0.1.0 + * @since 1.9 * * @package ElasticPress * From c12c50999e13a3cc5f2d7c7a0ba48ebefe175257 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:43:48 -0500 Subject: [PATCH 061/117] Add missing doc block --- classes/class-ep-index-gui.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 9f51eea16c..40dba1e7a6 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -80,6 +80,15 @@ public function action_ep_do_settings_meta( $ep_settings ) { } + /** + * Executes the index + * + * When the indexer is called VIA Ajax this function starts the index or resumes from the previous position. + * + * @since 1.9 + * + * @return array|WP_Error + */ protected function _run_index() { $post_count = array( 'total' => 0 ); From 5c05d66c31cff88beafd382d354abf93e467bb66 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:44:00 -0500 Subject: [PATCH 062/117] Minor formatting fixes --- classes/class-ep-index-gui.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 40dba1e7a6..c476e3be02 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -147,7 +147,7 @@ protected function _run_index() { 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), 'ep_posts_total' => absint( $total['total'] ), 'ep_current_synced' => $index_success['current_synced'], - ); + ); } else { @@ -156,7 +156,7 @@ protected function _run_index() { 'ep_posts_synced' => ( false === get_transient( 'ep_index_synced' ) ? 0 : absint( get_transient( 'ep_index_synced' ) ) ), 'ep_posts_total' => absint( $total['total'] ), 'ep_current_synced' => $index_success['current_synced'], - ); + ); } return $data; From d30ae0e691bcb66457d10dd693916a6f25965a3c Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 13:45:05 -0500 Subject: [PATCH 063/117] Better error email handling Allows the override of most information for the bulk email handler via filters. --- classes/class-ep-index-worker.php | 40 +++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index f441ba82f0..38c07edc73 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -181,8 +181,17 @@ protected function _index_helper() { if ( true === $complete ) { delete_transient( 'ep_index_offset' ); - $this->send_bulk_errors(); + /** + * Allow disabling of bulk error email. + * + * @since 1.9 + * + * @param bool $to_send true to send bulk errors or false [Default: true] + */ + if ( true === apply_filters( 'ep_disable_index_bulk_errors', true ) ) { + $this->send_bulk_errors(); + } } wp_reset_postdata(); @@ -370,7 +379,34 @@ protected function send_bulk_errors() { } } - wp_mail( get_option( 'admin_email' ), wp_specialchars_decode( get_option( 'blogname' ) ) . esc_html__( ': ElasticPress Index Errors', 'elasticpress' ), $email_text ); + /** + * Filter the email text used to send the bulk error email + * + * @since 1.9 + * + * @param string $email_text The message body of the bulk error email. + */ + $email_text = apply_filters( 'ep_bulk_errors_email_text', $email_text ); + + /** + * Filter the email subject used to send the bulk error email + * + * @since 1.9 + * + * @param string $email_subject The subject of the bulk error email. + */ + $email_subject = apply_filters( 'ep_bulk_errors_email_subject', wp_specialchars_decode( get_option( 'blogname' ) ) . esc_html__( ': ElasticPress Index Errors', 'elasticpress' ) ); + + /** + * Filter the email recipient who should receive the bulk indexing errors + * + * @since 1.9 + * + * @param string $email_to The email address to which the bulk errors should be sent. + */ + $email_to = apply_filters( 'wp_bulk_errors_email_to', get_option( 'admin_email' ) ); + + wp_mail( $email_to, $email_subject, $email_text ); // Clear failed posts after sending emails. delete_transient( 'ep_index_failed_posts' ); From 2ca1a6874436105b36ec772fd8bcf7d06c914687 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 14:31:01 -0500 Subject: [PATCH 064/117] Re-apply GUI changes Due to the complexity of the merge process and the fact that the changes needed to these files were additions they have been added here for easier use --- classes/class-ep-api.php | 312 ++++++++++++++++++++++++++++++++++++- tests/test-single-site.php | 110 +++++++++++++ 2 files changed, 421 insertions(+), 1 deletion(-) diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index 3e3a3395cf..2c7ccfe9ca 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -239,7 +239,7 @@ public function delete_post( $post_id, $blocking = true ) { $index = trailingslashit( ep_get_index_name() ); - $path = $index . 'post/' . $post_id; + $path = $index . '/post/' . $post_id; $request_args = array( 'method' => 'DELETE', 'timeout' => 15, 'blocking' => $blocking ); @@ -1720,6 +1720,292 @@ public function remote_request( $path, $args = array() ) { } + /** + * Parse response from Elasticsearch + * + * Determines if there is an issue or if the response is valid. + * + * @since 1.9 + * + * @param object $response JSON decoded response from ElasticSearch. + * + * @return array Contains the status message or the returned statistics. + */ + public function parse_api_response( $response ) { + + if ( null === $response ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'Invalid response from ElasticPress server. Please contact your administrator.' ), + ); + + } elseif ( + isset( $response->error ) && + ( + ( is_string( $response->error ) && stristr( $response->error, 'IndexMissingException' ) ) || + ( isset( $response->error->reason ) && stristr( $response->error->reason, 'no such index' ) ) + ) + ) { + + if ( is_multisite() ) { + + $error = __( 'Site not indexed.

      Please run: wp elasticpress index --setup --network-wide using WP-CLI. Or use the index button on the left of this screen.

      ', 'elasticpress' ); + + } else { + + $error = __( 'Site not indexed.

      Please run: wp elasticpress index --setup using WP-CLI. Or use the index button on the left of this screen.

      ', 'elasticpress' ); + + } + + return array( + 'status' => false, + 'msg' => $error, + ); + + } + + return array( 'status' => true, 'data' => $response->_all->primaries->indexing ); + + } + + /** + * Get ElasticSearch plugins + * + * Gets a list of available ElasticSearch plugins. + * + * @since 1.9 + * + * @return array Array of plugins and their version or error message + */ + public function get_plugins() { + + $plugins = get_transient( 'ep_installed_plugins' ); + + if ( is_array( $plugins ) ) { + return $plugins; + } + + $plugins = array(); + + if ( is_wp_error( ep_get_host() ) ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + ); + + } + + $path = '/_nodes?plugin=true'; + + $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); + + if ( ! is_wp_error( $request ) ) { + + $response = json_decode( wp_remote_retrieve_body( $request ), true ); + + if ( isset( $response['nodes'] ) ) { + + foreach ( $response['nodes'] as $node ) { + + if ( isset( $node['plugins'] ) && is_array( $node['plugins'] ) ) { + + foreach ( $node['plugins'] as $plugin ) { + + $plugins[ $plugin['name'] ] = $plugin['version']; + + } + + break; + + } + } + } + + set_transient( 'ep_installed_plugins', $plugins, apply_filters( 'ep_installed_plugins_exp', 3600 ) ); + + return $plugins; + + } + + return array( + 'status' => false, + 'msg' => $request->get_error_message(), + ); + + } + + /** + * Get cluster status + * + * Retrieves cluster stats from ElasticSearch. + * + * @since 1.9 + * + * @return array Contains the status message or the returned statistics. + */ + public function get_cluster_status() { + + if ( is_wp_error( ep_get_host() ) ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + ); + + } else { + + $request = ep_remote_request( '_cluster/stats', array( 'method' => 'GET' ) ); + + if ( ! is_wp_error( $request ) ) { + + $response = json_decode( wp_remote_retrieve_body( $request ) ); + + return $response; + + } + + return array( + 'status' => false, + 'msg' => $request->get_error_message(), + ); + + } + } + + /** + * Get index status + * + * Retrieves index stats from ElasticSearch. + * + * @since 1.9 + * + * @param int $blog_id Id of blog to get stats. + * + * @return array Contains the status message or the returned statistics. + */ + public function get_index_status( $blog_id = null ) { + + if ( is_wp_error( ep_get_host( true ) ) ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + ); + + } else { + + if ( is_multisite() && null === $blog_id ) { + + $path = ep_get_network_alias() . '/_stats/indexing/'; + + } else { + + $path = ep_get_index_name( $blog_id ) . '/_stats/indexing/'; + + } + + $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); + + } + + if ( ! is_wp_error( $request ) ) { + + $response = json_decode( wp_remote_retrieve_body( $request ) ); + + return ep_parse_api_response( $response ); + + } + + return array( + 'status' => false, + 'msg' => $request->get_error_message(), + ); + + } + + /** + * Retrieves search stats from ElasticSearch. + * + * Retrieves various search statistics from the ES server. + * + * @since 1.9 + * + * @param int $blog_id Id of blog to get stats. + * + * @return array Contains the status message or the returned statistics. + */ + public function get_search_status( $blog_id = null ) { + + if ( is_wp_error( ep_get_host() ) ) { + + return array( + 'status' => false, + 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + ); + + } else { + + if ( is_multisite() && null === $blog_id ) { + + $path = ep_get_network_alias() . '/_stats/search/'; + + } else { + + $path = ep_get_index_name( $blog_id ) . '/_stats/search/'; + + } + + $request = ep_remote_request( $path, array( 'method' => 'GET' ) ); + + } + + if ( ! is_wp_error( $request ) ) { + + $stats = json_decode( wp_remote_retrieve_body( $request ) ); + + if ( isset( $stats->_all ) ) { + return $stats->_all->primaries->search; + } + + return false; + + } + + return array( + 'status' => false, + 'msg' => $request->get_error_message(), + ); + + } + + /** + * Add the document mapping + * + * Creates the document mapping for the index. + * + * @since 1.9 + * + * @return bool true on success or false + */ + public function process_site_mappings() { + + ep_check_host(); + + // Deletes index first. + ep_delete_index(); + + $result = ep_put_mapping(); + + if ( $result ) { + return true; + } + + return false; + + } + } EP_API::factory(); @@ -1815,3 +2101,27 @@ function ep_remote_request( $path, $args ) { function ep_get_query_log() { return EP_API::factory()->get_query_log(); } + +function ep_parse_api_response( $response ) { + return EP_API::factory()->parse_api_response( $response ); +} + +function ep_get_plugins() { + return EP_API::factory()->get_plugins(); +} + +function ep_get_search_status( $blog_id = null ) { + return EP_API::factory()->get_search_status( $blog_id ); +} + +function ep_get_index_status( $blog_id = null ) { + return EP_API::factory()->get_index_status( $blog_id ); +} + +function ep_get_cluster_status() { + return EP_API::factory()->get_cluster_status(); +} + +function ep_process_site_mappings() { + return EP_API::factory()->process_site_mappings(); +} diff --git a/tests/test-single-site.php b/tests/test-single-site.php index 64693f15fb..df80e4dc72 100644 --- a/tests/test-single-site.php +++ b/tests/test-single-site.php @@ -2730,4 +2730,114 @@ public function testMetaValueTypeQueryDatetime() { $this->assertEquals( 1, $query->post_count ); } + + /** + * Test check host + * + * Tests the check host function + * + * @since 1.9 + * + * @return void + */ + function testCheckHost() { + + $check_host = ep_check_host(); + + $this->assertTrue( $check_host ); + + } + + /** + * Test byte size + * + * Tests the human readable byte conversion function.@deprecated + * + * @since 1.9 + * + * @return void + */ + function testByteSize() { + + $one_kb = EP_Settings::ep_byte_size( 1056, 0 ); + + $one_mb = EP_Settings::ep_byte_size( 1056000, 0 ); + + $this->assertEquals( '1 KB', $one_kb ); + $this->assertEquals( '1 MB', $one_mb ); + + } + + /** + * Test indexing function + * + * Tests indexing. + * + * @since 1.9 + * + * @return void + */ + function testIndex() { + + if ( ! class_exists( 'EP_Index_Worker' ) ) { + require( $this->plugin_path . '/classes/class-ep-index-worker.php' ); + } + + $index_worker = new EP_Index_Worker(); + + $index_result = $index_worker->index(); + + $this->assertTrue( is_array( $index_result ) ); + + } + + /** + * Test sanitize host + * + * Tests the sanitization function for saving a host via the dashboard. + * + * @since 1.9 + * + * @return void + */ + function testSanitizeHost() { + + if ( ! class_exists( 'EP_Settings' ) ) { + require( $this->plugin_path . '/classes/class-ep-settings.php' ); + } + + $settings = new EP_Settings(); + + $host = $settings->sanitize_ep_host( 'http://127.0.0.1:9200' ); + + $this->assertEquals( 'http://127.0.0.1:9200', $host ); + + } + + /** + * Test sanitize activation + * + * Tests the sanitization function for changing activation state via the dashboard. + * + * @since 1.9 + * + * @return void + */ + function testSanitizeActivate() { + + if ( ! class_exists( 'EP_Settings' ) ) { + require( $this->plugin_path . '/classes/class-ep-settings.php' ); + } + + $settings = new EP_Settings(); + + $active = $settings->sanitize_ep_activate( '1' ); + $inactive = $settings->sanitize_ep_activate( '0' ); + $no_field = $settings->sanitize_ep_activate( null ); + + $this->assertTrue( $active ); + $this->assertFalse( $inactive ); + $this->assertFalse( $no_field ); + + } } From db4fa96f811ec0bcab6eb444ae466913bf3a1899 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Tue, 26 Jan 2016 14:35:31 -0500 Subject: [PATCH 065/117] Grunt execution --- assets/js/elasticpress-admin.min.js | 2 +- lang/elasticpress.pot | 38 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index e7bad76e4a..01da35dad8 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.html(ep.synced_posts+"/"+ep.total_posts+"items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,complete:function(k){var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.html(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var j=a("#ep_site_select");j.change(function(b){b.preventDefault(),console.log(j.val());var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.text(ep.synced_posts+"/"+ep.total_posts+"items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,complete:function(k){var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.text(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var j=a("#ep_site_select");j.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 965e0a6edf..9dc7be760a 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-12-17 13:07-0500\n" +"POT-Creation-Date: 2016-01-26 14:35-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -109,26 +109,26 @@ msgstr "" msgid "Unable to reach Elasticsearch Server! Check that service is running." msgstr "" -#: classes/class-ep-api.php:1728 +#: classes/class-ep-api.php:1740 msgid "" "Invalid response from ElasticPress server. Please contact your administrator." msgstr "" -#: classes/class-ep-api.php:1741 +#: classes/class-ep-api.php:1753 msgid "" "Site not indexed.

      Please run: wp elasticpress index --setup --" "network-wide using WP-CLI. Or use the index button on the left of " "this screen.

      " msgstr "" -#: classes/class-ep-api.php:1745 +#: classes/class-ep-api.php:1757 msgid "" "Site not indexed.

      Please run: wp elasticpress index --setup " "using WP-CLI. Or use the index button on the left of this screen.

      " msgstr "" -#: classes/class-ep-api.php:1783 classes/class-ep-api.php:1842 -#: classes/class-ep-api.php:1882 classes/class-ep-api.php:1933 +#: classes/class-ep-api.php:1795 classes/class-ep-api.php:1854 +#: classes/class-ep-api.php:1894 classes/class-ep-api.php:1945 msgid "ElasticSearch Host is not available." msgstr "" @@ -136,52 +136,52 @@ msgstr "" msgid "No running host available." msgstr "" -#: classes/class-ep-index-gui.php:116 +#: classes/class-ep-index-gui.php:125 msgid "" "Mappings could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:129 +#: classes/class-ep-index-gui.php:138 msgid "" "Indexing could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:170 classes/class-ep-index-gui.php:300 +#: classes/class-ep-index-gui.php:179 classes/class-ep-index-gui.php:309 #: classes/class-ep-settings.php:147 msgid "Security error!" msgstr "" -#: classes/class-ep-index-gui.php:313 includes/settings/status.php:72 +#: classes/class-ep-index-gui.php:322 includes/settings/status.php:72 msgid "Search Stats" msgstr "" -#: classes/class-ep-index-gui.php:316 includes/settings/status.php:76 +#: classes/class-ep-index-gui.php:325 includes/settings/status.php:76 msgid "Total Queries:" msgstr "" -#: classes/class-ep-index-gui.php:319 includes/settings/status.php:79 +#: classes/class-ep-index-gui.php:328 includes/settings/status.php:79 msgid "Query Time:" msgstr "" -#: classes/class-ep-index-gui.php:322 includes/settings/status.php:83 +#: classes/class-ep-index-gui.php:331 includes/settings/status.php:83 msgid "Total Fetches:" msgstr "" -#: classes/class-ep-index-gui.php:325 includes/settings/status.php:86 +#: classes/class-ep-index-gui.php:334 includes/settings/status.php:86 msgid "Fetch Time:" msgstr "" -#: classes/class-ep-index-gui.php:330 includes/settings/status.php:95 +#: classes/class-ep-index-gui.php:339 includes/settings/status.php:95 msgid "Index Stats" msgstr "" -#: classes/class-ep-index-gui.php:333 includes/settings/status.php:99 +#: classes/class-ep-index-gui.php:342 includes/settings/status.php:99 msgid "Index Total:" msgstr "" -#: classes/class-ep-index-gui.php:336 includes/settings/status.php:102 +#: classes/class-ep-index-gui.php:345 includes/settings/status.php:102 msgid "Index Time:" msgstr "" @@ -189,11 +189,11 @@ msgstr "" msgid "Index Status" msgstr "" -#: classes/class-ep-index-worker.php:362 +#: classes/class-ep-index-worker.php:371 msgid "The following posts failed to index:" msgstr "" -#: classes/class-ep-index-worker.php:373 +#: classes/class-ep-index-worker.php:398 msgid ": ElasticPress Index Errors" msgstr "" From 91b68619de57b2e53dc3eb0dee0867e1dee3185a Mon Sep 17 00:00:00 2001 From: "pete@petenelson.com" Date: Tue, 26 Jan 2016 19:11:07 -0600 Subject: [PATCH 066/117] moved the request_url update to after the is_wp_error() check in remote_request() --- classes/class-ep-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index 3d7ea7fe19..8386c92363 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -1688,7 +1688,6 @@ public function remote_request( $path, $args = array() ) { if ( false === $request || is_wp_error( $request ) || ( isset( $request['response']['code'] ) && 200 !== $request['response']['code'] ) ) { $host = ep_get_host( true, $use_backups ); - $request_url = esc_url( trailingslashit( $host ) . $path ); if ( is_wp_error( $host ) ) { $query['failed_hosts'][] = $host; @@ -1698,6 +1697,7 @@ public function remote_request( $path, $args = array() ) { return $host; } + $request_url = esc_url( trailingslashit( $host ) . $path ); $request = wp_remote_request( $request_url, $args ); } From 7f6fdf1a4fa4eefd0dfe57744489bf3271f1d528 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 09:28:40 -0500 Subject: [PATCH 067/117] Update copy for message when ElasticPress hasn't been enabled. --- includes/settings/status.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/settings/status.php b/includes/settings/status.php index 80b78c8dd8..7cbd6af417 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -60,7 +60,7 @@ + style="color:red;">
      From 41e65efb8f104d242eb1fafcba79df27c5bc4382 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 09:32:57 -0500 Subject: [PATCH 068/117] Don't duplicate failed host message. --- includes/settings/status.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/includes/settings/status.php b/includes/settings/status.php index 7cbd6af417..846d623281 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -53,9 +53,7 @@ -
      -
      + style="color:green;">

      @@ -173,7 +171,7 @@ array(), From 407a15903af8d82456e32f78b733d870a3b71d4d Mon Sep 17 00:00:00 2001 From: John P Bloch Date: Wed, 27 Jan 2016 09:54:44 -0600 Subject: [PATCH 069/117] Use lower-case for composer name --- .gitignore | 1 + composer.json | 2 +- composer.lock | 305 +++++++++++++++++++++++++++++++------------------- 3 files changed, 193 insertions(+), 115 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..57872d0f1e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vendor/ diff --git a/composer.json b/composer.json index e276215b0f..03136014e1 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "10up/ElasticPress", + "name": "10up/elasticpress", "description": "Integrate Elasticsearch with WordPress.", "type": "wordpress-plugin", "keywords": ["wordpress", "plugin", "elasticsearch", "elasticpress", "search"], diff --git a/composer.lock b/composer.lock index ab9b320469..ebfbad4bab 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,11 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "332f73e3674c21dc09f838e8b7fff5b8", + "hash": "2a66b09e73d9603356dbd0f0688b2ffc", + "content-hash": "d42375176ab2c0c38041ad616d74e801", "packages": [], "packages-dev": [ { @@ -13,12 +14,12 @@ "source": { "type": "git", "url": "https://github.com/codeclimate/php-test-reporter.git", - "reference": "2dd8395f81874333d15de3a598f722997ba42fb5" + "reference": "02790d733f9eb43d0a5981962c41846092fb387f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/2dd8395f81874333d15de3a598f722997ba42fb5", - "reference": "2dd8395f81874333d15de3a598f722997ba42fb5", + "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/02790d733f9eb43d0a5981962c41846092fb387f", + "reference": "02790d733f9eb43d0a5981962c41846092fb387f", "shasum": "" }, "require": { @@ -28,6 +29,7 @@ "symfony/console": ">=2.0" }, "require-dev": { + "ext-xdebug": "*", "phpunit/phpunit": "3.7.*@stable" }, "bin": [ @@ -36,7 +38,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.1.x-dev" + "dev-master": "0.2.x-dev" } }, "autoload": { @@ -62,20 +64,20 @@ "codeclimate", "coverage" ], - "time": "2014-12-29 16:17:04" + "time": "2015-12-17 00:52:54" }, { "name": "guzzle/guzzle", - "version": "v3.9.2", + "version": "v3.9.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle3.git", - "reference": "54991459675c1a2924122afbb0e5609ade581155" + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/54991459675c1a2924122afbb0e5609ade581155", - "reference": "54991459675c1a2924122afbb0e5609ade581155", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", "shasum": "" }, "require": { @@ -116,6 +118,9 @@ "zendframework/zend-cache": "2.*,<2.3", "zendframework/zend-log": "2.*,<2.3" }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, "type": "library", "extra": { "branch-alias": { @@ -143,7 +148,7 @@ "homepage": "https://github.com/guzzle/guzzle/contributors" } ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", "homepage": "http://guzzlephp.org/", "keywords": [ "client", @@ -154,7 +159,7 @@ "rest", "web service" ], - "time": "2014-08-11 04:32:36" + "time": "2015-03-18 18:23:50" }, { "name": "psr/log", @@ -264,74 +269,76 @@ }, { "name": "symfony/config", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Config", + "version": "v3.0.1", "source": { "type": "git", - "url": "https://github.com/symfony/Config.git", - "reference": "84c0c150c1520995f09ea9e47e817068b353cb0f" + "url": "https://github.com/symfony/config.git", + "reference": "58680a6516a457a6c65044fe33586c4a81fdff01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/84c0c150c1520995f09ea9e47e817068b353cb0f", - "reference": "84c0c150c1520995f09ea9e47e817068b353cb0f", + "url": "https://api.github.com/repos/symfony/config/zipball/58680a6516a457a6c65044fe33586c4a81fdff01", + "reference": "58680a6516a457a6c65044fe33586c4a81fdff01", "shasum": "" }, "require": { - "php": ">=5.3.3", - "symfony/filesystem": "~2.3" + "php": ">=5.5.9", + "symfony/filesystem": "~2.8|~3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Config\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Config Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" + "homepage": "https://symfony.com", + "time": "2015-12-26 13:39:53" }, { "name": "symfony/console", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Console", + "version": "v3.0.1", "source": { "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "ef825fd9f809d275926547c9e57cbf14968793e8" + "url": "https://github.com/symfony/console.git", + "reference": "ebcdc507829df915f4ca23067bd59ee4ef61f6c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ef825fd9f809d275926547c9e57cbf14968793e8", - "reference": "ef825fd9f809d275926547c9e57cbf14968793e8", + "url": "https://api.github.com/repos/symfony/console/zipball/ebcdc507829df915f4ca23067bd59ee4ef61f6c3", + "reference": "ebcdc507829df915f4ca23067bd59ee4ef61f6c3", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/process": "~2.1" + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0" }, "suggest": { "psr/log": "For using the console logger", @@ -341,56 +348,58 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Console\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Console Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" + "homepage": "https://symfony.com", + "time": "2015-12-22 10:39:06" }, { "name": "symfony/event-dispatcher", - "version": "v2.6.1", - "target-dir": "Symfony/Component/EventDispatcher", + "version": "v2.8.2", "source": { "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "720fe9bca893df7ad1b4546649473b5afddf0216" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "ee278f7c851533e58ca307f66305ccb9188aceda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/720fe9bca893df7ad1b4546649473b5afddf0216", - "reference": "720fe9bca893df7ad1b4546649473b5afddf0216", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ee278f7c851533e58ca307f66305ccb9188aceda", + "reference": "ee278f7c851533e58ca307f66305ccb9188aceda", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.0", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/stopwatch": "~2.2" + "symfony/config": "~2.0,>=2.0.5|~3.0.0", + "symfony/dependency-injection": "~2.6|~3.0.0", + "symfony/expression-language": "~2.6|~3.0.0", + "symfony/stopwatch": "~2.3|~3.0.0" }, "suggest": { "symfony/dependency-injection": "", @@ -399,172 +408,240 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" + "homepage": "https://symfony.com", + "time": "2016-01-13 10:28:07" }, { "name": "symfony/filesystem", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Filesystem", + "version": "v3.0.1", "source": { "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "ff6efc95256cb33031933729e68b01d720b5436b" + "url": "https://github.com/symfony/filesystem.git", + "reference": "c2e59d11dccd135dc8f00ee97f34fe1de842e70c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/ff6efc95256cb33031933729e68b01d720b5436b", - "reference": "ff6efc95256cb33031933729e68b01d720b5436b", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/c2e59d11dccd135dc8f00ee97f34fe1de842e70c", + "reference": "c2e59d11dccd135dc8f00ee97f34fe1de842e70c", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Filesystem\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Filesystem Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" + "homepage": "https://symfony.com", + "time": "2015-12-22 10:39:06" }, { - "name": "symfony/stopwatch", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Stopwatch", + "name": "symfony/polyfill-mbstring", + "version": "v1.1.0", "source": { "type": "git", - "url": "https://github.com/symfony/Stopwatch.git", - "reference": "261abd360cfb6ac65ea93ffd82073e2011d034fc" + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "1289d16209491b584839022f29257ad859b8532d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/261abd360cfb6ac65ea93ffd82073e2011d034fc", - "reference": "261abd360cfb6ac65ea93ffd82073e2011d034fc", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/1289d16209491b584839022f29257ad859b8532d", + "reference": "1289d16209491b584839022f29257ad859b8532d", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "suggest": { + "ext-mbstring": "For best performance" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "1.1-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Stopwatch\\": "" - } + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, { "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2016-01-20 09:13:37" + }, + { + "name": "symfony/stopwatch", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "6aeac8907e3e1340a0033b0a9ec075f8e6524800" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6aeac8907e3e1340a0033b0a9ec075f8e6524800", + "reference": "6aeac8907e3e1340a0033b0a9ec075f8e6524800", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Stopwatch Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" + "homepage": "https://symfony.com", + "time": "2015-10-30 23:35:59" }, { "name": "symfony/yaml", - "version": "v2.6.1", - "target-dir": "Symfony/Component/Yaml", + "version": "v3.0.1", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20" + "url": "https://github.com/symfony/yaml.git", + "reference": "3df409958a646dad2bc5046c3fb671ee24a1a691" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/3346fc090a3eb6b53d408db2903b241af51dcb20", - "reference": "3346fc090a3eb6b53d408db2903b241af51dcb20", + "url": "https://api.github.com/repos/symfony/yaml/zipball/3df409958a646dad2bc5046c3fb671ee24a1a691", + "reference": "3df409958a646dad2bc5046c3fb671ee24a1a691", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Yaml\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" + "homepage": "https://symfony.com", + "time": "2015-12-26 13:39:53" } ], "aliases": [], From 2ca6abf7bf9bf61d25e5ec373f18c6a9c28760f9 Mon Sep 17 00:00:00 2001 From: John P Bloch Date: Wed, 27 Jan 2016 10:09:38 -0600 Subject: [PATCH 070/117] Restrict versions to be compatible with PHP 5.3 --- composer.json | 5 +++ composer.lock | 85 ++++++++++++++++++++++++++------------------------- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/composer.json b/composer.json index 03136014e1..5d44117b92 100644 --- a/composer.json +++ b/composer.json @@ -24,5 +24,10 @@ }, "require-dev": { "codeclimate/php-test-reporter": "dev-master" + }, + "config": { + "platform": { + "php": "5.3.29" + } } } diff --git a/composer.lock b/composer.lock index ebfbad4bab..533000a039 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "2a66b09e73d9603356dbd0f0688b2ffc", - "content-hash": "d42375176ab2c0c38041ad616d74e801", + "hash": "4553bf7abcb9f542364f7c0be9cc94d1", + "content-hash": "cee413b14ad73df8e1129acb0236a7f3", "packages": [], "packages-dev": [ { @@ -269,26 +269,26 @@ }, { "name": "symfony/config", - "version": "v3.0.1", + "version": "v2.8.2", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "58680a6516a457a6c65044fe33586c4a81fdff01" + "reference": "41ee6c70758f40fa1dbf90d019ae0a66c4a09e74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/58680a6516a457a6c65044fe33586c4a81fdff01", - "reference": "58680a6516a457a6c65044fe33586c4a81fdff01", + "url": "https://api.github.com/repos/symfony/config/zipball/41ee6c70758f40fa1dbf90d019ae0a66c4a09e74", + "reference": "41ee6c70758f40fa1dbf90d019ae0a66c4a09e74", "shasum": "" }, "require": { - "php": ">=5.5.9", - "symfony/filesystem": "~2.8|~3.0" + "php": ">=5.3.9", + "symfony/filesystem": "~2.3|~3.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -315,30 +315,30 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2015-12-26 13:39:53" + "time": "2016-01-03 15:33:41" }, { "name": "symfony/console", - "version": "v3.0.1", + "version": "v2.8.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "ebcdc507829df915f4ca23067bd59ee4ef61f6c3" + "reference": "d0239fb42f98dd02e7d342f793c5d2cdee0c478d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/ebcdc507829df915f4ca23067bd59ee4ef61f6c3", - "reference": "ebcdc507829df915f4ca23067bd59ee4ef61f6c3", + "url": "https://api.github.com/repos/symfony/console/zipball/d0239fb42f98dd02e7d342f793c5d2cdee0c478d", + "reference": "d0239fb42f98dd02e7d342f793c5d2cdee0c478d", "shasum": "" }, "require": { - "php": ">=5.5.9", + "php": ">=5.3.9", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/event-dispatcher": "~2.1|~3.0.0", + "symfony/process": "~2.1|~3.0.0" }, "suggest": { "psr/log": "For using the console logger", @@ -348,7 +348,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -375,7 +375,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-12-22 10:39:06" + "time": "2016-01-14 08:33:16" }, { "name": "symfony/event-dispatcher", @@ -439,25 +439,25 @@ }, { "name": "symfony/filesystem", - "version": "v3.0.1", + "version": "v2.8.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "c2e59d11dccd135dc8f00ee97f34fe1de842e70c" + "reference": "637b64d0ee10f44ae98dbad651b1ecdf35a11e8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/c2e59d11dccd135dc8f00ee97f34fe1de842e70c", - "reference": "c2e59d11dccd135dc8f00ee97f34fe1de842e70c", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/637b64d0ee10f44ae98dbad651b1ecdf35a11e8c", + "reference": "637b64d0ee10f44ae98dbad651b1ecdf35a11e8c", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -484,7 +484,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2015-12-22 10:39:06" + "time": "2016-01-13 10:28:07" }, { "name": "symfony/polyfill-mbstring", @@ -547,25 +547,25 @@ }, { "name": "symfony/stopwatch", - "version": "v3.0.1", + "version": "v2.8.2", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "6aeac8907e3e1340a0033b0a9ec075f8e6524800" + "reference": "e3bc8e2a984f4382690a438c8bb650f3ffd71e73" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6aeac8907e3e1340a0033b0a9ec075f8e6524800", - "reference": "6aeac8907e3e1340a0033b0a9ec075f8e6524800", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/e3bc8e2a984f4382690a438c8bb650f3ffd71e73", + "reference": "e3bc8e2a984f4382690a438c8bb650f3ffd71e73", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -592,29 +592,29 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2015-10-30 23:35:59" + "time": "2016-01-03 15:33:41" }, { "name": "symfony/yaml", - "version": "v3.0.1", + "version": "v2.8.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "3df409958a646dad2bc5046c3fb671ee24a1a691" + "reference": "34c8a4b51e751e7ea869b8262f883d008a2b81b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/3df409958a646dad2bc5046c3fb671ee24a1a691", - "reference": "3df409958a646dad2bc5046c3fb671ee24a1a691", + "url": "https://api.github.com/repos/symfony/yaml/zipball/34c8a4b51e751e7ea869b8262f883d008a2b81b8", + "reference": "34c8a4b51e751e7ea869b8262f883d008a2b81b8", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -641,7 +641,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-12-26 13:39:53" + "time": "2016-01-13 10:28:07" } ], "aliases": [], @@ -654,5 +654,8 @@ "platform": { "php": ">=5.2" }, - "platform-dev": [] + "platform-dev": [], + "platform-overrides": { + "php": "5.3.29" + } } From 9de0df9e18458e8f8a65ca5a510be38cb99ef266 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 11:56:24 -0500 Subject: [PATCH 071/117] Handle multisite options Better allows division between single and multisite so that the plugin can be network activated or limited to a single site on multisite. --- classes/class-ep-api.php | 29 +++++++++++++++++-- classes/class-ep-config.php | 20 +++++++++++-- classes/class-ep-settings.php | 54 ++++++++++++++++++++++++----------- elasticpress.php | 2 ++ includes/settings/form.php | 12 +++++++- uninstall.php | 4 +++ 6 files changed, 98 insertions(+), 23 deletions(-) diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index 2c7ccfe9ca..cfd0c18280 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -1478,7 +1478,15 @@ public function deactivate() { ep_check_host(); - return delete_site_option( 'ep_is_active' ); + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + + return delete_site_option( 'ep_is_active' ); + + } else { + + return delete_option( 'ep_is_active' ); + + } } @@ -1492,8 +1500,15 @@ public function activate() { ep_check_host(); - return update_site_option( 'ep_is_active', true ); + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + + return update_site_option( 'ep_is_active', true ); + + } else { + return update_option( 'ep_is_active', true ); + + } } /** @@ -1577,7 +1592,15 @@ protected function parse_orderby( $orderby, $order ) { * @since 0.9.2 */ public function is_activated() { - return get_site_option( 'ep_is_active', false, false ); + + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + + return get_site_option( 'ep_is_active', false, false ); + + } else { + + return get_option( 'ep_is_active', false, false ); + } } /** diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index 255291297c..653523630c 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -193,7 +193,15 @@ public function check_host() { */ public function set_api_key() { - $ep_api_key = get_site_option( 'ep_api_key' ); + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + + $ep_api_key = get_site_option( 'ep_api_key' ); + + } else { + + $ep_api_key = get_option( 'ep_api_key' ); + + } if ( $ep_api_key && ! defined( 'EP_API_KEY' ) ) { define( 'EP_API_KEY', $ep_api_key ); @@ -218,7 +226,15 @@ public function set_api_key() { */ public function set_host() { - $ep_host = get_site_option( 'ep_host' ); + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + + $ep_host = get_site_option( 'ep_host' ); + + } else { + + $ep_host = get_option( 'ep_host' ); + + } if ( $ep_host && ! defined( 'EP_HOST' ) ) { $this->option_host = true; diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 9e478b01fd..e587b47e2d 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -111,19 +111,19 @@ public function action_admin_enqueue_scripts() { } wp_localize_script( - 'ep_admin', - 'ep', - array( - 'nonce' => wp_create_nonce( 'ep_manual_index' ), - 'stats_nonce' => wp_create_nonce( 'ep_site_stats' ), - 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), - 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), - 'items_indexed' => $indexed, - 'sites' => esc_html__( ' site(s)', 'elasticpress' ), - 'index_running' => $running, - 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, - 'synced_posts' => $synced_posts, - ) + 'ep_admin', + 'ep', + array( + 'nonce' => wp_create_nonce( 'ep_manual_index' ), + 'stats_nonce' => wp_create_nonce( 'ep_site_stats' ), + 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), + 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), + 'items_indexed' => $indexed, + 'sites' => esc_html__( ' site(s)', 'elasticpress' ), + 'index_running' => $running, + 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, + 'synced_posts' => $synced_posts, + ) ); } @@ -374,7 +374,18 @@ public function setting_callback_activate() { */ public function setting_callback_api_key() { - echo ''; + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + + $key = get_site_option( 'ep_api_key' ); + + } else { + + $key = get_option( 'ep_api_key' ); + + } + + + echo ''; } @@ -389,12 +400,21 @@ public function setting_callback_api_key() { */ public function setting_callback_host() { + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + + $host = get_site_option( 'ep_host' ); + + } else { + + $host = get_option( 'ep_host' ); + + } + $read_only = ''; - $host = get_site_option( 'ep_host' ); if ( false === ep_host_by_option() && defined( 'EP_HOST' ) ) { $read_only = 'readonly'; - $host = EP_HOST; + $host = EP_HOST; } echo ''; @@ -440,7 +460,7 @@ public function ep_settings_section_hightlight() { * * @since 1.7 * - * @param int $bytes The raw bytes to convert. + * @param int $bytes The raw bytes to convert. * @param int $precision The precision with which to display the conversion. * * @return string diff --git a/elasticpress.php b/elasticpress.php index ac0be84dfa..71503141b0 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -29,6 +29,8 @@ require_once( 'classes/class-ep-wp-query-integration.php' ); require_once( 'classes/class-ep-wp-date-query.php' ); + +// Define a constant if we're network activated to allow plugin to respond accordingly. $network_activated = ep_is_network_activated( plugin_basename( __FILE__ ) ); if ( $network_activated ) { diff --git a/includes/settings/form.php b/includes/settings/form.php index 5f2bae8108..5329b27828 100644 --- a/includes/settings/form.php +++ b/includes/settings/form.php @@ -25,7 +25,17 @@ settings_fields( 'elasticpress' ); do_settings_sections( 'elasticpress' ); - if ( ( ! ep_host_by_option() && ! is_wp_error( ep_check_host() ) ) || is_wp_error( ep_check_host() ) || get_site_option( 'ep_host' ) ) { + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + + $host = get_site_option( 'ep_host' ); + + } else { + + $host = get_option( 'ep_host' ); + + } + + if ( ( ! ep_host_by_option() && ! is_wp_error( ep_check_host() ) ) || is_wp_error( ep_check_host() ) || $host ) { submit_button(); } diff --git a/uninstall.php b/uninstall.php index a07a3726f1..f875e594d4 100644 --- a/uninstall.php +++ b/uninstall.php @@ -66,6 +66,10 @@ protected static function clean_options() { delete_site_option( 'ep_host' ); delete_site_option( 'ep_activate' ); + // Delete options if we're not network activated. + delete_option( 'ep_host' ); + delete_option( 'ep_activate' ); + // Delete transients. delete_transient( 'ep_post_count' ); delete_transient( 'ep_index_offset' ); From 156fdddcc2944b6def209f7a6c5d5f6a38dc39f3 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 11:56:34 -0500 Subject: [PATCH 072/117] Fix a version number --- elasticpress.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticpress.php b/elasticpress.php index 71503141b0..abc5f302dd 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -20,7 +20,7 @@ } define( 'EP_URL', plugin_dir_url( __FILE__ ) ); -define( 'EP_VERSION', '1.6.2' ); +define( 'EP_VERSION', '1.8' ); require_once( 'classes/class-ep-config.php' ); require_once( 'classes/class-ep-api.php' ); From 65cf5b63de4e8e6e01912a306d99e809a6b707d0 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 14:47:37 -0500 Subject: [PATCH 073/117] Remove EP API_KEY setting Removes the ElasticPress API setting from ElasticPress core (can still be added with a constant). --- classes/class-ep-api.php | 1 + classes/class-ep-config.php | 37 ------------------------------ classes/class-ep-settings.php | 42 +---------------------------------- 3 files changed, 2 insertions(+), 78 deletions(-) diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index cfd0c18280..de00364ac7 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -267,6 +267,7 @@ public function delete_post( $post_id, $blocking = true ) { public function format_request_headers() { $headers = array(); + // Check for ElasticPress API key and add to header if needed. if ( defined( 'EP_API_KEY' ) && EP_API_KEY ) { $headers['X-ElasticPress-API-Key'] = EP_API_KEY; } diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index 653523630c..094fb9b09e 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -182,39 +182,6 @@ public function check_host() { } - /** - * Set EP_API_KEY if needed - * - * Retrieves the value set in options the api key and defines EP_API_KEY constant. - * - * @since 0.3.0 - * - * @return string The set API key. - */ - public function set_api_key() { - - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { - - $ep_api_key = get_site_option( 'ep_api_key' ); - - } else { - - $ep_api_key = get_option( 'ep_api_key' ); - - } - - if ( $ep_api_key && ! defined( 'EP_API_KEY' ) ) { - define( 'EP_API_KEY', $ep_api_key ); - } - - if ( defined( 'EP_API_KEY' ) ) { - return EP_API_KEY; - } - - return ''; - - } - /** * Set EP_HOST if needed * @@ -322,10 +289,6 @@ function ep_set_host() { return EP_Config::factory()->set_host(); } -function ep_set_api_key() { - return EP_Config::factory()->set_api_key(); -} - function ep_host_by_option() { return EP_Config::factory()->host_by_option(); } diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index e587b47e2d..bc278f4ec8 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -36,7 +36,6 @@ class EP_Settings { */ public function __construct() { - ep_set_api_key(); ep_check_host(); if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { // Must be network admin in multisite. @@ -154,13 +153,6 @@ public function action_admin_init() { } - if ( isset( $_POST['ep_api_key'] ) ) { - - $host = sanitize_text_field( $_POST['ep_api_key'] ); - update_site_option( 'ep_api_key', $host ); - - } - if ( isset( $_POST['ep_activate'] ) ) { $this->sanitize_ep_activate( $_POST['ep_activate'] ); @@ -182,11 +174,6 @@ public function action_admin_init() { 'setting_callback_host', ), 'elasticpress', 'ep_settings_section_main' ); - add_settings_field( 'ep_api_key', esc_html__( 'ElasticPress API Key:', 'elasticpress' ), array( - $this, - 'setting_callback_api_key', - ), 'elasticpress', 'ep_settings_section_main' ); - $stats = ep_get_index_status(); if ( $stats['status'] && ! is_wp_error( ep_check_host() ) ) { @@ -199,7 +186,6 @@ public function action_admin_init() { } register_setting( 'elasticpress', 'ep_host', array( $this, 'sanitize_ep_host' ) ); - register_setting( 'elasticpress', 'ep_api_key', 'sanitize_text_field' ); register_setting( 'elasticpress', 'ep_activate', array( $this, 'sanitize_ep_activate' ) ); } @@ -363,38 +349,12 @@ public function setting_callback_activate() { } - /** - * Setting callback - * - * Callback for settings field. Displays textbox to specify the EP_API_KEY. - * - * @since 0.3.0 - * - * @return void - */ - public function setting_callback_api_key() { - - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { - - $key = get_site_option( 'ep_api_key' ); - - } else { - - $key = get_option( 'ep_api_key' ); - - } - - - echo ''; - - } - /** * Setting callback * * Callback for settings field. Displays textbox to specify the EP_HOST. * - * @since 1.7 + * @since 1.9 * * @return void */ From ce200cf6288feb172648b96a2ba579fe334ac490 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 14:47:48 -0500 Subject: [PATCH 074/117] Fix version numbers --- classes/class-ep-index-status.php | 6 +++--- classes/class-ep-settings.php | 32 +++++++++++++++---------------- includes/settings/form.php | 2 +- includes/settings/index.php | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/classes/class-ep-index-status.php b/classes/class-ep-index-status.php index 08f1d00984..0d9091c20b 100644 --- a/classes/class-ep-index-status.php +++ b/classes/class-ep-index-status.php @@ -4,7 +4,7 @@ * * @package elasticpress * - * @since 1.7 + * @since 1.9 * * @author Chris Wiegman */ @@ -22,7 +22,7 @@ class EP_Index_Status { * * Wires actions and filters for the index status indicators. * - * @since 1.7 + * @since 1.9 * * @return EP_Index_Status */ @@ -37,7 +37,7 @@ public function __construct() { * * Shows the index status of individual posts. * - * @since 1.7 + * @since 1.9 * * @return void */ diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index bc278f4ec8..82617b06d8 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -4,7 +4,7 @@ * * @package elasticpress * - * @since 1.7 + * @since 1.9 * * @author Allan Collins */ @@ -19,7 +19,7 @@ class EP_Settings { /** * WordPress options page * - * @since 1.7 + * @since 1.9 * * @var object */ @@ -30,7 +30,7 @@ class EP_Settings { * * Loads initial actions. * - * @since 1.7 + * @since 1.9 * * @return EP_Settings */ @@ -60,7 +60,7 @@ public function __construct() { * * Registers and enqueues the necessary JavaScripts for the interface. * - * @since 1.7 + * @since 1.9 * * @return void */ @@ -133,7 +133,7 @@ public function action_admin_enqueue_scripts() { * * Sets up Settings API. * - * @since 1.7 + * @since 1.9 * * @return void */ @@ -166,7 +166,7 @@ public function action_admin_init() { add_settings_section( 'ep_settings_section_main', '', array( $this, - 'ep_settings_section_hightlight', + 'callback_ep_settings_section_main', ), 'elasticpress' ); add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( @@ -195,7 +195,7 @@ public function action_admin_init() { * * Adds options page to admin menu. * - * @since 1.7 + * @since 1.9 * * @return void */ @@ -226,7 +226,7 @@ public function action_admin_menu() { * * Callback for add_meta_box to load column view. * - * @since 1.7 + * @since 1.9 * * @param WP_Post|NULL $post Normally WP_Post object, but NULL in our case. * @param array $args Arguments passed from add_meta_box. @@ -247,7 +247,7 @@ public function load_view( $post, $args ) { * * Creates meta boxes for the settings page columns. * - * @since 1.7 + * @since 1.9 * * @return void */ @@ -291,7 +291,7 @@ protected function populate_columns() { * * Sanitizes the activation input from the dashboard and performs activation/deactivation. * - * @since 0.2.0 + * @since 1.9 * * @param string $input input items. * @@ -320,7 +320,7 @@ public function sanitize_ep_activate( $input ) { * * Sanitizes the EP_HOST inputed from the dashboard. * - * @since 0.2.0 + * @since 1.9 * * @param string $input input items. * @@ -339,7 +339,7 @@ public function sanitize_ep_host( $input ) { * * Callback for settings field. Displays textbox to specify the EP_HOST. * - * @since 0.2.0 + * @since 1.9 * * @return void */ @@ -386,7 +386,7 @@ public function setting_callback_host() { * * Loads up the settings page. * - * @since 1.7 + * @since 1.9 * * @return void */ @@ -403,11 +403,11 @@ public function settings_page() { * * Adds a header to main settings information * - * @since 0.2.0 + * @since 1.9 * * @return void */ - public function ep_settings_section_hightlight() { + public function callback_ep_settings_section_main() { echo '

      ' . esc_html__( 'ElasticSearch Integration Options', 'elasticpress' ) . '

      '; @@ -418,7 +418,7 @@ public function ep_settings_section_hightlight() { * * Converts bytes to human-readable format. * - * @since 1.7 + * @since 1.9 * * @param int $bytes The raw bytes to convert. * @param int $precision The precision with which to display the conversion. diff --git a/includes/settings/form.php b/includes/settings/form.php index 5329b27828..a3b16498b5 100644 --- a/includes/settings/form.php +++ b/includes/settings/form.php @@ -2,7 +2,7 @@ /** * Form for setting ElasticPress preferences * - * @since 1.7 + * @since 1.9 * * @package elasticpress * diff --git a/includes/settings/index.php b/includes/settings/index.php index 650188bd71..88964977bd 100644 --- a/includes/settings/index.php +++ b/includes/settings/index.php @@ -2,7 +2,7 @@ /** * Form for execution ElasticPress indexer * - * @since 1.7 + * @since 1.9 * * @package elasticpress * From a56499829ec6c031082c9e488a6cc3c34104937e Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 14:53:43 -0500 Subject: [PATCH 075/117] Remove extra files Not really applicable for directory browsing anymore. Time to stop adding the extra index.php files. --- assets/css/images/index.php | 1 - assets/css/index.php | 1 - assets/index.php | 1 - assets/js/index.php | 1 - 4 files changed, 4 deletions(-) delete mode 100644 assets/css/images/index.php delete mode 100644 assets/css/index.php delete mode 100644 assets/index.php delete mode 100644 assets/js/index.php diff --git a/assets/css/images/index.php b/assets/css/images/index.php deleted file mode 100644 index 83c037f11a..0000000000 --- a/assets/css/images/index.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/css/index.php b/assets/css/index.php deleted file mode 100644 index 83c037f11a..0000000000 --- a/assets/css/index.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/index.php b/assets/index.php deleted file mode 100644 index 83c037f11a..0000000000 --- a/assets/index.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/js/index.php b/assets/js/index.php deleted file mode 100644 index 83c037f11a..0000000000 --- a/assets/js/index.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From bbe5000004ef23ebd12e69e09f5e0912513289e6 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Wed, 27 Jan 2016 13:24:23 -0700 Subject: [PATCH 076/117] Update some copy to make more sense based on the situation. Fix a typo. --- classes/class-ep-config.php | 2 +- includes/settings/status.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index 094fb9b09e..613bfc11f9 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -34,7 +34,7 @@ public static function factory() { * Retrieve the appropriate EP_HOST * * Looks at the defined EP_HOST or a backup global should the defined host failed. - * Priority is given to the EP_HOST constand with the backups only used when needed. + * Priority is given to the EP_HOST constant with the backups only used when needed. * * @since 1.6 * diff --git a/includes/settings/status.php b/includes/settings/status.php index 846d623281..d172736091 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -34,7 +34,7 @@ -
    + @@ -58,7 +58,7 @@ + style="color:red;">
    From 7def4570952faa6bf47cdcf872b30b94f770ff0e Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 16:58:32 -0500 Subject: [PATCH 077/117] Ignore vendor dir with git --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3c3629e647..022b988504 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +vendor From fc4b4c72011159c5127fef6b6bcd40f4e947dd70 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 16:58:54 -0500 Subject: [PATCH 078/117] Make sure all strings are translatable --- classes/class-ep-settings.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 82617b06d8..5d32a8a525 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -109,6 +109,12 @@ public function action_admin_enqueue_scripts() { $indexed = esc_html__( 'items indexed in ', 'elasticpress' ); } + $allowed_link = array( + 'a' => array( + 'href' => array(), + ), + ); + wp_localize_script( 'ep_admin', 'ep', @@ -122,6 +128,8 @@ public function action_admin_enqueue_scripts() { 'index_running' => $running, 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, 'synced_posts' => $synced_posts, + 'failed_text' => esc_html__( 'A failure has occured. Please try the indexing operation again and if the error persists contact your website administrator.', 'elasticpress' ), + 'complete_text' => wp_kses( __( 'Index complete Refresh the stats', 'elasticpress' ), $allowed_link ), ) ); From cabfe6886165b7c728a3481c193ec97e3b8dc4fc Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 16:59:31 -0500 Subject: [PATCH 079/117] Better error handling with AJAX --- assets/js/elasticpress-admin.js | 81 +++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 28f2508829..1e19312143 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -66,61 +66,76 @@ jQuery( document ).ready( function ( $ ) { url : ajaxurl, type : 'POST', data : data, - complete : function ( response ) { + error : function ( request ) { + + alert( request.responseText ); - var sitesCompletedText = '' + }, + complete : function ( response ) { - if ( 0 === response.responseJSON.data.is_network ) { + // Handle returned error appropriately. + if ( 'undefined' === typeof response.responseJSON || 'undefined' === typeof response.responseJSON.data ) { - epTotalToIndex = response.responseJSON.data.ep_posts_total; - epTotalIndexed = response.responseJSON.data.ep_posts_synced; + $( '#progressstats' ).text( ep.failed_text ); + $( '#ep_run_index' ).val( ep.index_complete_text ).addClass( 'button-primary' ); + $( '#progressbar' ).fadeOut( 'slow' ); } else { - if ( epSitesRemaining !== response.responseJSON.data.ep_sites_remaining ) { + var sitesCompletedText = '' - epSitesRemaining = response.responseJSON.data.ep_sites_remaining; - epTotalToIndex += response.responseJSON.data.ep_posts_total; - epSitesCompleted ++; + if ( 0 === response.responseJSON.data.is_network ) { - } + epTotalToIndex = response.responseJSON.data.ep_posts_total; + epTotalIndexed = response.responseJSON.data.ep_posts_synced; - sitesCompletedText = epSitesCompleted + ep.sites; - epTotalIndexed += response.responseJSON.data.ep_current_synced; + } else { - } + if ( epSitesRemaining !== response.responseJSON.data.ep_sites_remaining ) { - var progress = parseFloat( epTotalIndexed ) / parseFloat( epTotalToIndex ); + epSitesRemaining = response.responseJSON.data.ep_sites_remaining; + epTotalToIndex += response.responseJSON.data.ep_posts_total; + epSitesCompleted ++; - bar.progressbar( - { - value : progress * 100 - } - ); + } + + sitesCompletedText = epSitesCompleted + ep.sites; + epTotalIndexed += response.responseJSON.data.ep_current_synced; - status.text( epTotalIndexed + '/' + epTotalToIndex + ' ' + ep.items_indexed + sitesCompletedText ); + } - if ( 1 == response.responseJSON.data.ep_sync_complete ) { //indexing complete + var progress = parseFloat( epTotalIndexed ) / parseFloat( epTotalToIndex ); bar.progressbar( { - value : 100 + value : progress * 100 } ); - setTimeout( function () { + status.text( epTotalIndexed + '/' + epTotalToIndex + ' ' + ep.items_indexed + sitesCompletedText ); - $( '#progressbar' ).fadeOut( 'slow' ); - $( '#progressstats' ).html( 'Index complete Refresh the stats' ); - $( '#ep_run_index' ).val( ep.index_complete_text ).addClass( 'button-primary' ); - resetIndex(); + if ( 1 == response.responseJSON.data.ep_sync_complete ) { //indexing complete - }, 1000 ); + bar.progressbar( + { + value : 100 + } + ); - } else { + setTimeout( function () { + + $( '#progressbar' ).fadeOut( 'slow' ); + $( '#progressstats' ).html( ep.complete_text ); + $( '#ep_run_index' ).val( ep.index_complete_text ).addClass( 'button-primary' ); + resetIndex(); + + }, 1000 ); - performIndex( false, button ); + } else { + performIndex( false, button ); + + } } } } @@ -153,6 +168,7 @@ jQuery( document ).ready( function ( $ ) { return; } + $( '#progressstats' ).text( ep.running_index_text ); performIndex( true, button ); //start the polling } ); @@ -179,6 +195,11 @@ jQuery( document ).ready( function ( $ ) { url : ajaxurl, type : 'POST', data : data, + error : function ( request ) { + + alert( request.responseText ); + + }, complete : function ( response ) { $( '#ep_site_stats' ).html( response.responseJSON.data ); From c975df4a876648886e2bf56aed6966b56c8b3927 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 16:59:37 -0500 Subject: [PATCH 080/117] Grunt run --- assets/js/elasticpress-admin.min.js | 2 +- lang/elasticpress.pot | 86 ++++++++++++++++------------- 2 files changed, 48 insertions(+), 40 deletions(-) diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index 01da35dad8..1876f6e0cf 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.text(ep.synced_posts+"/"+ep.total_posts+"items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,complete:function(k){var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.text(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html('Index complete Refresh the stats'),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&b(!0,d)});var j=a("#ep_site_select");j.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.text(ep.synced_posts+"/"+ep.total_posts+"items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,error:function(a){alert(a.responseText)},complete:function(k){if("undefined"==typeof k.responseJSON||"undefined"==typeof k.responseJSON.data)a("#progressstats").text(ep.failed_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),a("#progressbar").fadeOut("slow");else{var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.text(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),b(!0,d))});var j=a("#ep_site_select");j.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,error:function(a){alert(a.responseText)},complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 9dc7be760a..1831e82b01 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-01-26 14:35-0500\n" +"POT-Creation-Date: 2016-01-27 16:57-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -109,26 +109,26 @@ msgstr "" msgid "Unable to reach Elasticsearch Server! Check that service is running." msgstr "" -#: classes/class-ep-api.php:1740 +#: classes/class-ep-api.php:1764 msgid "" "Invalid response from ElasticPress server. Please contact your administrator." msgstr "" -#: classes/class-ep-api.php:1753 +#: classes/class-ep-api.php:1777 msgid "" "Site not indexed.

    Please run: wp elasticpress index --setup --" "network-wide using WP-CLI. Or use the index button on the left of " "this screen.

    " msgstr "" -#: classes/class-ep-api.php:1757 +#: classes/class-ep-api.php:1781 msgid "" "Site not indexed.

    Please run: wp elasticpress index --setup " "using WP-CLI. Or use the index button on the left of this screen.

    " msgstr "" -#: classes/class-ep-api.php:1795 classes/class-ep-api.php:1854 -#: classes/class-ep-api.php:1894 classes/class-ep-api.php:1945 +#: classes/class-ep-api.php:1819 classes/class-ep-api.php:1878 +#: classes/class-ep-api.php:1918 classes/class-ep-api.php:1969 msgid "ElasticSearch Host is not available." msgstr "" @@ -149,39 +149,39 @@ msgid "" msgstr "" #: classes/class-ep-index-gui.php:179 classes/class-ep-index-gui.php:309 -#: classes/class-ep-settings.php:147 +#: classes/class-ep-settings.php:154 msgid "Security error!" msgstr "" -#: classes/class-ep-index-gui.php:322 includes/settings/status.php:72 +#: classes/class-ep-index-gui.php:322 includes/settings/status.php:70 msgid "Search Stats" msgstr "" -#: classes/class-ep-index-gui.php:325 includes/settings/status.php:76 +#: classes/class-ep-index-gui.php:325 includes/settings/status.php:74 msgid "Total Queries:" msgstr "" -#: classes/class-ep-index-gui.php:328 includes/settings/status.php:79 +#: classes/class-ep-index-gui.php:328 includes/settings/status.php:77 msgid "Query Time:" msgstr "" -#: classes/class-ep-index-gui.php:331 includes/settings/status.php:83 +#: classes/class-ep-index-gui.php:331 includes/settings/status.php:81 msgid "Total Fetches:" msgstr "" -#: classes/class-ep-index-gui.php:334 includes/settings/status.php:86 +#: classes/class-ep-index-gui.php:334 includes/settings/status.php:84 msgid "Fetch Time:" msgstr "" -#: classes/class-ep-index-gui.php:339 includes/settings/status.php:95 +#: classes/class-ep-index-gui.php:339 includes/settings/status.php:93 msgid "Index Stats" msgstr "" -#: classes/class-ep-index-gui.php:342 includes/settings/status.php:99 +#: classes/class-ep-index-gui.php:342 includes/settings/status.php:97 msgid "Index Total:" msgstr "" -#: classes/class-ep-index-gui.php:345 includes/settings/status.php:102 +#: classes/class-ep-index-gui.php:345 includes/settings/status.php:100 msgid "Index Time:" msgstr "" @@ -197,39 +197,45 @@ msgstr "" msgid ": ElasticPress Index Errors" msgstr "" -#: classes/class-ep-settings.php:107 +#: classes/class-ep-settings.php:106 msgid "items indexed" msgstr "" -#: classes/class-ep-settings.php:110 +#: classes/class-ep-settings.php:109 msgid "items indexed in " msgstr "" -#: classes/class-ep-settings.php:119 includes/settings/index.php:14 +#: classes/class-ep-settings.php:124 includes/settings/index.php:14 msgid "Running Index..." msgstr "" -#: classes/class-ep-settings.php:120 includes/settings/index.php:14 +#: classes/class-ep-settings.php:125 includes/settings/index.php:14 msgid "Run Index" msgstr "" -#: classes/class-ep-settings.php:122 +#: classes/class-ep-settings.php:127 msgid " site(s)" msgstr "" -#: classes/class-ep-settings.php:180 -msgid "ElasticSearch Host:" +#: classes/class-ep-settings.php:131 +msgid "" +"A failure has occured. Please try the indexing operation again and if the " +"error persists contact your website administrator." +msgstr "" + +#: classes/class-ep-settings.php:132 +msgid "Index complete Refresh the stats" msgstr "" -#: classes/class-ep-settings.php:185 -msgid "ElasticPress API Key:" +#: classes/class-ep-settings.php:180 +msgid "ElasticSearch Host:" msgstr "" -#: classes/class-ep-settings.php:194 +#: classes/class-ep-settings.php:189 msgid "Use ElasticSearch:" msgstr "" -#: classes/class-ep-settings.php:432 +#: classes/class-ep-settings.php:420 msgid "ElasticSearch Integration Options" msgstr "" @@ -267,7 +273,9 @@ msgid "" msgstr "" #: includes/settings/status.php:37 -msgid "A host has not been set. You must set a host to continue." +msgid "" +"A host has not been set or is set but cannot be contacted. You must set a " +"proper host to continue." msgstr "" #: includes/settings/status.php:48 @@ -282,45 +290,45 @@ msgstr "" msgid "ElasticPress can override WP search." msgstr "" -#: includes/settings/status.php:63 +#: includes/settings/status.php:61 msgid "" -"ElasticPress is not activated and cannot override WP search. You can " -"activate it on the form to the left." +"ElasticPress is not enabled and cannot override WP queries. You can activate " +"it on the form to the left." msgstr "" -#: includes/settings/status.php:68 +#: includes/settings/status.php:66 msgid "System Stats" msgstr "" -#: includes/settings/status.php:114 +#: includes/settings/status.php:112 msgid "Site Stats" msgstr "" -#: includes/settings/status.php:117 +#: includes/settings/status.php:115 msgid "Select a site:" msgstr "" -#: includes/settings/status.php:118 +#: includes/settings/status.php:116 msgid "Select" msgstr "" -#: includes/settings/status.php:153 +#: includes/settings/status.php:151 msgid "Cluster Stats" msgstr "" -#: includes/settings/status.php:163 +#: includes/settings/status.php:161 msgid "Disk Usage:" msgstr "" -#: includes/settings/status.php:167 +#: includes/settings/status.php:165 msgid "Disk Space Available:" msgstr "" -#: includes/settings/status.php:170 +#: includes/settings/status.php:168 msgid "Total Disk Space:" msgstr "" -#: includes/settings/status.php:183 +#: includes/settings/status.php:181 msgid "ERROR:" msgstr "" From 9570b11144dfb502a99be9020e2bb6e151226087 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Wed, 27 Jan 2016 17:02:59 -0500 Subject: [PATCH 081/117] Fix missing semi-colon. --- assets/js/elasticpress-admin.js | 2 +- lang/elasticpress.pot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index 1e19312143..b888cdd369 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -82,7 +82,7 @@ jQuery( document ).ready( function ( $ ) { } else { - var sitesCompletedText = '' + var sitesCompletedText = ''; if ( 0 === response.responseJSON.data.is_network ) { diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 1831e82b01..c5d3f96543 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-01-27 16:57-0500\n" +"POT-Creation-Date: 2016-01-27 17:02-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From e5da87abf91bc309fa1aecda4efeae5f9611b162 Mon Sep 17 00:00:00 2001 From: Chris Wiegman Date: Thu, 28 Jan 2016 10:05:19 -0500 Subject: [PATCH 082/117] Look in query_vars instead of query to determine enabled status. --- classes/class-ep-api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index 3d7ea7fe19..da3ccaacc6 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -1459,9 +1459,9 @@ public function elasticpress_enabled( $query ) { if ( method_exists( $query, 'is_search' ) && $query->is_search() ) { $enabled = true; - } elseif ( ! empty( $query->query['ep_match_all'] ) ) { // ep_match_all is supported for legacy reasons + } elseif ( ! empty( $query->query_vars['ep_match_all'] ) ) { // ep_match_all is supported for legacy reasons $enabled = true; - } elseif ( ! empty( $query->query['ep_integrate'] ) ) { + } elseif ( ! empty( $query->query_vars['ep_integrate'] ) ) { $enabled = true; } From e612a1d3067339ee64958c3b7e654aa28f45cd2e Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 28 Jan 2016 15:05:58 -0700 Subject: [PATCH 083/117] Add a missing space in some status text. --- assets/js/elasticpress-admin.js | 2 +- assets/js/elasticpress-admin.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index b888cdd369..dcdf6d61cc 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -20,7 +20,7 @@ jQuery( document ).ready( function ( $ ) { if ( parseInt( ep.total_posts ) > 0 ) { progress = parseFloat( ep.synced_posts ) / parseFloat( ep.total_posts ); - status.text( ep.synced_posts + '/' + ep.total_posts + 'items' ); + status.text( ep.synced_posts + '/' + ep.total_posts + ' items' ); } diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index 1876f6e0cf..b64bf68a01 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.text(ep.synced_posts+"/"+ep.total_posts+"items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,error:function(a){alert(a.responseText)},complete:function(k){if("undefined"==typeof k.responseJSON||"undefined"==typeof k.responseJSON.data)a("#progressstats").text(ep.failed_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),a("#progressbar").fadeOut("slow");else{var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.text(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),b(!0,d))});var j=a("#ep_site_select");j.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,error:function(a){alert(a.responseText)},complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.text(ep.synced_posts+"/"+ep.total_posts+" items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,error:function(a){alert(a.responseText)},complete:function(k){if("undefined"==typeof k.responseJSON||"undefined"==typeof k.responseJSON.data)a("#progressstats").text(ep.failed_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),a("#progressbar").fadeOut("slow");else{var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.text(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),b(!0,d))});var j=a("#ep_site_select");j.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,error:function(a){alert(a.responseText)},complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file From 5fe446a3792a8cbcb25e123db3ccc99ad7ee5772 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 29 Jan 2016 14:49:12 -0700 Subject: [PATCH 084/117] Update the main readme a bit to reflect the --keep-active flag changes. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b62ddf8771..1e2ee681bc 100644 --- a/README.md +++ b/README.md @@ -500,15 +500,15 @@ The following commands are supported by ElasticPress: * `--offset` let's you skip the first n posts (don't forget to remove the `--setup` flag when resuming or the index will be emptied before starting again). * `--show-bulk-errors` displays the error message returned from Elasticsearch when a post fails to index (as opposed to just the title and ID of the post). * `--post-type` let's you specify which post types will be indexed (by default: all indexable post types are indexed). For example, `--post-type="my_custom_post_type"` would limit indexing to only posts from the post type "my_custom_post_type". Accepts multiple post types separated by comma. - * `--keep-active` let's you keep ElasticPress active during indexing (cannot be used with --setup). + * `--keep-active` let's you keep ElasticPress active during indexing (cannot be used with `--setup`). * `wp elasticpress activate` - Turns on ElasticPress integration. Integration is automatically deactivated during indexing. + Turns on ElasticPress integration. Integration is automatically deactivated during indexing if `--keep-active` isn't passed or `--setup` is passed. * `wp elasticpress deactivate` - Turns off ElasticPress integration. Integration is automatically deactivated during indexing. + Turns off ElasticPress integration. Integration is automatically deactivated during indexing if `--keep-active` isn't passed or `--setup` is passed. * `wp elasticpress delete-index [--network-wide]` From 0280759d39b153be6df230452289daeb72a08778 Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Sun, 6 Dec 2015 21:20:18 +0100 Subject: [PATCH 085/117] (Closes #390) Fix --no-bulk option --- bin/wp-cli.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index c9ad18bb9e..d2335c3cb1 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -182,6 +182,7 @@ private function _create_network_alias() { * Index all posts for a site or network wide * * @synopsis [--setup] [--network-wide] [--posts-per-page] [--no-bulk] [--offset] [--show-bulk-errors] [--post-type] [--keep-active] + * * @param array $args * * @since 0.1.2 @@ -189,6 +190,8 @@ private function _create_network_alias() { * @param array $assoc_args */ public function index( $args, $assoc_args ) { + $defaults = array( 'bulk' => true ); + $assoc_args = wp_parse_args( $assoc_args, $defaults ); $this->_connect_check(); if ( ! empty( $assoc_args['posts-per-page'] ) ) { @@ -301,11 +304,7 @@ private function _index_helper( $args ) { $synced = 0; $errors = array(); - $no_bulk = false; - - if ( isset( $args['no-bulk'] ) ) { - $no_bulk = true; - } + $no_bulk = ! $args['bulk']; $show_bulk_errors = false; From caaa2bd96affc26a013092a61546004c7797dfaf Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Wed, 23 Dec 2015 22:50:14 +0100 Subject: [PATCH 086/117] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e2ee681bc..b96beff33e 100644 --- a/README.md +++ b/README.md @@ -496,7 +496,7 @@ The following commands are supported by ElasticPress: * `--network-wide` will force indexing on all the blogs in the network. `--network-wide` takes an optional argument to limit the number of blogs to be indexed across where 0 is no limit. For example, `--network-wide=5` would limit indexing to only 5 blogs on the network. * `--setup` will clear the index first and re-send the put mapping. * `--posts-per-page` let's you determine the amount of posts to be indexed per bulk index (or cycle). - * `--no-bulk` let's you disable bulk indexing. + * `--bulk` let's you enable bulk indexing (use --no-bulk to disable). * `--offset` let's you skip the first n posts (don't forget to remove the `--setup` flag when resuming or the index will be emptied before starting again). * `--show-bulk-errors` displays the error message returned from Elasticsearch when a post fails to index (as opposed to just the title and ID of the post). * `--post-type` let's you specify which post types will be indexed (by default: all indexable post types are indexed). For example, `--post-type="my_custom_post_type"` would limit indexing to only posts from the post type "my_custom_post_type". Accepts multiple post types separated by comma. From 7b9f2a1f9d8fa3a89b2a484ac81f809871487675 Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Wed, 20 Jan 2016 19:05:34 +0100 Subject: [PATCH 087/117] Renamed option to nobulk --- README.md | 4 ++-- bin/wp-cli.php | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b96beff33e..15cca4d4f3 100644 --- a/README.md +++ b/README.md @@ -489,14 +489,14 @@ The following are special parameters that are only supported by ElasticPress. The following commands are supported by ElasticPress: -* `wp elasticpress index [--setup] [--network-wide] [--posts-per-page] [--no-bulk] [--offset] [--show-bulk-errors] [--post-type] [--keep-active]` +* `wp elasticpress index [--setup] [--network-wide] [--posts-per-page] [--nobulk] [--offset] [--show-bulk-errors] [--post-type] [--keep-active]` Index all posts in the current blog. * `--network-wide` will force indexing on all the blogs in the network. `--network-wide` takes an optional argument to limit the number of blogs to be indexed across where 0 is no limit. For example, `--network-wide=5` would limit indexing to only 5 blogs on the network. * `--setup` will clear the index first and re-send the put mapping. * `--posts-per-page` let's you determine the amount of posts to be indexed per bulk index (or cycle). - * `--bulk` let's you enable bulk indexing (use --no-bulk to disable). + * `--nobulk` let's you disable bulk indexing. * `--offset` let's you skip the first n posts (don't forget to remove the `--setup` flag when resuming or the index will be emptied before starting again). * `--show-bulk-errors` displays the error message returned from Elasticsearch when a post fails to index (as opposed to just the title and ID of the post). * `--post-type` let's you specify which post types will be indexed (by default: all indexable post types are indexed). For example, `--post-type="my_custom_post_type"` would limit indexing to only posts from the post type "my_custom_post_type". Accepts multiple post types separated by comma. diff --git a/bin/wp-cli.php b/bin/wp-cli.php index d2335c3cb1..0c3f1b569e 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -181,7 +181,7 @@ private function _create_network_alias() { /** * Index all posts for a site or network wide * - * @synopsis [--setup] [--network-wide] [--posts-per-page] [--no-bulk] [--offset] [--show-bulk-errors] [--post-type] [--keep-active] + * @synopsis [--setup] [--network-wide] [--posts-per-page] [--nobulk] [--offset] [--show-bulk-errors] [--post-type] [--keep-active] * * @param array $args * @@ -190,8 +190,6 @@ private function _create_network_alias() { * @param array $assoc_args */ public function index( $args, $assoc_args ) { - $defaults = array( 'bulk' => true ); - $assoc_args = wp_parse_args( $assoc_args, $defaults ); $this->_connect_check(); if ( ! empty( $assoc_args['posts-per-page'] ) ) { @@ -304,7 +302,11 @@ private function _index_helper( $args ) { $synced = 0; $errors = array(); - $no_bulk = ! $args['bulk']; + $no_bulk = false; + + if ( isset( $args['nobulk'] ) ) { + $no_bulk = true; + } $show_bulk_errors = false; From 63646254cb445540bc6a0b51c8acfb0aad15448c Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 1 Feb 2016 10:53:58 -0700 Subject: [PATCH 088/117] Make sure we use the proper case on Elasticsearch. --- classes/class-ep-api.php | 24 ++++++++++++------------ classes/class-ep-settings.php | 6 +++--- includes/settings/status.php | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index 2e57d03a90..76775efb13 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -193,7 +193,7 @@ public function search( $args, $scope = 'current' ) { * @since 1.6.0 * * @param array $results The unfiltered search results. - * @param object $response The response body retrieved from ElasticSearch. + * @param object $response The response body retrieved from Elasticsearch. */ return apply_filters( 'ep_search_results_array', array( 'found_posts' => $response['hits']['total'], 'posts' => $posts ), $response ); @@ -1095,7 +1095,7 @@ public function format_args( $args ) { } elseif ( 'like' === $compare ) { $meta_key_path = 'meta.' . $single_meta_query['key'] . '.value'; } elseif ( $type && isset( $meta_query_type_mapping[ $type ] ) ) { - // Map specific meta field types to different ElasticSearch core types + // Map specific meta field types to different Elasticsearch core types $meta_key_path = 'meta.' . $single_meta_query['key'] . '.' . $meta_query_type_mapping[ $type ]; } elseif ( in_array( $compare, array( '>=', '<=', '>', '<' ) ) ) { $meta_key_path = 'meta.' . $single_meta_query['key'] . '.double'; @@ -1751,7 +1751,7 @@ public function remote_request( $path, $args = array() ) { * * @since 1.9 * - * @param object $response JSON decoded response from ElasticSearch. + * @param object $response JSON decoded response from Elasticsearch. * * @return array Contains the status message or the returned statistics. */ @@ -1794,9 +1794,9 @@ public function parse_api_response( $response ) { } /** - * Get ElasticSearch plugins + * Get Elasticsearch plugins * - * Gets a list of available ElasticSearch plugins. + * Gets a list of available Elasticearch plugins. * * @since 1.9 * @@ -1816,7 +1816,7 @@ public function get_plugins() { return array( 'status' => false, - 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + 'msg' => esc_html__( 'Elasticsearch Host is not available.', 'elasticpress' ), ); } @@ -1863,7 +1863,7 @@ public function get_plugins() { /** * Get cluster status * - * Retrieves cluster stats from ElasticSearch. + * Retrieves cluster stats from Elasticsearch. * * @since 1.9 * @@ -1875,7 +1875,7 @@ public function get_cluster_status() { return array( 'status' => false, - 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + 'msg' => esc_html__( 'Elasticsearch Host is not available.', 'elasticpress' ), ); } else { @@ -1901,7 +1901,7 @@ public function get_cluster_status() { /** * Get index status * - * Retrieves index stats from ElasticSearch. + * Retrieves index stats from Elasticsearch. * * @since 1.9 * @@ -1915,7 +1915,7 @@ public function get_index_status( $blog_id = null ) { return array( 'status' => false, - 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + 'msg' => esc_html__( 'Elasticsearch Host is not available.', 'elasticpress' ), ); } else { @@ -1950,7 +1950,7 @@ public function get_index_status( $blog_id = null ) { } /** - * Retrieves search stats from ElasticSearch. + * Retrieves search stats from Elasticsearch. * * Retrieves various search statistics from the ES server. * @@ -1966,7 +1966,7 @@ public function get_search_status( $blog_id = null ) { return array( 'status' => false, - 'msg' => esc_html__( 'ElasticSearch Host is not available.', 'elasticpress' ), + 'msg' => esc_html__( 'Elasticsearch Host is not available.', 'elasticpress' ), ); } else { diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 5d32a8a525..adf806c8ba 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -177,7 +177,7 @@ public function action_admin_init() { 'callback_ep_settings_section_main', ), 'elasticpress' ); - add_settings_field( 'ep_host', esc_html__( 'ElasticSearch Host:', 'elasticpress' ), array( + add_settings_field( 'ep_host', esc_html__( 'Elasticsearch Host:', 'elasticpress' ), array( $this, 'setting_callback_host', ), 'elasticpress', 'ep_settings_section_main' ); @@ -186,7 +186,7 @@ public function action_admin_init() { if ( $stats['status'] && ! is_wp_error( ep_check_host() ) ) { - add_settings_field( 'ep_activate', esc_html__( 'Use ElasticSearch:', 'elasticpress' ), array( + add_settings_field( 'ep_activate', esc_html__( 'Use Elasticsearch:', 'elasticpress' ), array( $this, 'setting_callback_activate', ), 'elasticpress', 'ep_settings_section_main' ); @@ -417,7 +417,7 @@ public function settings_page() { */ public function callback_ep_settings_section_main() { - echo '

    ' . esc_html__( 'ElasticSearch Integration Options', 'elasticpress' ) . '

    '; + echo '

    ' . esc_html__( 'Elasticsearch Integration Options', 'elasticpress' ) . '

    '; } diff --git a/includes/settings/status.php b/includes/settings/status.php index d172736091..d1a9668803 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -25,7 +25,7 @@
    :
    - + @@ -48,7 +48,7 @@ printf( '

    %s

    ', esc_html__( 'Plugin Status', 'elasticpress' ) ); ?>

    + style="color:green;">

    From ffbe95b46f0d8615d5d6615593c101aff54e4024 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 1 Feb 2016 11:06:54 -0700 Subject: [PATCH 089/117] If a host hasn't been set, has been set but can't be contacted, or if ElasticPress integration has not been enabled, don't show the index button, as using it causes JS errors in those situations. --- includes/settings/index.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/settings/index.php b/includes/settings/index.php index 88964977bd..e5fd117e33 100644 --- a/includes/settings/index.php +++ b/includes/settings/index.php @@ -10,12 +10,21 @@ */ ?>

    - + + + + + + + + +

    From f0b18cebcf4d86b639241ae2aeef5904bc104a7d Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 1 Feb 2016 11:21:04 -0700 Subject: [PATCH 090/117] Update POT file, switch to using grunt-wp-i18n to generate this. --- Gruntfile.js | 38 ++----- lang/elasticpress.pot | 245 ++++++++++++++++++++++++++++++------------ package.json | 2 +- 3 files changed, 188 insertions(+), 97 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 53cb8c43d8..350afce87d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -78,34 +78,16 @@ module.exports = function ( grunt ) { }, - pot : { - - options : { - text_domain : 'elasticpress', - dest : 'lang/', - keywords : [ //WordPress localisation functions - '__:1', - '_e:1', - '_x:1,2c', - 'esc_html__:1', - 'esc_html_e:1', - 'esc_html_x:1,2c', - 'esc_attr__:1', - 'esc_attr_e:1', - 'esc_attr_x:1,2c', - '_ex:1,2c', - '_n:1,2', - '_nx:1,2,4c', - '_n_noop:1,2', - '_nx_noop:1,2,3c' - ] - }, - - files : { - src : ['**/*.php'], //Parse all php files - expand : true + makepot: { + main: { + options: { + domainPath: 'lang', + mainFile: 'elasticpress.php', + potFilename: 'elasticpress.pot', + type: 'wp-plugin', + potHeaders: true + } } - }, watch : { @@ -140,6 +122,6 @@ module.exports = function ( grunt ) { ); // A very basic default task. - grunt.registerTask ( 'default', ['uglify:production', 'sass', 'autoprefixer', 'cssmin', 'pot'] ); + grunt.registerTask ( 'default', ['uglify:production', 'sass', 'autoprefixer', 'cssmin', 'makepot'] ); }; \ No newline at end of file diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index c5d3f96543..7179a4b376 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -1,25 +1,19 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the ElasticPress package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy +# Copyright (C) 2016 Aaron Holbrook, Taylor Lovett, Matt Gross, 10up +# This file is distributed under the GPLv2 or later. msgid "" msgstr "" -"Project-Id-Version: ElasticPress 1.0.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-01-27 17:02-0500\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" +"Project-Id-Version: ElasticPress 1.8\n" +"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/elasticpress\n" +"POT-Creation-Date: 2016-02-01 18:17:04+00:00\n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" +"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"X-Generator: grunt-wp-i18n 0.5.3\n" #: bin/wp-cli.php:55 -#, php-format msgid "Adding mapping for site %d..." msgstr "" @@ -36,7 +30,6 @@ msgid "Adding mapping..." msgstr "" #: bin/wp-cli.php:109 -#, php-format msgid "Deleting index for site %d..." msgstr "" @@ -56,11 +49,11 @@ msgstr "" msgid "Index delete failed" msgstr "" -#: bin/wp-cli.php:147 bin/wp-cli.php:257 +#: bin/wp-cli.php:147 bin/wp-cli.php:265 msgid "Recreating network alias..." msgstr "" -#: bin/wp-cli.php:154 bin/wp-cli.php:281 +#: bin/wp-cli.php:154 bin/wp-cli.php:289 msgid "Done!" msgstr "" @@ -68,56 +61,54 @@ msgstr "" msgid "An error occurred" msgstr "" -#: bin/wp-cli.php:237 +#: bin/wp-cli.php:245 msgid "Indexing posts network-wide..." msgstr "" -#: bin/wp-cli.php:248 bin/wp-cli.php:269 -#, php-format +#: bin/wp-cli.php:256 bin/wp-cli.php:277 msgid "Number of posts indexed on site %d: %d" msgstr "" -#: bin/wp-cli.php:251 bin/wp-cli.php:272 -#, php-format +#: bin/wp-cli.php:259 bin/wp-cli.php:280 msgid "Number of post index errors on site %d: %d" msgstr "" -#: bin/wp-cli.php:261 -#, php-format +#: bin/wp-cli.php:269 msgid "Total number of posts indexed: %d" msgstr "" -#: bin/wp-cli.php:265 +#: bin/wp-cli.php:273 msgid "Indexing posts..." msgstr "" -#: bin/wp-cli.php:276 +#: bin/wp-cli.php:284 msgid "Total time elapsed: " msgstr "" -#: bin/wp-cli.php:536 +#: bin/wp-cli.php:544 msgid "" "The following posts failed to index:\r\n" "\r\n" msgstr "" -#: bin/wp-cli.php:685 classes/class-ep-config.php:174 +#: bin/wp-cli.php:693 classes/class-ep-config.php:174 msgid "EP_HOST is not defined! Check wp-config.php" msgstr "" -#: bin/wp-cli.php:689 classes/class-ep-config.php:178 +#: bin/wp-cli.php:697 classes/class-ep-config.php:178 msgid "Unable to reach Elasticsearch Server! Check that service is running." msgstr "" #: classes/class-ep-api.php:1764 msgid "" -"Invalid response from ElasticPress server. Please contact your administrator." +"Invalid response from ElasticPress server. Please contact your " +"administrator." msgstr "" #: classes/class-ep-api.php:1777 msgid "" -"Site not indexed.

    Please run: wp elasticpress index --setup --" -"network-wide using WP-CLI. Or use the index button on the left of " +"Site not indexed.

    Please run: wp elasticpress index --setup " +"--network-wide using WP-CLI. Or use the index button on the left of " "this screen.

    " msgstr "" @@ -129,7 +120,7 @@ msgstr "" #: classes/class-ep-api.php:1819 classes/class-ep-api.php:1878 #: classes/class-ep-api.php:1918 classes/class-ep-api.php:1969 -msgid "ElasticSearch Host is not available." +msgid "Elasticsearch Host is not available." msgstr "" #: classes/class-ep-config.php:65 classes/class-ep-config.php:90 @@ -189,10 +180,6 @@ msgstr "" msgid "Index Status" msgstr "" -#: classes/class-ep-index-worker.php:371 -msgid "The following posts failed to index:" -msgstr "" - #: classes/class-ep-index-worker.php:398 msgid ": ElasticPress Index Errors" msgstr "" @@ -205,11 +192,11 @@ msgstr "" msgid "items indexed in " msgstr "" -#: classes/class-ep-settings.php:124 includes/settings/index.php:14 +#: classes/class-ep-settings.php:124 includes/settings/index.php:15 msgid "Running Index..." msgstr "" -#: classes/class-ep-settings.php:125 includes/settings/index.php:14 +#: classes/class-ep-settings.php:125 includes/settings/index.php:15 msgid "Run Index" msgstr "" @@ -228,42 +215,45 @@ msgid "Index complete Refresh the stats" msgstr "" #: classes/class-ep-settings.php:180 -msgid "ElasticSearch Host:" +msgid "Elasticsearch Host:" msgstr "" #: classes/class-ep-settings.php:189 -msgid "Use ElasticSearch:" +msgid "Use Elasticsearch:" msgstr "" #: classes/class-ep-settings.php:420 -msgid "ElasticSearch Integration Options" +msgid "Elasticsearch Integration Options" msgstr "" #: classes/class-ep-wp-date-query.php:488 -#, php-format -msgid "" -"Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s." +#. translators: Date query invalid date message: 1: invalid value, 2: type of +#. value, 3: minimum valid value, 4: maximum valid value +msgid "Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s." msgstr "" #: classes/class-ep-wp-date-query.php:518 -#, php-format +#. translators: 1: year, 2: month, 3: day of month msgid "" "The following values do not describe a valid date: year %1$s, month %2$s, " "day %3$s." msgstr "" #: classes/class-ep-wp-date-query.php:535 -#, php-format -msgid "" -"The following values do not describe a valid date: month %1$s, day %2$s." +#. translators: 1: month, 2: day of month +msgid "The following values do not describe a valid date: month %1$s, day %2$s." msgstr "" -#: includes/settings-page.php:13 -msgid "ElasticPress" +#: includes/settings/index.php:23 +msgid "ElasticPress needs to be enabled to run an index." +msgstr "" + +#: includes/settings/index.php:26 +msgid "A proper host must be set before running an index." msgstr "" #: includes/settings/status.php:28 -msgid "ElasticSearch Host" +msgid "Elasticsearch Host" msgstr "" #: includes/settings/status.php:33 @@ -283,7 +273,7 @@ msgid "Plugin Status" msgstr "" #: includes/settings/status.php:51 -msgid "Connected to ElasticSearch." +msgid "Connected to Elasticsearch." msgstr "" #: includes/settings/status.php:56 @@ -292,8 +282,8 @@ msgstr "" #: includes/settings/status.php:61 msgid "" -"ElasticPress is not enabled and cannot override WP queries. You can activate " -"it on the form to the left." +"ElasticPress is not enabled and cannot override WP queries. You can " +"activate it on the form to the left." msgstr "" #: includes/settings/status.php:66 @@ -332,22 +322,141 @@ msgstr "" msgid "ERROR:" msgstr "" -#: node_modules/grunt-pot/test/fixtures/some-file.php:3 -msgid "I'm a translatable string." +#. Plugin Name of the plugin/theme +msgid "ElasticPress" msgstr "" -#: node_modules/grunt-pot/test/fixtures/some-other-file.php:4 -msgid "Me too" +#: vendor/wp-cli/wp-cli/php/WP_CLI/CommandWithTerms.php:211 +msgid "Invalid Taxonomy" msgstr "" -#: node_modules/grunt-pot/test/fixtures/some-other-file.php:7 -#, php-format -msgid "I have %d apple" -msgid_plural "I have %d apples" +#: vendor/wp-cli/wp-cli/php/WP_CLI/CommandWithUpgrade.php:413 +msgid " Try again" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/WP_CLI/CommandWithUpgrade.php:418 +msgid "API error. Try Again." +msgstr "" + +#: vendor/wp-cli/wp-cli/php/commands/core.php:638 +msgid "Wildcard DNS may not be configured correctly." +msgstr "" + +#: vendor/wp-cli/wp-cli/php/commands/cron.php:339 +msgid "%s year" +msgid_plural "%s years" msgstr[0] "" msgstr[1] "" -#. / TRANSLATORS: This should be translated as a shorthand for YEAR-MONTH-DAY using 4, 2 and 2 digits. -#: node_modules/grunt-pot/test/fixtures/some-other-file.php:16 -msgid "yyyy-mm-dd" +#: vendor/wp-cli/wp-cli/php/commands/cron.php:340 +msgid "%s month" +msgid_plural "%s months" +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/cron.php:341 +msgid "%s week" +msgid_plural "%s weeks" +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/cron.php:342 +msgid "%s day" +msgid_plural "%s days" +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/cron.php:343 +msgid "%s hour" +msgid_plural "%s hours" +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/cron.php:344 +msgid "%s minute" +msgid_plural "%s minutes" +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/cron.php:345 +msgid "%s second" +msgid_plural "%s seconds" +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/export.php:264 +msgid "Invalid start ID: %d" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/commands/media.php:65 +msgid "image" +msgid_plural "images" +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/media.php:75 +msgid "An error occurred with image regeneration." +msgid_plural "An error occurred regenerating one or more images." +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/media.php:79 +msgid "the image" +msgid_plural "all images" +msgstr[0] "" +msgstr[1] "" + +#: vendor/wp-cli/wp-cli/php/commands/site.php:99 +msgid "Uncategorized" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/export/class-wp-export-query.php:327 +msgid "Term is missing a parent: %s (%d)" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/export/writers.php:35 +#: vendor/wp-cli/wp-cli/php/export/writers.php:39 +msgid "Export Error" msgstr "" + +#: vendor/wp-cli/wp-cli/php/export/writers.php:95 +#: vendor/wp-cli/wp-cli/php/export/writers.php:159 +msgid "WP Export: error opening %s for writing." +msgstr "" + +#: vendor/wp-cli/wp-cli/php/export/writers.php:112 +#: vendor/wp-cli/wp-cli/php/export/writers.php:147 +msgid "WP Export: error writing to export file." +msgstr "" + +#: vendor/wp-cli/wp-cli/php/utils-wp.php:122 +msgid "Inactive Widgets" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/utils-wp.php:125 +msgid "Drag widgets here to remove them from the sidebar but keep their settings." +msgstr "" + +#. Description of the plugin/theme +msgid "Integrate WordPress search with Elasticsearch" +msgstr "" + +#. Author of the plugin/theme +msgid "Aaron Holbrook, Taylor Lovett, Matt Gross, 10up" +msgstr "" + +#. Author URI of the plugin/theme +msgid "http://10up.com" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/commands/core.php:451 +#: vendor/wp-cli/wp-cli/php/commands/core.php:499 +msgctxt "Default network name" +msgid "%s Sites" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/commands/site.php:102 +#. translators: Default category slug +msgctxt "Default category slug" +msgid "Uncategorized" +msgstr "" \ No newline at end of file diff --git a/package.json b/package.json index 4eb1ada3e4..a914017f3f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "grunt-contrib-cssmin": "*", "load-grunt-tasks": "*", "grunt-autoprefixer": "*", - "grunt-pot": "*" + "grunt-wp-i18n": "^0.5.3" }, "author": "10up", "repository": { From 8198123fcbc04c905118a538977e8d1af143027b Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 1 Feb 2016 11:22:33 -0700 Subject: [PATCH 091/117] Remove unneeded namespacing. --- classes/class-ep-index-worker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index 38c07edc73..46d3ea2e24 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -123,7 +123,7 @@ protected function _index_helper() { 'ignore_sticky_posts' => true, ) ); - $query = new \WP_Query( $args ); + $query = new WP_Query( $args ); if ( $query->have_posts() ) { From f43e1c892ec70156ef10abbb900bfa0c43458189 Mon Sep 17 00:00:00 2001 From: rossluebe Date: Wed, 23 Dec 2015 14:03:16 -0500 Subject: [PATCH 092/117] Sync searchable_post_types with indexable_post_types. --- classes/class-ep-wp-query-integration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-ep-wp-query-integration.php b/classes/class-ep-wp-query-integration.php index 0031b8a438..4d1d2a2251 100644 --- a/classes/class-ep-wp-query-integration.php +++ b/classes/class-ep-wp-query-integration.php @@ -226,7 +226,7 @@ public function filter_posts_request( $request, $query ) { * To follow WordPress conventions, * make sure we only search 'searchable' post types */ - $searchable_post_types = get_post_types( array( 'exclude_from_search' => false ) ); + $searchable_post_types = ep_get_indexable_post_types(); // If we have no searchable post types, there's no point going any further if ( empty( $searchable_post_types ) ) { From f4bcc8869f9fc7f735cc33e7627e832c3ecf362f Mon Sep 17 00:00:00 2001 From: rossluebe Date: Mon, 8 Feb 2016 12:00:09 -0500 Subject: [PATCH 093/117] Make searchable post types it's own function and filter. --- classes/class-ep-config.php | 12 ++++++++++++ classes/class-ep-wp-query-integration.php | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index 613bfc11f9..98f50ded5e 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -127,6 +127,18 @@ public function get_indexable_post_types() { return apply_filters( 'ep_indexable_post_types', $post_types ); } + /** + * Returns searchable post types for the current site + * + * @since 1.9 + * @return mixed|void + */ + public function get_searchable_post_types() { + $post_types = get_post_types( array( 'exclude_from_search' => false ) ); + + return apply_filters( 'ep_searchable_post_types', $post_types ); + } + /** * Return indexable post_status for the current site * diff --git a/classes/class-ep-wp-query-integration.php b/classes/class-ep-wp-query-integration.php index 4d1d2a2251..b5e72b958c 100644 --- a/classes/class-ep-wp-query-integration.php +++ b/classes/class-ep-wp-query-integration.php @@ -226,7 +226,7 @@ public function filter_posts_request( $request, $query ) { * To follow WordPress conventions, * make sure we only search 'searchable' post types */ - $searchable_post_types = ep_get_indexable_post_types(); + $searchable_post_types = ep_get_searchable_post_types(); // If we have no searchable post types, there's no point going any further if ( empty( $searchable_post_types ) ) { From 7ef6b07b223b3d8f2e673683a1fa0d865d7e0fb4 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 8 Feb 2016 15:21:45 -0700 Subject: [PATCH 094/117] Remove the System Stats section. --- includes/settings/status.php | 44 +----------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/includes/settings/status.php b/includes/settings/status.php index d1a9668803..8694690a81 100644 --- a/includes/settings/status.php +++ b/includes/settings/status.php @@ -15,8 +15,7 @@ $site_stats_id = get_current_blog_id(); } -$stats = ep_get_index_status( $site_stats_id ); -$search_stats = ep_get_search_status( $site_stats_id ); +$stats = ep_get_index_status( $site_stats_id ); echo '
    '; @@ -63,47 +62,6 @@ - %s', esc_html__( 'System Stats', 'elasticpress' ) ); ?> - -
    - - %s', esc_html__( 'Search Stats', 'elasticpress' ) ); ?> - -
      -
    • - query_total ); ?> -
    • -
    • - query_time_in_millis ); ?> - ms -
    • -
    • - fetch_total ); ?> -
      -
    • - fetch_time_in_millis ); ?> - ms -
    • -
    - -
    - -
    - - %s', esc_html__( 'Index Stats', 'elasticpress' ) ); ?> - -
      -
    • - index_total ); ?> -
    • -
    • - index_time_in_millis ); ?> - ms -
    • -
    - -
    - Date: Mon, 8 Feb 2016 15:28:43 -0700 Subject: [PATCH 095/117] Remove alerts on ajax errors, as it just gets confusing. Recreate our POT file. --- assets/js/elasticpress-admin.js | 10 ------ assets/js/elasticpress-admin.min.js | 2 +- lang/elasticpress.pot | 52 +++++++++++++---------------- 3 files changed, 25 insertions(+), 39 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index dcdf6d61cc..ee6f70c877 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -66,11 +66,6 @@ jQuery( document ).ready( function ( $ ) { url : ajaxurl, type : 'POST', data : data, - error : function ( request ) { - - alert( request.responseText ); - - }, complete : function ( response ) { // Handle returned error appropriately. @@ -195,11 +190,6 @@ jQuery( document ).ready( function ( $ ) { url : ajaxurl, type : 'POST', data : data, - error : function ( request ) { - - alert( request.responseText ); - - }, complete : function ( response ) { $( '#ep_site_stats' ).html( response.responseJSON.data ); diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index b64bf68a01..3e3ab67142 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.text(ep.synced_posts+"/"+ep.total_posts+" items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,error:function(a){alert(a.responseText)},complete:function(k){if("undefined"==typeof k.responseJSON||"undefined"==typeof k.responseJSON.data)a("#progressstats").text(ep.failed_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),a("#progressbar").fadeOut("slow");else{var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.text(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),b(!0,d))});var j=a("#ep_site_select");j.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,error:function(a){alert(a.responseText)},complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.text(ep.synced_posts+"/"+ep.total_posts+" items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,complete:function(k){if("undefined"==typeof k.responseJSON||"undefined"==typeof k.responseJSON.data)a("#progressstats").text(ep.failed_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),a("#progressbar").fadeOut("slow");else{var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.text(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),b(!0,d))});var j=a("#ep_site_select");j.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 7179a4b376..4b921d797a 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.8\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/elasticpress\n" -"POT-Creation-Date: 2016-02-01 18:17:04+00:00\n" +"POT-Creation-Date: 2016-02-08 22:22:16+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -144,35 +144,35 @@ msgstr "" msgid "Security error!" msgstr "" -#: classes/class-ep-index-gui.php:322 includes/settings/status.php:70 +#: classes/class-ep-index-gui.php:322 msgid "Search Stats" msgstr "" -#: classes/class-ep-index-gui.php:325 includes/settings/status.php:74 +#: classes/class-ep-index-gui.php:325 msgid "Total Queries:" msgstr "" -#: classes/class-ep-index-gui.php:328 includes/settings/status.php:77 +#: classes/class-ep-index-gui.php:328 msgid "Query Time:" msgstr "" -#: classes/class-ep-index-gui.php:331 includes/settings/status.php:81 +#: classes/class-ep-index-gui.php:331 msgid "Total Fetches:" msgstr "" -#: classes/class-ep-index-gui.php:334 includes/settings/status.php:84 +#: classes/class-ep-index-gui.php:334 msgid "Fetch Time:" msgstr "" -#: classes/class-ep-index-gui.php:339 includes/settings/status.php:93 +#: classes/class-ep-index-gui.php:339 msgid "Index Stats" msgstr "" -#: classes/class-ep-index-gui.php:342 includes/settings/status.php:97 +#: classes/class-ep-index-gui.php:342 msgid "Index Total:" msgstr "" -#: classes/class-ep-index-gui.php:345 includes/settings/status.php:100 +#: classes/class-ep-index-gui.php:345 msgid "Index Time:" msgstr "" @@ -252,73 +252,69 @@ msgstr "" msgid "A proper host must be set before running an index." msgstr "" -#: includes/settings/status.php:28 +#: includes/settings/status.php:27 msgid "Elasticsearch Host" msgstr "" -#: includes/settings/status.php:33 +#: includes/settings/status.php:32 msgid "" "Current host is set but cannot be contacted. Please contact the server " "administrator." msgstr "" -#: includes/settings/status.php:37 +#: includes/settings/status.php:36 msgid "" "A host has not been set or is set but cannot be contacted. You must set a " "proper host to continue." msgstr "" -#: includes/settings/status.php:48 +#: includes/settings/status.php:47 msgid "Plugin Status" msgstr "" -#: includes/settings/status.php:51 +#: includes/settings/status.php:50 msgid "Connected to Elasticsearch." msgstr "" -#: includes/settings/status.php:56 +#: includes/settings/status.php:55 msgid "ElasticPress can override WP search." msgstr "" -#: includes/settings/status.php:61 +#: includes/settings/status.php:60 msgid "" "ElasticPress is not enabled and cannot override WP queries. You can " "activate it on the form to the left." msgstr "" -#: includes/settings/status.php:66 -msgid "System Stats" -msgstr "" - -#: includes/settings/status.php:112 +#: includes/settings/status.php:70 msgid "Site Stats" msgstr "" -#: includes/settings/status.php:115 +#: includes/settings/status.php:73 msgid "Select a site:" msgstr "" -#: includes/settings/status.php:116 +#: includes/settings/status.php:74 msgid "Select" msgstr "" -#: includes/settings/status.php:151 +#: includes/settings/status.php:109 msgid "Cluster Stats" msgstr "" -#: includes/settings/status.php:161 +#: includes/settings/status.php:119 msgid "Disk Usage:" msgstr "" -#: includes/settings/status.php:165 +#: includes/settings/status.php:123 msgid "Disk Space Available:" msgstr "" -#: includes/settings/status.php:168 +#: includes/settings/status.php:126 msgid "Total Disk Space:" msgstr "" -#: includes/settings/status.php:181 +#: includes/settings/status.php:139 msgid "ERROR:" msgstr "" From 210df648f800f0abd5df9347e943298c36604582 Mon Sep 17 00:00:00 2001 From: rossluebe Date: Mon, 8 Feb 2016 17:33:54 -0500 Subject: [PATCH 096/117] Add `ep_get_searchable_post_type` declaration. --- classes/class-ep-config.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/class-ep-config.php b/classes/class-ep-config.php index 98f50ded5e..8d083387b5 100644 --- a/classes/class-ep-config.php +++ b/classes/class-ep-config.php @@ -285,6 +285,10 @@ function ep_get_indexable_post_types() { return EP_Config::factory()->get_indexable_post_types(); } +function ep_get_searchable_post_types() { + return EP_Config::factory()->get_searchable_post_types(); +} + function ep_get_indexable_post_status() { return EP_Config::factory()->get_indexable_post_status(); } From 8f5058f8973801c9029a13e01721ed86a680b988 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 9 Feb 2016 11:29:53 -0700 Subject: [PATCH 097/117] Don't call wp_cache_flush - clear $wp_object_cache->cache instead Calling wp_cache_flush will complety dump all items from an external object cache, and not all object cache implementations will actually clear the cache property on the wp_object_cache clas. This was added to get around the cache property being protected or private, so we just make sure its public before calling this. --- bin/wp-cli.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 0c3f1b569e..0394b4f2fc 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -381,7 +381,13 @@ private function _index_helper( $args ) { $wp_object_cache->group_ops = array(); $wp_object_cache->stats = array(); $wp_object_cache->memcache_debug = array(); - wp_cache_flush(); + + // Make sure this is a public property, before trying to clear it + $cache_property = new ReflectionProperty( $wp_object_cache, 'cache' ); + if ( $cache_property->isPublic() ) { + $wp_object_cache->cache = array(); + } + unset( $cache_property ); if ( is_callable( $wp_object_cache, '__remoteset' ) ) { call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important From 74abc5600c5cde49e90ceb97736d257a91b0eb49 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 9 Feb 2016 11:30:30 -0700 Subject: [PATCH 098/117] Clear $wp_actions after each batch to help with memory usage --- bin/wp-cli.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 0394b4f2fc..e3375b93c0 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -298,7 +298,7 @@ public function index( $args, $assoc_args ) { * @return array */ private function _index_helper( $args ) { - global $wpdb, $wp_object_cache; + global $wpdb, $wp_object_cache, $wp_actions; $synced = 0; $errors = array(); @@ -392,6 +392,9 @@ private function _index_helper( $args ) { if ( is_callable( $wp_object_cache, '__remoteset' ) ) { call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important } + + // Prevent wp_actions from growing out of control + $wp_actions = array(); } } From d81cd9fd7cabddb580784c3f5fb62e2e6b34d424 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 9 Feb 2016 11:46:14 -0700 Subject: [PATCH 099/117] wp_cache_flush after each batch when not using external object cache WordPress core stores all cache data in the cache property, but its marked as private. IN these cases, we can call flush() and it resets this value, keeping memory usage under control --- bin/wp-cli.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index e3375b93c0..4f13b39e30 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -389,6 +389,14 @@ private function _index_helper( $args ) { } unset( $cache_property ); + /* + * In the case where we're not using an external object cache, we need to call flush on the default + * WordPress object cache class to clear the values from the cache property + */ + if ( ! wp_using_ext_object_cache() ) { + wp_cache_flush(); + } + if ( is_callable( $wp_object_cache, '__remoteset' ) ) { call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important } From ea34f0478428403050a9c6ca22f0a361de2c96d5 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 9 Feb 2016 11:57:06 -0700 Subject: [PATCH 100/117] Move code to prevent running out of memory to stop_the_insanity method --- bin/wp-cli.php | 68 ++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 4f13b39e30..02e12a2325 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -298,7 +298,6 @@ public function index( $args, $assoc_args ) { * @return array */ private function _index_helper( $args ) { - global $wpdb, $wp_object_cache, $wp_actions; $synced = 0; $errors = array(); @@ -375,35 +374,7 @@ private function _index_helper( $args ) { usleep( 500 ); // Avoid running out of memory - $wpdb->queries = array(); - - if ( is_object( $wp_object_cache ) ) { - $wp_object_cache->group_ops = array(); - $wp_object_cache->stats = array(); - $wp_object_cache->memcache_debug = array(); - - // Make sure this is a public property, before trying to clear it - $cache_property = new ReflectionProperty( $wp_object_cache, 'cache' ); - if ( $cache_property->isPublic() ) { - $wp_object_cache->cache = array(); - } - unset( $cache_property ); - - /* - * In the case where we're not using an external object cache, we need to call flush on the default - * WordPress object cache class to clear the values from the cache property - */ - if ( ! wp_using_ext_object_cache() ) { - wp_cache_flush(); - } - - if ( is_callable( $wp_object_cache, '__remoteset' ) ) { - call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important - } - - // Prevent wp_actions from growing out of control - $wp_actions = array(); - } + $this->stop_the_insanity(); } if ( ! $no_bulk ) { @@ -700,6 +671,43 @@ public function is_activated() { } } + /** + * Resets some values to reduce memory footprint. + */ + public function stop_the_insanity() { + global $wpdb, $wp_object_cache, $wp_actions; + + $wpdb->queries = array(); + + if ( is_object( $wp_object_cache ) ) { + $wp_object_cache->group_ops = array(); + $wp_object_cache->stats = array(); + $wp_object_cache->memcache_debug = array(); + + // Make sure this is a public property, before trying to clear it + $cache_property = new ReflectionProperty( $wp_object_cache, 'cache' ); + if ( $cache_property->isPublic() ) { + $wp_object_cache->cache = array(); + } + unset( $cache_property ); + + /* + * In the case where we're not using an external object cache, we need to call flush on the default + * WordPress object cache class to clear the values from the cache property + */ + if ( ! wp_using_ext_object_cache() ) { + wp_cache_flush(); + } + + if ( is_callable( $wp_object_cache, '__remoteset' ) ) { + call_user_func( array( $wp_object_cache, '__remoteset' ) ); // important + } + } + + // Prevent wp_actions from growing out of control + $wp_actions = array(); + } + /** * Provide better error messaging for common connection errors * From 9d9db4d02ddfbeba6b6fe7f852ee70e07bf4b1d9 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Tue, 9 Feb 2016 16:29:59 -0700 Subject: [PATCH 101/117] Fix a composer error causing our Travis tests to fail. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8bab2c180e..5c242fb4d7 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "codeclimate/php-test-reporter": "dev-master", "phpunit/phpunit": "*@stable", - "wp-cli/wp-cli": "dev-master" + "wp-cli/wp-cli": "*@stable" }, "config": { "platform": { From 0770d544d097d17e2961755b6646545c5d18c3a6 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Tue, 9 Feb 2016 16:49:48 -0700 Subject: [PATCH 102/117] Bring over cache indexing fixes from #442, to our admin gui. --- classes/class-ep-index-worker.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index 46d3ea2e24..aa94eed2b7 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -168,13 +168,22 @@ protected function _index_helper() { $wp_object_cache->group_ops = array(); $wp_object_cache->stats = array(); $wp_object_cache->memcache_debug = array(); - $wp_object_cache->cache = array(); + + // Make sure this is a public property, before trying to clear it + $cache_property = new ReflectionProperty( $wp_object_cache, 'cache' ); + if ( $cache_property->isPublic() ) { + $wp_object_cache->cache = array(); + } + unset( $cache_property ); if ( is_callable( array( $wp_object_cache, '__remoteset' ) ) ) { call_user_func( array( $wp_object_cache, '__remoteset' ) ); // Important. } } + // Prevent wp_actions from growing out of control + $wp_actions = array(); + set_transient( 'ep_index_offset', $offset, 600 ); set_transient( 'ep_index_synced', $synced, 600 ); From dd3e89b7a3a29e589e5ec245c7e3d0599d6e901d Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Wed, 10 Feb 2016 13:28:41 +0000 Subject: [PATCH 103/117] Reduce memory consumption during indexing --- bin/wp-cli.php | 8 +++++++- classes/class-ep-api.php | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 02e12a2325..a3eeebac6b 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -332,6 +332,11 @@ private function _index_helper( $args ) { $post_type = array_map( 'trim', $post_type ); } + /** + * Create WP_Query here and reuse it in the loop to avoid high memory consumption. + */ + $query = new WP_Query(); + while ( true ) { $args = apply_filters( 'ep_index_posts_args', array( @@ -343,7 +348,7 @@ private function _index_helper( $args ) { 'orderby' => array( 'ID' => 'DESC' ), ) ); - $query = new WP_Query( $args ); + $query->query( $args ); if ( $query->have_posts() ) { @@ -375,6 +380,7 @@ private function _index_helper( $args ) { // Avoid running out of memory $this->stop_the_insanity(); + } if ( ! $no_bulk ) { diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index 76775efb13..2b71a2efbe 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -1711,7 +1711,7 @@ public function remote_request( $path, $args = array() ) { if ( isset( $args['blocking'] ) && false === $args['blocking' ] ) { $query['blocking'] = true; $query['request'] = $request; - $this->queries[] = $query; + $this->_add_query_log( $query ); return $request; } @@ -1724,7 +1724,7 @@ public function remote_request( $path, $args = array() ) { if ( is_wp_error( $host ) ) { $query['failed_hosts'][] = $host; $query['time_finish'] = microtime( true ); - $this->queries[] = $query; + $this->_add_query_log( $query ); return $host; } @@ -1738,7 +1738,7 @@ public function remote_request( $path, $args = array() ) { $query['request'] = $request; $query['url'] = $request_url; $query['host'] = $host; - $this->queries[] = $query; + $this->_add_query_log( $query ); return $request; @@ -2030,6 +2030,19 @@ public function process_site_mappings() { } + /** + * Query logging. Don't log anything when WP_DEBUG is not enabled. + * + * @param array $query Query. + * + * @return void Method does not return. + */ + protected function _add_query_log( $query ) { + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + $this->queries[] = $query; + } + } + } EP_API::factory(); From 6378c818c666a4462b0287f6781cba90a7aa6164 Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Wed, 10 Feb 2016 22:34:36 +0000 Subject: [PATCH 104/117] Avoid caching query results. --- bin/wp-cli.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index a3eeebac6b..2f76b7e6cb 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -340,14 +340,16 @@ private function _index_helper( $args ) { while ( true ) { $args = apply_filters( 'ep_index_posts_args', array( - 'posts_per_page' => $posts_per_page, - 'post_type' => $post_type, - 'post_status' => ep_get_indexable_post_status(), - 'offset' => $offset, - 'ignore_sticky_posts' => true, - 'orderby' => array( 'ID' => 'DESC' ), + 'posts_per_page' => $posts_per_page, + 'post_type' => $post_type, + 'post_status' => ep_get_indexable_post_status(), + 'offset' => $offset, + 'ignore_sticky_posts' => true, + 'orderby' => array( 'ID' => 'DESC' ), + 'cache_results ' => false, + 'update_post_meta_cache' => false, + 'update_post_term_cache' => false, ) ); - $query->query( $args ); if ( $query->have_posts() ) { @@ -408,6 +410,7 @@ private function queue_post( $post_id, $bulk_trigger, $show_bulk_errors = false static $killed_post_count = 0; $killed_post = false; + $post_args = ep_prepare_post( $post_id ); // Mimic EP_Sync_Manager::sync_post( $post_id ), otherwise posts can slip From 622dade9e6bd7865a33bef55f346ed28c6af9918 Mon Sep 17 00:00:00 2001 From: Lukas Pawlik Date: Thu, 11 Feb 2016 02:38:59 +0000 Subject: [PATCH 105/117] Let WP_Query be destructed by GC --- bin/wp-cli.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 2f76b7e6cb..9e8266785d 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -684,7 +684,7 @@ public function is_activated() { * Resets some values to reduce memory footprint. */ public function stop_the_insanity() { - global $wpdb, $wp_object_cache, $wp_actions; + global $wpdb, $wp_object_cache, $wp_actions, $wp_filter; $wpdb->queries = array(); @@ -715,6 +715,21 @@ public function stop_the_insanity() { // Prevent wp_actions from growing out of control $wp_actions = array(); + + // WP_Query class adds filter get_term_metadata using its own instance + // what prevents WP_Query class from being destructed by PHP gc. + // if ( $q['update_post_term_cache'] ) { + // add_filter( 'get_term_metadata', array( $this, 'lazyload_term_meta' ), 10, 2 ); + // } + // It's high memory consuming as WP_Query instance holds all query results inside itself + // and in theory $wp_filter will not stop growing until Out Of Memory exception occurs. + if ( isset( $wp_filter['get_term_metadata'][10] ) ) { + foreach ( $wp_filter['get_term_metadata'][10] as $hook => $content ) { + if ( preg_match( '#^[0-9a-f]{32}lazyload_term_meta$#', $hook ) ) { + unset( $wp_filter['get_term_metadata'][10][$hook] ); + } + } + } } /** From 0c9db2c92856d4ee455d2133113634b61b655d0e Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Wed, 10 Feb 2016 21:17:12 -0700 Subject: [PATCH 106/117] Add a try/catch block around our ReflectionProperty, as it throws an exception in some cases. --- classes/class-ep-index-worker.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/classes/class-ep-index-worker.php b/classes/class-ep-index-worker.php index aa94eed2b7..c37fc19179 100644 --- a/classes/class-ep-index-worker.php +++ b/classes/class-ep-index-worker.php @@ -170,11 +170,14 @@ protected function _index_helper() { $wp_object_cache->memcache_debug = array(); // Make sure this is a public property, before trying to clear it - $cache_property = new ReflectionProperty( $wp_object_cache, 'cache' ); - if ( $cache_property->isPublic() ) { - $wp_object_cache->cache = array(); + try { + $cache_property = new ReflectionProperty( $wp_object_cache, 'cache' ); + if ( $cache_property->isPublic() ) { + $wp_object_cache->cache = array(); + } + unset( $cache_property ); + } catch ( ReflectionException $e ) { } - unset( $cache_property ); if ( is_callable( array( $wp_object_cache, '__remoteset' ) ) ) { call_user_func( array( $wp_object_cache, '__remoteset' ) ); // Important. From 22e6965e0acc8f983153006832ea30c15cdfd8b7 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 11 Feb 2016 16:37:57 -0700 Subject: [PATCH 107/117] Wrap ReflectionProperty in try/catch block to avoid exceptions that break on certain cache systems. --- bin/wp-cli.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 02e12a2325..37dc0629c9 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -685,11 +685,14 @@ public function stop_the_insanity() { $wp_object_cache->memcache_debug = array(); // Make sure this is a public property, before trying to clear it - $cache_property = new ReflectionProperty( $wp_object_cache, 'cache' ); - if ( $cache_property->isPublic() ) { - $wp_object_cache->cache = array(); + try { + $cache_property = new ReflectionProperty( $wp_object_cache, 'cache' ); + if ( $cache_property->isPublic() ) { + $wp_object_cache->cache = array(); + } + unset( $cache_property ); + } catch ( ReflectionException $e ) { } - unset( $cache_property ); /* * In the case where we're not using an external object cache, we need to call flush on the default From 02c4b15b1c7417ea10d9d4a21cbf9fc8e255725a Mon Sep 17 00:00:00 2001 From: Matt Gibbs Date: Thu, 18 Feb 2016 07:40:48 -0500 Subject: [PATCH 108/117] Added post__in to documentation --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 15cca4d4f3..3fdf7015ad 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,10 @@ After running an index, ElasticPress integrates with `WP_Query` if and only if t Filter posts by post type. ```any``` will search all public post types. `WP_Query` defaults to either `post` or `any` if no `post_type` is provided depending on the context of the query. This is confusing. ElasticPress will ALWAYS default to `any` if no `post_type` is provided. If you want to search for `post` posts, you MUST specify `post` as the `post_type`. +* ```post__in``` (*array*) + + Filter posts by specific post IDs. + * ```offset``` (*int*) Number of posts to skip in ascending order. From ada49d0067ac5c8fb3d06e556cb1e8ccf289586f Mon Sep 17 00:00:00 2001 From: Matt Gibbs Date: Thu, 18 Feb 2016 07:49:01 -0500 Subject: [PATCH 109/117] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fdf7015ad..d73860f95d 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,11 @@ After running an index, ElasticPress integrates with `WP_Query` if and only if t * ```post__in``` (*array*) - Filter posts by specific post IDs. + Specify post IDs to retrieve. + +* ```post__not_in``` (*array*) + + Specify post IDs to exclude. * ```offset``` (*int*) From f220dd20611d84a543bf12c982eaa5a80dd4f360 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Tue, 9 Feb 2016 16:09:23 -0700 Subject: [PATCH 110/117] Add the ability to pause indexing from the admin GUI. Keep indexing paused even if the page is refreshed. Make sure EP is enabled while indexing is paused. --- assets/js/elasticpress-admin.js | 125 ++++++++++++++++++++++++---- assets/js/elasticpress-admin.min.js | 2 +- classes/class-ep-index-gui.php | 36 ++++++++ classes/class-ep-settings.php | 11 +++ includes/settings/index.php | 25 +++++- lang/elasticpress.pot | 68 ++++++++------- 6 files changed, 219 insertions(+), 48 deletions(-) diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index ee6f70c877..ed38e2a96a 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -1,11 +1,29 @@ jQuery( document ).ready( function ( $ ) { + var pauseIndexing = false; + var epSitesRemaining = 0; + var epTotalToIndex = 0; + var epTotalIndexed = 0; + var epSitesCompleted = 0; + + // The run index button + var run_index_button = $( '#ep_run_index' ); + + // The pause index button + var pause_index_button = $( '#ep_pause_index' ); + /** * Update the progress bar every 3 seconds */ - var performIndex = function ( resetBar, button ) { + var performIndex = function ( resetBar, button, stopbtn ) { + + if ( pauseIndexing ) { + return; + } - $( button ).val( ep.running_index_text ).removeClass( 'button-primary' ); + $( button ).val( ep.running_index_text ).removeClass( 'button-primary' ).attr( 'disabled', true ); + + $( stopbtn ).removeClass( 'hidden' ); //Make sure the progress bar is showing var bar = $( '#progressbar' ), @@ -32,14 +50,53 @@ jQuery( document ).ready( function ( $ ) { } - processIndex( bar, button, status ); + processIndex( bar, button, stopbtn, status ); }; - var epSitesRemaining = 0; - var epTotalToIndex = 0; - var epTotalIndexed = 0; - var epSitesCompleted = 0; + /** + * Set our variable to pause indexing + */ + var pauseIndex = function( pausebtn, indexbtn ) { + + var btn = $( pausebtn ); + var paused = btn.data( 'paused' ); + + if ( paused === 'enabled' ) { + + btn.val( ep.index_pause_text ).data( 'paused', 'disabled' ); + + pauseIndexing = false; + + performIndex( false, indexbtn, pausebtn ); + + } else { + + var data = { + action : 'ep_pause_index', + nonce : ep.pause_nonce + }; + + // call the ajax request to re-enable ElasticPress + $.ajax( + { + url : ajaxurl, + type : 'POST', + data : data, + complete: function (response) { + + btn.val( ep.index_resume_text ).data( 'paused', 'enabled' ); + $( indexbtn ).val( ep.index_paused_text ).attr( 'disabled', true ); + + pauseIndexing = true; + + } + } + ); + + } + + }; // Resets index counts var resetIndex = function () { @@ -53,7 +110,7 @@ jQuery( document ).ready( function ( $ ) { /** * Send request to server and process response */ - var processIndex = function ( bar, button, status ) { + var processIndex = function ( bar, button, stopbtn, status ) { var data = { action : 'ep_launch_index', @@ -72,7 +129,8 @@ jQuery( document ).ready( function ( $ ) { if ( 'undefined' === typeof response.responseJSON || 'undefined' === typeof response.responseJSON.data ) { $( '#progressstats' ).text( ep.failed_text ); - $( '#ep_run_index' ).val( ep.index_complete_text ).addClass( 'button-primary' ); + $( button ).val( ep.index_complete_text ).addClass( 'button-primary' ).attr( 'disabled', false ); + $( stopbtn ).addClass( 'hidden' ); $( '#progressbar' ).fadeOut( 'slow' ); } else { @@ -121,14 +179,15 @@ jQuery( document ).ready( function ( $ ) { $( '#progressbar' ).fadeOut( 'slow' ); $( '#progressstats' ).html( ep.complete_text ); - $( '#ep_run_index' ).val( ep.index_complete_text ).addClass( 'button-primary' ); + $( button ).val( ep.index_complete_text ).addClass( 'button-primary' ).attr( 'disabled', false ); + $( stopbtn ).addClass( 'hidden' ); resetIndex(); }, 1000 ); } else { - performIndex( false, button ); + performIndex( false, button, stopbtn ); } } @@ -138,14 +197,37 @@ jQuery( document ).ready( function ( $ ) { }; - // The run index button - var run_index_button = $( '#ep_run_index' ); + /** + * Show the progress bar when indexing is paused. + */ + var showProgressBar = function() { + + var bar = $( '#progressbar' ), + status = $( '#progressstats' ); + + bar.show(); + + var progress = parseFloat( ep.synced_posts ) / parseFloat( ep.total_posts ); + + bar.progressbar( + { + value : progress * 100 + } + ); + + status.text( ep.synced_posts + '/' + ep.total_posts + ' ' + ep.items_indexed ); + + }; /** * Start the poll if we need it */ - if ( 1 == ep.index_running ) { - performIndex( true, run_index_button ); + if ( 1 == ep.index_running && 1 != ep.paused ) { + performIndex( true, run_index_button, pause_index_button ); + } + + if ( 1 == ep.index_running && 1 == ep.paused ) { + showProgressBar(); } /** @@ -164,7 +246,18 @@ jQuery( document ).ready( function ( $ ) { } $( '#progressstats' ).text( ep.running_index_text ); - performIndex( true, button ); //start the polling + performIndex( true, button, pause_index_button ); //start the polling + + } ); + + /** + * Process the pause index operation + */ + pause_index_button.click( function ( event ) { + + event.preventDefault(); + + pauseIndex( this, run_index_button ); } ); diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index 3e3ab67142..2d6a365dab 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=function(b,c){a(c).val(ep.running_index_text).removeClass("button-primary");var d=a("#progressbar"),e=a("#progressstats");if(d.show(),b){var f=0;parseInt(ep.total_posts)>0&&(f=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),e.text(ep.synced_posts+"/"+ep.total_posts+" items")),d.progressbar({value:100*f})}h(d,c,e)},c=0,d=0,e=0,f=0,g=function(){c=0,d=0,e=0},h=function(h,i,j){var k={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:k,complete:function(k){if("undefined"==typeof k.responseJSON||"undefined"==typeof k.responseJSON.data)a("#progressstats").text(ep.failed_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),a("#progressbar").fadeOut("slow");else{var l="";0===k.responseJSON.data.is_network?(d=k.responseJSON.data.ep_posts_total,e=k.responseJSON.data.ep_posts_synced):(c!==k.responseJSON.data.ep_sites_remaining&&(c=k.responseJSON.data.ep_sites_remaining,d+=k.responseJSON.data.ep_posts_total,f++),l=f+ep.sites,e+=k.responseJSON.data.ep_current_synced);var m=parseFloat(e)/parseFloat(d);h.progressbar({value:100*m}),j.text(e+"/"+d+" "+ep.items_indexed+l),1==k.responseJSON.data.ep_sync_complete?(h.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a("#ep_run_index").val(ep.index_complete_text).addClass("button-primary"),g()},1e3)):b(!1,i)}}})},i=a("#ep_run_index");1==ep.index_running&&b(!0,i),i.click(function(c){c.preventDefault(),g();var d=this;a(d).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),b(!0,d))});var j=a("#ep_site_select");j.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:j.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=!1,c=0,d=0,e=0,f=0,g=a("#ep_run_index"),h=a("#ep_pause_index"),i=function(c,d,e){if(!b){a(d).val(ep.running_index_text).removeClass("button-primary").attr("disabled",!0),a(e).removeClass("hidden");var f=a("#progressbar"),g=a("#progressstats");if(f.show(),c){var h=0;parseInt(ep.total_posts)>0&&(h=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),g.text(ep.synced_posts+"/"+ep.total_posts+" items")),f.progressbar({value:100*h})}l(f,d,e,g)}},j=function(c,d){var e=a(c),f=e.data("paused");if("enabled"===f)e.val(ep.index_pause_text).data("paused","disabled"),b=!1,i(!1,d,c);else{var g={action:"ep_pause_index",nonce:ep.pause_nonce};a.ajax({url:ajaxurl,type:"POST",data:g,complete:function(c){e.val(ep.index_resume_text).data("paused","enabled"),a(d).val(ep.index_paused_text).attr("disabled",!0),b=!0}})}},k=function(){c=0,d=0,e=0},l=function(b,g,h,j){var l={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:l,complete:function(l){if("undefined"==typeof l.responseJSON||"undefined"==typeof l.responseJSON.data)a("#progressstats").text(ep.failed_text),a(g).val(ep.index_complete_text).addClass("button-primary").attr("disabled",!1),a(h).addClass("hidden"),a("#progressbar").fadeOut("slow");else{var m="";0===l.responseJSON.data.is_network?(d=l.responseJSON.data.ep_posts_total,e=l.responseJSON.data.ep_posts_synced):(c!==l.responseJSON.data.ep_sites_remaining&&(c=l.responseJSON.data.ep_sites_remaining,d+=l.responseJSON.data.ep_posts_total,f++),m=f+ep.sites,e+=l.responseJSON.data.ep_current_synced);var n=parseFloat(e)/parseFloat(d);b.progressbar({value:100*n}),j.text(e+"/"+d+" "+ep.items_indexed+m),1==l.responseJSON.data.ep_sync_complete?(b.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a(g).val(ep.index_complete_text).addClass("button-primary").attr("disabled",!1),a(h).addClass("hidden"),k()},1e3)):i(!1,g,h)}}})},m=function(){var b=a("#progressbar"),c=a("#progressstats");b.show();var d=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts);b.progressbar({value:100*d}),c.text(ep.synced_posts+"/"+ep.total_posts+" "+ep.items_indexed)};1==ep.index_running&&1!=ep.paused&&i(!0,g,h),1==ep.index_running&&1==ep.paused&&m(),g.click(function(b){b.preventDefault(),k();var c=this;a(c).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),i(!0,c,h))}),h.click(function(a){a.preventDefault(),j(this,g)});var n=a("#ep_site_select");n.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:n.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index c476e3be02..6ddcf94b75 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -46,6 +46,7 @@ public function __construct() { // Add Ajax Actions. add_action( 'wp_ajax_ep_launch_index', array( $this, 'action_wp_ajax_ep_launch_index' ) ); + add_action( 'wp_ajax_ep_pause_index', array( $this, 'action_wp_ajax_ep_pause_index' ) ); add_action( 'wp_ajax_ep_get_site_stats', array( $this, 'action_wp_ajax_ep_get_site_stats' ) ); add_action( 'ep_do_settings_meta', array( $this, 'action_ep_do_settings_meta' ) ); @@ -190,6 +191,8 @@ public function action_wp_ajax_ep_launch_index() { if ( true === $network ) { + delete_site_option( 'ep_index_paused' ); + $last_run = get_site_transient( 'ep_sites_to_index' ); if ( false === $last_run ) { @@ -208,6 +211,8 @@ public function action_wp_ajax_ep_launch_index() { $site_info = array_pop( $sites ); $site = absint( $site_info['blog_id'] ); + } else { + delete_option( 'ep_index_paused' ); } if ( false !== $site ) { @@ -293,6 +298,37 @@ public function action_wp_ajax_ep_launch_index() { } + /** + * Process the indexing pause request + * + * Processes the action when the pause indexing button is clicked, + * re-enabling the ElasticPress integration while indexing is paused. + * + * @since 1.9 + * + * @return void + */ + public function action_wp_ajax_ep_pause_index() { + + // Verify nonce and make sure this is run by an admin. + if ( ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'ep_pause_index' ) || ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( esc_html__( 'Security error!', 'elasticpress' ) ); + } + + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + update_site_option( 'ep_index_paused', true ); + } else { + update_option( 'ep_index_paused', true, false ); + } + + // If ElasticPress is activated correctly, send a positive response + if ( ep_activate() ) { + wp_send_json_success(); + } + + wp_send_json_error(); + } + /** * Process site stats * diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index adf806c8ba..5b99940e73 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -103,6 +103,12 @@ public function action_admin_enqueue_scripts() { } + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + $paused = get_site_option( 'ep_index_paused' ); + } else { + $paused = get_option( 'ep_index_paused' ); + } + $indexed = esc_html__( 'items indexed', 'elasticpress' ); if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { @@ -120,10 +126,15 @@ public function action_admin_enqueue_scripts() { 'ep', array( 'nonce' => wp_create_nonce( 'ep_manual_index' ), + 'pause_nonce' => wp_create_nonce( 'ep_pause_index' ), 'stats_nonce' => wp_create_nonce( 'ep_site_stats' ), 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), + 'index_paused_text' => esc_html__( 'Indexing is Paused', 'elasticpress' ), + 'index_resume_text' => esc_html__( 'Resume Indexing', 'elasticpress' ), + 'index_pause_text' => esc_html__( 'Pause Indexing', 'elasticpress' ), 'items_indexed' => $indexed, + 'paused' => absint( $paused ), 'sites' => esc_html__( ' site(s)', 'elasticpress' ), 'index_running' => $running, 'total_posts' => isset( $total_posts['total'] ) ? $total_posts['total'] : 0, diff --git a/includes/settings/index.php b/includes/settings/index.php index e5fd117e33..cb59b7a127 100644 --- a/includes/settings/index.php +++ b/includes/settings/index.php @@ -10,15 +10,34 @@ */ ?>

    - + > + > diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 4b921d797a..3ec9225505 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.8\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/elasticpress\n" -"POT-Creation-Date: 2016-02-08 22:22:16+00:00\n" +"POT-Creation-Date: 2016-02-09 23:04:39+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -85,17 +85,17 @@ msgstr "" msgid "Total time elapsed: " msgstr "" -#: bin/wp-cli.php:544 +#: bin/wp-cli.php:532 msgid "" "The following posts failed to index:\r\n" "\r\n" msgstr "" -#: bin/wp-cli.php:693 classes/class-ep-config.php:174 +#: bin/wp-cli.php:718 classes/class-ep-config.php:174 msgid "EP_HOST is not defined! Check wp-config.php" msgstr "" -#: bin/wp-cli.php:697 classes/class-ep-config.php:178 +#: bin/wp-cli.php:722 classes/class-ep-config.php:178 msgid "Unable to reach Elasticsearch Server! Check that service is running." msgstr "" @@ -127,52 +127,52 @@ msgstr "" msgid "No running host available." msgstr "" -#: classes/class-ep-index-gui.php:125 +#: classes/class-ep-index-gui.php:126 msgid "" "Mappings could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:138 +#: classes/class-ep-index-gui.php:139 msgid "" "Indexing could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:179 classes/class-ep-index-gui.php:309 -#: classes/class-ep-settings.php:154 +#: classes/class-ep-index-gui.php:180 classes/class-ep-index-gui.php:314 +#: classes/class-ep-index-gui.php:350 classes/class-ep-settings.php:165 msgid "Security error!" msgstr "" -#: classes/class-ep-index-gui.php:322 +#: classes/class-ep-index-gui.php:363 msgid "Search Stats" msgstr "" -#: classes/class-ep-index-gui.php:325 +#: classes/class-ep-index-gui.php:366 msgid "Total Queries:" msgstr "" -#: classes/class-ep-index-gui.php:328 +#: classes/class-ep-index-gui.php:369 msgid "Query Time:" msgstr "" -#: classes/class-ep-index-gui.php:331 +#: classes/class-ep-index-gui.php:372 msgid "Total Fetches:" msgstr "" -#: classes/class-ep-index-gui.php:334 +#: classes/class-ep-index-gui.php:375 msgid "Fetch Time:" msgstr "" -#: classes/class-ep-index-gui.php:339 +#: classes/class-ep-index-gui.php:380 msgid "Index Stats" msgstr "" -#: classes/class-ep-index-gui.php:342 +#: classes/class-ep-index-gui.php:383 msgid "Index Total:" msgstr "" -#: classes/class-ep-index-gui.php:345 +#: classes/class-ep-index-gui.php:386 msgid "Index Time:" msgstr "" @@ -184,45 +184,57 @@ msgstr "" msgid ": ElasticPress Index Errors" msgstr "" -#: classes/class-ep-settings.php:106 +#: classes/class-ep-settings.php:112 msgid "items indexed" msgstr "" -#: classes/class-ep-settings.php:109 +#: classes/class-ep-settings.php:115 msgid "items indexed in " msgstr "" -#: classes/class-ep-settings.php:124 includes/settings/index.php:15 +#: classes/class-ep-settings.php:131 includes/settings/index.php:28 msgid "Running Index..." msgstr "" -#: classes/class-ep-settings.php:125 includes/settings/index.php:15 +#: classes/class-ep-settings.php:132 includes/settings/index.php:23 msgid "Run Index" msgstr "" -#: classes/class-ep-settings.php:127 +#: classes/class-ep-settings.php:133 includes/settings/index.php:26 +msgid "Indexing is Paused" +msgstr "" + +#: classes/class-ep-settings.php:134 includes/settings/index.php:33 +msgid "Resume Indexing" +msgstr "" + +#: classes/class-ep-settings.php:135 includes/settings/index.php:33 +msgid "Pause Indexing" +msgstr "" + +#: classes/class-ep-settings.php:138 msgid " site(s)" msgstr "" -#: classes/class-ep-settings.php:131 +#: classes/class-ep-settings.php:142 msgid "" "A failure has occured. Please try the indexing operation again and if the " "error persists contact your website administrator." msgstr "" -#: classes/class-ep-settings.php:132 +#: classes/class-ep-settings.php:143 msgid "Index complete Refresh the stats" msgstr "" -#: classes/class-ep-settings.php:180 +#: classes/class-ep-settings.php:191 msgid "Elasticsearch Host:" msgstr "" -#: classes/class-ep-settings.php:189 +#: classes/class-ep-settings.php:200 msgid "Use Elasticsearch:" msgstr "" -#: classes/class-ep-settings.php:420 +#: classes/class-ep-settings.php:431 msgid "Elasticsearch Integration Options" msgstr "" @@ -244,11 +256,11 @@ msgstr "" msgid "The following values do not describe a valid date: month %1$s, day %2$s." msgstr "" -#: includes/settings/index.php:23 +#: includes/settings/index.php:42 msgid "ElasticPress needs to be enabled to run an index." msgstr "" -#: includes/settings/index.php:26 +#: includes/settings/index.php:45 msgid "A proper host must be set before running an index." msgstr "" From 3d80aeb9a03728e1b302ce896b1209d25750cb26 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 25 Feb 2016 15:35:35 -0700 Subject: [PATCH 111/117] Add an button to restart the indexing, if indexing has been paused. This allows you to start the indexing over if you desire, without having to wait for it to finish first. --- assets/css/elasticpress.css | 3 + assets/css/elasticpress.css.map | 2 +- assets/css/elasticpress.min.css | 2 +- assets/css/elasticpress.scss | 4 ++ assets/js/elasticpress-admin.js | 81 ++++++++++++++++++++----- assets/js/elasticpress-admin.min.js | 2 +- classes/class-ep-index-gui.php | 32 ++++++++++ classes/class-ep-settings.php | 1 + includes/settings/index.php | 7 ++- lang/elasticpress.pot | 93 ++++++++++++++--------------- 10 files changed, 161 insertions(+), 66 deletions(-) diff --git a/assets/css/elasticpress.css b/assets/css/elasticpress.css index b379f022f1..a5df40e8da 100644 --- a/assets/css/elasticpress.css +++ b/assets/css/elasticpress.css @@ -33,4 +33,7 @@ padding: 0; } #ep_stats ul li { margin-left: 20px; } + +#ep_restart_index { + float: right; } /*# sourceMappingURL=elasticpress.css.map */ \ No newline at end of file diff --git a/assets/css/elasticpress.css.map b/assets/css/elasticpress.css.map index c848cfc7ac..f69931958d 100644 --- a/assets/css/elasticpress.css.map +++ b/assets/css/elasticpress.css.map @@ -1 +1 @@ -{"version":3,"sources":["elasticpress.scss"],"names":[],"mappings":"AAAA;EAGE,oBAAqB,EACrB;;AAJF;EAOE,gBAAiB,EACjB;;AARF;EAWE,eAAgB;EAChB,YAAe;EACf,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AAhBF;EAmBE,eAAgB;EAChB,aAAgB;EAChB,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AAxBF;;EA4BE,YAAa;EACb,YAAa,EACb;;AA9BF;EAiCE,UAAY;EACZ,WAAY,EACZ;;AAnCF;EAuCE,iBAAkB;EAClB,UAAe;EACf,WAAe,EAMf;EA/CF;IA4CG,kBAAmB,EACnB","file":"elasticpress.css"} \ No newline at end of file +{"version":3,"sources":["elasticpress.scss"],"names":[],"mappings":"AAAA;EAGE,oBAAqB,EACrB;;AAJF;EAOE,gBAAiB,EACjB;;AARF;EAWE,eAAgB;EAChB,YAAe;EACf,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AAhBF;EAmBE,eAAgB;EAChB,aAAgB;EAChB,UAAY;EACZ,gBAAiB;EACjB,WAAc,EACd;;AAxBF;;EA4BE,YAAa;EACb,YAAa,EACb;;AA9BF;EAiCE,UAAY;EACZ,WAAY,EACZ;;AAnCF;EAuCE,iBAAkB;EAClB,UAAe;EACf,WAAe,EAMf;EA/CF;IA4CG,kBAAmB,EACnB;;AAMH;EACC,aAAa,EACb","file":"elasticpress.css"} \ No newline at end of file diff --git a/assets/css/elasticpress.min.css b/assets/css/elasticpress.min.css index 6a1fd71e6d..85a5203cc6 100644 --- a/assets/css/elasticpress.min.css +++ b/assets/css/elasticpress.min.css @@ -1 +1 @@ -#ep_stats #ep_site_sel{padding:15px 0 0}#ep_stats .ep_stats_section{padding:20px 0}#ep_stats .index_stats,#ep_stats .search_stats{display:block;margin:0;padding:10px 0;width:50%}#ep_stats .search_stats{float:left}#ep_stats .index_stats{float:right}#ep_stats h3,#ep_stats ul{margin:0;padding:0}#ep_stats #ep_cluster_stats,#ep_stats #ep_ind_stats{clear:both;width:100%}#ep_stats ul{list-style:disc}#ep_stats ul li{margin-left:20px} \ No newline at end of file +#ep_stats #ep_site_sel{padding:15px 0 0}#ep_stats .ep_stats_section{padding:20px 0}#ep_stats .index_stats,#ep_stats .search_stats{display:block;margin:0;padding:10px 0;width:50%}#ep_stats .search_stats{float:left}#ep_stats .index_stats{float:right}#ep_stats h3,#ep_stats ul{margin:0;padding:0}#ep_stats #ep_cluster_stats,#ep_stats #ep_ind_stats{clear:both;width:100%}#ep_stats ul{list-style:disc}#ep_stats ul li{margin-left:20px}#ep_restart_index{float:right} \ No newline at end of file diff --git a/assets/css/elasticpress.scss b/assets/css/elasticpress.scss index f1eff9a580..c4a686c48b 100644 --- a/assets/css/elasticpress.scss +++ b/assets/css/elasticpress.scss @@ -47,4 +47,8 @@ } +} + +#ep_restart_index { + float: right; } \ No newline at end of file diff --git a/assets/js/elasticpress-admin.js b/assets/js/elasticpress-admin.js index ed38e2a96a..916a62dd19 100644 --- a/assets/js/elasticpress-admin.js +++ b/assets/js/elasticpress-admin.js @@ -12,10 +12,13 @@ jQuery( document ).ready( function ( $ ) { // The pause index button var pause_index_button = $( '#ep_pause_index' ); + // The restart index button + var restart_index_button = $( '#ep_restart_index' ); + /** * Update the progress bar every 3 seconds */ - var performIndex = function ( resetBar, button, stopbtn ) { + var performIndex = function ( resetBar, button, stopBtn, restartBtn ) { if ( pauseIndexing ) { return; @@ -23,7 +26,8 @@ jQuery( document ).ready( function ( $ ) { $( button ).val( ep.running_index_text ).removeClass( 'button-primary' ).attr( 'disabled', true ); - $( stopbtn ).removeClass( 'hidden' ); + $( stopBtn ).removeClass( 'hidden' ); + $( restartBtn ).addClass( 'hidden' ); //Make sure the progress bar is showing var bar = $( '#progressbar' ), @@ -50,16 +54,16 @@ jQuery( document ).ready( function ( $ ) { } - processIndex( bar, button, stopbtn, status ); + processIndex( bar, button, stopBtn, restartBtn, status ); }; /** * Set our variable to pause indexing */ - var pauseIndex = function( pausebtn, indexbtn ) { + var pauseIndex = function( pauseBtn, indexBtn, restartBtn ) { - var btn = $( pausebtn ); + var btn = $( pauseBtn ); var paused = btn.data( 'paused' ); if ( paused === 'enabled' ) { @@ -68,7 +72,7 @@ jQuery( document ).ready( function ( $ ) { pauseIndexing = false; - performIndex( false, indexbtn, pausebtn ); + performIndex( false, indexBtn, pauseBtn, restartBtn ); } else { @@ -86,7 +90,8 @@ jQuery( document ).ready( function ( $ ) { complete: function (response) { btn.val( ep.index_resume_text ).data( 'paused', 'enabled' ); - $( indexbtn ).val( ep.index_paused_text ).attr( 'disabled', true ); + $( indexBtn ).val( ep.index_paused_text ).attr( 'disabled', true ); + $( restartBtn ).removeClass( 'hidden' ); pauseIndexing = true; @@ -98,6 +103,41 @@ jQuery( document ).ready( function ( $ ) { }; + /** + * Allow indexing to be restarted. + */ + var restartIndex = function( restartBtn, pauseBtn, indexBtn ) { + + var data = { + action : 'ep_restart_index', + nonce : ep.restart_nonce + }; + + // call the ajax request to un-pause indexing + $.ajax( + { + url : ajaxurl, + type : 'POST', + data : data, + complete: function (response) { + + resetIndex(); + + $( restartBtn ).addClass( 'hidden' ); + $( pauseBtn ).val( ep.index_pause_text ).data( 'paused', 'disabled' ).addClass( 'hidden' ); + $( indexBtn ).val( ep.index_complete_text ).addClass( 'button-primary' ).attr( 'disabled', false ); + + $( '#progressstats' ).text( '' ); + $( '#progressbar' ).fadeOut( 'slow' ); + + pauseIndexing = false; + + } + } + ); + + }; + // Resets index counts var resetIndex = function () { @@ -110,7 +150,7 @@ jQuery( document ).ready( function ( $ ) { /** * Send request to server and process response */ - var processIndex = function ( bar, button, stopbtn, status ) { + var processIndex = function ( bar, button, stopBtn, restartBtn, status ) { var data = { action : 'ep_launch_index', @@ -130,7 +170,8 @@ jQuery( document ).ready( function ( $ ) { $( '#progressstats' ).text( ep.failed_text ); $( button ).val( ep.index_complete_text ).addClass( 'button-primary' ).attr( 'disabled', false ); - $( stopbtn ).addClass( 'hidden' ); + $( stopBtn ).addClass( 'hidden' ); + $( restartBtn ).addClass( 'hidden' ); $( '#progressbar' ).fadeOut( 'slow' ); } else { @@ -180,14 +221,15 @@ jQuery( document ).ready( function ( $ ) { $( '#progressbar' ).fadeOut( 'slow' ); $( '#progressstats' ).html( ep.complete_text ); $( button ).val( ep.index_complete_text ).addClass( 'button-primary' ).attr( 'disabled', false ); - $( stopbtn ).addClass( 'hidden' ); + $( stopBtn ).addClass( 'hidden' ); + $( restartBtn ).addClass( 'hidden' ); resetIndex(); }, 1000 ); } else { - performIndex( false, button, stopbtn ); + performIndex( false, button, stopBtn, restartBtn ); } } @@ -223,7 +265,7 @@ jQuery( document ).ready( function ( $ ) { * Start the poll if we need it */ if ( 1 == ep.index_running && 1 != ep.paused ) { - performIndex( true, run_index_button, pause_index_button ); + performIndex( true, run_index_button, pause_index_button, restart_index_button ); } if ( 1 == ep.index_running && 1 == ep.paused ) { @@ -246,7 +288,7 @@ jQuery( document ).ready( function ( $ ) { } $( '#progressstats' ).text( ep.running_index_text ); - performIndex( true, button, pause_index_button ); //start the polling + performIndex( true, button, pause_index_button, restart_index_button ); //start the polling } ); @@ -257,7 +299,18 @@ jQuery( document ).ready( function ( $ ) { event.preventDefault(); - pauseIndex( this, run_index_button ); + pauseIndex( this, run_index_button, restart_index_button ); + + } ); + + /** + * Process the restart index operation + */ + restart_index_button.click( function ( event ) { + + event.preventDefault(); + + restartIndex( this, pause_index_button, run_index_button ); } ); diff --git a/assets/js/elasticpress-admin.min.js b/assets/js/elasticpress-admin.min.js index 2d6a365dab..787ccf3d35 100644 --- a/assets/js/elasticpress-admin.min.js +++ b/assets/js/elasticpress-admin.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){var b=!1,c=0,d=0,e=0,f=0,g=a("#ep_run_index"),h=a("#ep_pause_index"),i=function(c,d,e){if(!b){a(d).val(ep.running_index_text).removeClass("button-primary").attr("disabled",!0),a(e).removeClass("hidden");var f=a("#progressbar"),g=a("#progressstats");if(f.show(),c){var h=0;parseInt(ep.total_posts)>0&&(h=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),g.text(ep.synced_posts+"/"+ep.total_posts+" items")),f.progressbar({value:100*h})}l(f,d,e,g)}},j=function(c,d){var e=a(c),f=e.data("paused");if("enabled"===f)e.val(ep.index_pause_text).data("paused","disabled"),b=!1,i(!1,d,c);else{var g={action:"ep_pause_index",nonce:ep.pause_nonce};a.ajax({url:ajaxurl,type:"POST",data:g,complete:function(c){e.val(ep.index_resume_text).data("paused","enabled"),a(d).val(ep.index_paused_text).attr("disabled",!0),b=!0}})}},k=function(){c=0,d=0,e=0},l=function(b,g,h,j){var l={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:l,complete:function(l){if("undefined"==typeof l.responseJSON||"undefined"==typeof l.responseJSON.data)a("#progressstats").text(ep.failed_text),a(g).val(ep.index_complete_text).addClass("button-primary").attr("disabled",!1),a(h).addClass("hidden"),a("#progressbar").fadeOut("slow");else{var m="";0===l.responseJSON.data.is_network?(d=l.responseJSON.data.ep_posts_total,e=l.responseJSON.data.ep_posts_synced):(c!==l.responseJSON.data.ep_sites_remaining&&(c=l.responseJSON.data.ep_sites_remaining,d+=l.responseJSON.data.ep_posts_total,f++),m=f+ep.sites,e+=l.responseJSON.data.ep_current_synced);var n=parseFloat(e)/parseFloat(d);b.progressbar({value:100*n}),j.text(e+"/"+d+" "+ep.items_indexed+m),1==l.responseJSON.data.ep_sync_complete?(b.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a(g).val(ep.index_complete_text).addClass("button-primary").attr("disabled",!1),a(h).addClass("hidden"),k()},1e3)):i(!1,g,h)}}})},m=function(){var b=a("#progressbar"),c=a("#progressstats");b.show();var d=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts);b.progressbar({value:100*d}),c.text(ep.synced_posts+"/"+ep.total_posts+" "+ep.items_indexed)};1==ep.index_running&&1!=ep.paused&&i(!0,g,h),1==ep.index_running&&1==ep.paused&&m(),g.click(function(b){b.preventDefault(),k();var c=this;a(c).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),i(!0,c,h))}),h.click(function(a){a.preventDefault(),j(this,g)});var n=a("#ep_site_select");n.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:n.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file +jQuery(document).ready(function(a){var b=!1,c=0,d=0,e=0,f=0,g=a("#ep_run_index"),h=a("#ep_pause_index"),i=a("#ep_restart_index"),j=function(c,d,e,f){if(!b){a(d).val(ep.running_index_text).removeClass("button-primary").attr("disabled",!0),a(e).removeClass("hidden"),a(f).addClass("hidden");var g=a("#progressbar"),h=a("#progressstats");if(g.show(),c){var i=0;parseInt(ep.total_posts)>0&&(i=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts),h.text(ep.synced_posts+"/"+ep.total_posts+" items")),g.progressbar({value:100*i})}n(g,d,e,f,h)}},k=function(c,d,e){var f=a(c),g=f.data("paused");if("enabled"===g)f.val(ep.index_pause_text).data("paused","disabled"),b=!1,j(!1,d,c,e);else{var h={action:"ep_pause_index",nonce:ep.pause_nonce};a.ajax({url:ajaxurl,type:"POST",data:h,complete:function(c){f.val(ep.index_resume_text).data("paused","enabled"),a(d).val(ep.index_paused_text).attr("disabled",!0),a(e).removeClass("hidden"),b=!0}})}},l=function(c,d,e){var f={action:"ep_restart_index",nonce:ep.restart_nonce};a.ajax({url:ajaxurl,type:"POST",data:f,complete:function(f){m(),a(c).addClass("hidden"),a(d).val(ep.index_pause_text).data("paused","disabled").addClass("hidden"),a(e).val(ep.index_complete_text).addClass("button-primary").attr("disabled",!1),a("#progressstats").text(""),a("#progressbar").fadeOut("slow"),b=!1}})},m=function(){c=0,d=0,e=0},n=function(b,g,h,i,k){var l={action:"ep_launch_index",nonce:ep.nonce};a.ajax({url:ajaxurl,type:"POST",data:l,complete:function(l){if("undefined"==typeof l.responseJSON||"undefined"==typeof l.responseJSON.data)a("#progressstats").text(ep.failed_text),a(g).val(ep.index_complete_text).addClass("button-primary").attr("disabled",!1),a(h).addClass("hidden"),a(i).addClass("hidden"),a("#progressbar").fadeOut("slow");else{var n="";0===l.responseJSON.data.is_network?(d=l.responseJSON.data.ep_posts_total,e=l.responseJSON.data.ep_posts_synced):(c!==l.responseJSON.data.ep_sites_remaining&&(c=l.responseJSON.data.ep_sites_remaining,d+=l.responseJSON.data.ep_posts_total,f++),n=f+ep.sites,e+=l.responseJSON.data.ep_current_synced);var o=parseFloat(e)/parseFloat(d);b.progressbar({value:100*o}),k.text(e+"/"+d+" "+ep.items_indexed+n),1==l.responseJSON.data.ep_sync_complete?(b.progressbar({value:100}),setTimeout(function(){a("#progressbar").fadeOut("slow"),a("#progressstats").html(ep.complete_text),a(g).val(ep.index_complete_text).addClass("button-primary").attr("disabled",!1),a(h).addClass("hidden"),a(i).addClass("hidden"),m()},1e3)):j(!1,g,h,i)}}})},o=function(){var b=a("#progressbar"),c=a("#progressstats");b.show();var d=parseFloat(ep.synced_posts)/parseFloat(ep.total_posts);b.progressbar({value:100*d}),c.text(ep.synced_posts+"/"+ep.total_posts+" "+ep.items_indexed)};1==ep.index_running&&1!=ep.paused&&j(!0,g,h,i),1==ep.index_running&&1==ep.paused&&o(),g.click(function(b){b.preventDefault(),m();var c=this;a(c).hasClass("button-primary")&&(a("#progressstats").text(ep.running_index_text),j(!0,c,h,i))}),h.click(function(a){a.preventDefault(),k(this,g,i)}),i.click(function(a){a.preventDefault(),l(this,h,g)});var p=a("#ep_site_select");p.change(function(b){b.preventDefault();var c={action:"ep_get_site_stats",nonce:ep.stats_nonce,site:p.val()};a.ajax({url:ajaxurl,type:"POST",data:c,complete:function(b){a("#ep_site_stats").html(b.responseJSON.data)}})})}); \ No newline at end of file diff --git a/classes/class-ep-index-gui.php b/classes/class-ep-index-gui.php index 6ddcf94b75..f59b248690 100644 --- a/classes/class-ep-index-gui.php +++ b/classes/class-ep-index-gui.php @@ -47,6 +47,7 @@ public function __construct() { // Add Ajax Actions. add_action( 'wp_ajax_ep_launch_index', array( $this, 'action_wp_ajax_ep_launch_index' ) ); add_action( 'wp_ajax_ep_pause_index', array( $this, 'action_wp_ajax_ep_pause_index' ) ); + add_action( 'wp_ajax_ep_restart_index', array( $this, 'action_wp_ajax_ep_restart_index' ) ); add_action( 'wp_ajax_ep_get_site_stats', array( $this, 'action_wp_ajax_ep_get_site_stats' ) ); add_action( 'ep_do_settings_meta', array( $this, 'action_ep_do_settings_meta' ) ); @@ -329,6 +330,37 @@ public function action_wp_ajax_ep_pause_index() { wp_send_json_error(); } + /** + * Process the indexing restart request + * + * Processes the action when the restart indexing button is clicked, + * updating the option saying indexing is not paused anymore. + * + * @since 1.9 + * + * @return void + */ + public function action_wp_ajax_ep_restart_index() { + + // Verify nonce and make sure this is run by an admin. + if ( ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'ep_restart_index' ) || ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( esc_html__( 'Security error!', 'elasticpress' ) ); + } + + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { + delete_site_option( 'ep_index_paused' ); + delete_site_transient( 'ep_sites_to_index' ); + } else { + delete_option( 'ep_index_paused' ); + } + + delete_transient( 'ep_index_offset' ); + delete_transient( 'ep_index_synced' ); + delete_transient( 'ep_post_count' ); + + wp_send_json_success(); + } + /** * Process site stats * diff --git a/classes/class-ep-settings.php b/classes/class-ep-settings.php index 5b99940e73..03c65f4cef 100644 --- a/classes/class-ep-settings.php +++ b/classes/class-ep-settings.php @@ -127,6 +127,7 @@ public function action_admin_enqueue_scripts() { array( 'nonce' => wp_create_nonce( 'ep_manual_index' ), 'pause_nonce' => wp_create_nonce( 'ep_pause_index' ), + 'restart_nonce' => wp_create_nonce( 'ep_restart_index' ), 'stats_nonce' => wp_create_nonce( 'ep_site_stats' ), 'running_index_text' => esc_html__( 'Running Index...', 'elasticpress' ), 'index_complete_text' => esc_html__( 'Run Index', 'elasticpress' ), diff --git a/includes/settings/index.php b/includes/settings/index.php index cb59b7a127..6fe631d997 100644 --- a/includes/settings/index.php +++ b/includes/settings/index.php @@ -31,6 +31,8 @@ $stop_class = $paused ? ' button-primary' : ' button-primary hidden'; $stop_text = $paused ? esc_html__( 'Resume Indexing', 'elasticpress' ) : esc_html__( 'Pause Indexing', 'elasticpress' ); + +$restart_class = $paused ? ' button-secondary' : ' button-secondary hidden'; ?>

    @@ -38,6 +40,7 @@ > > + @@ -45,5 +48,5 @@

    -

    -

    +

    +

    diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 3ec9225505..2d6ac66a4c 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: ElasticPress 1.8\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/elasticpress\n" -"POT-Creation-Date: 2016-02-09 23:04:39+00:00\n" +"POT-Creation-Date: 2016-02-25 22:32:52+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -127,52 +127,53 @@ msgstr "" msgid "No running host available." msgstr "" -#: classes/class-ep-index-gui.php:126 +#: classes/class-ep-index-gui.php:127 msgid "" "Mappings could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:139 +#: classes/class-ep-index-gui.php:140 msgid "" "Indexing could not be completed. If the error persists contact your system " "administrator" msgstr "" -#: classes/class-ep-index-gui.php:180 classes/class-ep-index-gui.php:314 -#: classes/class-ep-index-gui.php:350 classes/class-ep-settings.php:165 +#: classes/class-ep-index-gui.php:181 classes/class-ep-index-gui.php:316 +#: classes/class-ep-index-gui.php:347 classes/class-ep-index-gui.php:377 +#: classes/class-ep-settings.php:166 msgid "Security error!" msgstr "" -#: classes/class-ep-index-gui.php:363 +#: classes/class-ep-index-gui.php:390 msgid "Search Stats" msgstr "" -#: classes/class-ep-index-gui.php:366 +#: classes/class-ep-index-gui.php:393 msgid "Total Queries:" msgstr "" -#: classes/class-ep-index-gui.php:369 +#: classes/class-ep-index-gui.php:396 msgid "Query Time:" msgstr "" -#: classes/class-ep-index-gui.php:372 +#: classes/class-ep-index-gui.php:399 msgid "Total Fetches:" msgstr "" -#: classes/class-ep-index-gui.php:375 +#: classes/class-ep-index-gui.php:402 msgid "Fetch Time:" msgstr "" -#: classes/class-ep-index-gui.php:380 +#: classes/class-ep-index-gui.php:407 msgid "Index Stats" msgstr "" -#: classes/class-ep-index-gui.php:383 +#: classes/class-ep-index-gui.php:410 msgid "Index Total:" msgstr "" -#: classes/class-ep-index-gui.php:386 +#: classes/class-ep-index-gui.php:413 msgid "Index Time:" msgstr "" @@ -192,49 +193,49 @@ msgstr "" msgid "items indexed in " msgstr "" -#: classes/class-ep-settings.php:131 includes/settings/index.php:28 +#: classes/class-ep-settings.php:132 includes/settings/index.php:28 msgid "Running Index..." msgstr "" -#: classes/class-ep-settings.php:132 includes/settings/index.php:23 +#: classes/class-ep-settings.php:133 includes/settings/index.php:23 msgid "Run Index" msgstr "" -#: classes/class-ep-settings.php:133 includes/settings/index.php:26 +#: classes/class-ep-settings.php:134 includes/settings/index.php:26 msgid "Indexing is Paused" msgstr "" -#: classes/class-ep-settings.php:134 includes/settings/index.php:33 +#: classes/class-ep-settings.php:135 includes/settings/index.php:33 msgid "Resume Indexing" msgstr "" -#: classes/class-ep-settings.php:135 includes/settings/index.php:33 +#: classes/class-ep-settings.php:136 includes/settings/index.php:33 msgid "Pause Indexing" msgstr "" -#: classes/class-ep-settings.php:138 +#: classes/class-ep-settings.php:139 msgid " site(s)" msgstr "" -#: classes/class-ep-settings.php:142 +#: classes/class-ep-settings.php:143 msgid "" "A failure has occured. Please try the indexing operation again and if the " "error persists contact your website administrator." msgstr "" -#: classes/class-ep-settings.php:143 +#: classes/class-ep-settings.php:144 msgid "Index complete Refresh the stats" msgstr "" -#: classes/class-ep-settings.php:191 +#: classes/class-ep-settings.php:192 msgid "Elasticsearch Host:" msgstr "" -#: classes/class-ep-settings.php:200 +#: classes/class-ep-settings.php:201 msgid "Use Elasticsearch:" msgstr "" -#: classes/class-ep-settings.php:431 +#: classes/class-ep-settings.php:432 msgid "Elasticsearch Integration Options" msgstr "" @@ -256,11 +257,15 @@ msgstr "" msgid "The following values do not describe a valid date: month %1$s, day %2$s." msgstr "" -#: includes/settings/index.php:42 -msgid "ElasticPress needs to be enabled to run an index." +#: includes/settings/index.php:43 +msgid "Restart Index" msgstr "" #: includes/settings/index.php:45 +msgid "ElasticPress needs to be enabled to run an index." +msgstr "" + +#: includes/settings/index.php:48 msgid "A proper host must be set before running an index." msgstr "" @@ -338,77 +343,71 @@ msgstr "" msgid "Invalid Taxonomy" msgstr "" -#: vendor/wp-cli/wp-cli/php/WP_CLI/CommandWithUpgrade.php:413 +#: vendor/wp-cli/wp-cli/php/WP_CLI/CommandWithUpgrade.php:408 msgid " Try again" msgstr "" -#: vendor/wp-cli/wp-cli/php/WP_CLI/CommandWithUpgrade.php:418 +#: vendor/wp-cli/wp-cli/php/WP_CLI/CommandWithUpgrade.php:413 msgid "API error. Try Again." msgstr "" -#: vendor/wp-cli/wp-cli/php/commands/core.php:638 +#: vendor/wp-cli/wp-cli/php/commands/core.php:658 msgid "Wildcard DNS may not be configured correctly." msgstr "" -#: vendor/wp-cli/wp-cli/php/commands/cron.php:339 +#: vendor/wp-cli/wp-cli/php/commands/cron.php:327 msgid "%s year" msgid_plural "%s years" msgstr[0] "" msgstr[1] "" -#: vendor/wp-cli/wp-cli/php/commands/cron.php:340 +#: vendor/wp-cli/wp-cli/php/commands/cron.php:328 msgid "%s month" msgid_plural "%s months" msgstr[0] "" msgstr[1] "" -#: vendor/wp-cli/wp-cli/php/commands/cron.php:341 +#: vendor/wp-cli/wp-cli/php/commands/cron.php:329 msgid "%s week" msgid_plural "%s weeks" msgstr[0] "" msgstr[1] "" -#: vendor/wp-cli/wp-cli/php/commands/cron.php:342 +#: vendor/wp-cli/wp-cli/php/commands/cron.php:330 msgid "%s day" msgid_plural "%s days" msgstr[0] "" msgstr[1] "" -#: vendor/wp-cli/wp-cli/php/commands/cron.php:343 +#: vendor/wp-cli/wp-cli/php/commands/cron.php:331 msgid "%s hour" msgid_plural "%s hours" msgstr[0] "" msgstr[1] "" -#: vendor/wp-cli/wp-cli/php/commands/cron.php:344 +#: vendor/wp-cli/wp-cli/php/commands/cron.php:332 msgid "%s minute" msgid_plural "%s minutes" msgstr[0] "" msgstr[1] "" -#: vendor/wp-cli/wp-cli/php/commands/cron.php:345 +#: vendor/wp-cli/wp-cli/php/commands/cron.php:333 msgid "%s second" msgid_plural "%s seconds" msgstr[0] "" msgstr[1] "" -#: vendor/wp-cli/wp-cli/php/commands/export.php:264 +#: vendor/wp-cli/wp-cli/php/commands/export.php:256 msgid "Invalid start ID: %d" msgstr "" -#: vendor/wp-cli/wp-cli/php/commands/media.php:65 +#: vendor/wp-cli/wp-cli/php/commands/media.php:58 msgid "image" msgid_plural "images" msgstr[0] "" msgstr[1] "" -#: vendor/wp-cli/wp-cli/php/commands/media.php:75 -msgid "An error occurred with image regeneration." -msgid_plural "An error occurred regenerating one or more images." -msgstr[0] "" -msgstr[1] "" - -#: vendor/wp-cli/wp-cli/php/commands/media.php:79 +#: vendor/wp-cli/wp-cli/php/commands/media.php:66 msgid "the image" msgid_plural "all images" msgstr[0] "" @@ -457,8 +456,8 @@ msgstr "" msgid "http://10up.com" msgstr "" -#: vendor/wp-cli/wp-cli/php/commands/core.php:451 -#: vendor/wp-cli/wp-cli/php/commands/core.php:499 +#: vendor/wp-cli/wp-cli/php/commands/core.php:485 +#: vendor/wp-cli/wp-cli/php/commands/core.php:530 msgctxt "Default network name" msgid "%s Sites" msgstr "" From f725ea740e63abd4fe98f1b3a67c665dce4d898e Mon Sep 17 00:00:00 2001 From: "ryan.veitch" Date: Sun, 28 Feb 2016 02:17:52 -0600 Subject: [PATCH 112/117] Adds Elasticearch Shield username:password login Adds username:password basic authentication headers. Define the constant ES_SHIELD in your wp-config.php Format: `username:password` (colon separated) Example: `define( 'ES_SHIELD', 'es_admin:password' );` --- classes/class-ep-api.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/classes/class-ep-api.php b/classes/class-ep-api.php index 2b71a2efbe..a55bf71f36 100644 --- a/classes/class-ep-api.php +++ b/classes/class-ep-api.php @@ -272,6 +272,20 @@ public function format_request_headers() { $headers['X-ElasticPress-API-Key'] = EP_API_KEY; } + /** + * ES Shield Username & Password + * Adds username:password basic authentication headers + * + * Define the constant ES_SHIELD in your wp-config.php + * Format: 'username:password' (colon separated) + * Example: define( 'ES_SHIELD', 'es_admin:password' ); + * + * @since 1.9 + */ + if ( defined( 'ES_SHIELD' ) && ES_SHIELD ) { + $headers['Authorization'] = 'Basic ' . base64_encode( ES_SHIELD ); + } + $headers = apply_filters( 'ep_format_request_headers', $headers ); return $headers; From 738f9ac7d450a4662c1be82123c1188b1621ffa6 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 3 Mar 2016 15:43:21 -0700 Subject: [PATCH 113/117] Change from using the _status endpoint to using the _recovery endpoint, as the former is deprecated. --- bin/wp-cli.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 6e4c355286..a6b5a411bd 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -567,7 +567,7 @@ public function status() { $request_args = array( 'headers' => ep_format_request_headers() ); - $request = wp_remote_get( trailingslashit( ep_get_host( true ) ) . '_status/?pretty', $request_args ); + $request = wp_remote_get( trailingslashit( ep_get_host( true ) ) . '_recovery/?pretty', $request_args ); if ( is_wp_error( $request ) ) { WP_CLI::error( implode( "\n", $request->get_error_messages() ) ); From 456eef11c63140d1d5127854547f67e4e06fc211 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 11 Mar 2016 10:47:22 -0700 Subject: [PATCH 114/117] Update the readme.md --- README.md | 34 +++++++++++++++++++++++++++++++++- includes/settings/index.php | 10 +++------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d73860f95d..26acea247f 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ There are other Elasticsearch integration plugins available for WordPress. Elast 2. ElasticPress requires WP-CLI. Install it by following [these instructions](http://wp-cli.org). 3. Install the plugin in WordPress. You can download a [zip via Github](https://github.com/10up/ElasticPress/archive/master.zip) and upload it using the WP plugin uploader. -## Configuration +## Configuration Using WP-CLI First, make sure you have Elasticsearch and WP-CLI configured properly. @@ -75,6 +75,38 @@ wp elasticpress index --setup wp elasticpress index --setup --network-wide ``` +## Configuration Using the Admin GUI (requires ElasticPress >= 1.9) + +First, make sure you have Elasticsearch configured properly. + +### Single Site (stand-alone or a single site on a network) + +1. Activate the plugin on the single site you want to index. +2. Go to the settings page, found at Settings > ElasticPress. +3. Set the ElasticSearch host in the proper input, with the connection (and port) of your Elasticsearch application. For example: + +``` +http://192.168.50.4:9200 +``` + +**Note:** The URL for the ElasticSearch host *must* begin with a protocol specifier (`http` or `https`). URLs without a protocol prefix will not be parsed correctly and will cause ElasticPress to error out. + +### Multisite Cross-site Search + +1. Network activate the plugin +2. Go to the settings page, found at Settings > ElasticPress, in the Network Admin. +3. Set the ElasticSearch host in the proper input, with the connection (and port) of your Elasticsearch application. For example: + +``` +http://192.168.50.4:9200 +``` + +**Note:** The URL for the ElasticSearch host *must* begin with a protocol specifier (`http` or `https`). URLs without a protocol prefix will not be parsed correctly and will cause ElasticPress to error out. + +#### Indexing +1. Once a proper host is set, you can now click the Run Index button to start the indexing process. +2. Once indexing is done, refresh this page to view the status and some stats. + After your index finishes, ```WP_Query``` will be integrated with Elasticsearch and support a few special parameters. ### Creating Elasticsearch Indices diff --git a/includes/settings/index.php b/includes/settings/index.php index 6fe631d997..c44504f7c1 100644 --- a/includes/settings/index.php +++ b/includes/settings/index.php @@ -37,13 +37,9 @@

    - - > - > - - - - + > + > + From 1ee0792c2d5d3828917cc5b75e40b58ae90e1e00 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 11 Mar 2016 11:45:27 -0700 Subject: [PATCH 115/117] Update the readme.txt --- README.md | 13 +++++++++++-- readme.txt | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 26acea247f..7668a1630e 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,12 @@ There are other Elasticsearch integration plugins available for WordPress. Elast * [Elasticsearch](https://www.elastic.co) 1.3+ * [WordPress](http://wordpress.org) 3.7.1+ -* [WP-CLI](http://wp-cli.org/) 0.13+ +* [WP-CLI](http://wp-cli.org/) 0.13+, if using WP-CLI for indexing ## Installation 1. First, you will need to properly [install and configure](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html) Elasticsearch. -2. ElasticPress requires WP-CLI. Install it by following [these instructions](http://wp-cli.org). +2. ElasticPress requires WP-CLI, if you want to use WP-CLI for indexing. Install it by following [these instructions](http://wp-cli.org). 3. Install the plugin in WordPress. You can download a [zip via Github](https://github.com/10up/ElasticPress/archive/master.zip) and upload it using the WP plugin uploader. ## Configuration Using WP-CLI @@ -572,6 +572,15 @@ The following commands are supported by ElasticPress: * `wp elasticpress status` +### Other Supported Params + +* ElasticPress can be used with the [Elasticsearch Shield](https://www.elastic.co/products/shield) plugin + + * Define the constant ```ES_SHIELD``` in your ```wp-config.php``` file with the username and password of your Elasticsearch Shield user. For example: + +```php +define( 'ES_SHIELD', 'username:password' ); +``` ## Development diff --git a/readme.txt b/readme.txt index a36abfa5ce..4ee02c34cf 100644 --- a/readme.txt +++ b/readme.txt @@ -30,16 +30,16 @@ Coupling WordPress with Elasticsearch allows us to do amazing things with search * Search all sites on a multisite install * [The list goes on...](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search.html) -_Note:_ Requires [WP-CLI](http://wp-cli.org/) and [Elasticsearch](http://www.elasticsearch.org/). +_Note:_ Requires [Elasticsearch](http://www.elasticsearch.org/) and [WP-CLI](http://wp-cli.org/), if using WP-CLI for indexing. Please refer to [Github](https://github.com/10up/ElasticPress) for detailed usage instructions and documentation. == Installation == 1. First, you will need to properly [install and configure](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_installing_elasticsearch.html) Elasticsearch. -2. Install [WP-CLI](http://wp-cli.org/). +2. Install [WP-CLI](http://wp-cli.org/), if using for indexing. 3. Install the plugin in WordPress. -= Configuration = += Configuration Using WP-CLI = First, make sure you have Elasticsearch configured properly and WP-CLI setup. @@ -58,8 +58,51 @@ configuring single site and multi-site cross-site search are slightly different. 3. If you would like to define backup servers in case EP_HOST fails enter `global $ep_backup_host` in wp-config.php and then instantiate the variable with an array of backup hosts to use. 4. Using WP-CLI, do an initial sync (with mapping) with your ES server by running: `wp elasticpress index --setup --network-wide`. += Configuration Using the Admin GUI (requires ElasticPress >= 1.9) = + +First, make sure you have Elasticsearch configured properly. + += Single Site (stand-alone or a single site on a network) = + +1. Activate the plugin on the single site you want to index. +2. Go to the settings page, found at Settings > ElasticPress. +3. Set the ElasticSearch host in the proper input, with the connection (and port) of your Elasticsearch application. + += Multisite Cross-site Search = + +1. Network activate the plugin +2. Go to the settings page, found at Settings > ElasticPress, in the Network Admin. +3. Set the ElasticSearch host in the proper input, with the connection (and port) of your Elasticsearch application. + += Indexing = +1. Once a proper host is set, you can now click the Run Index button to start the indexing process. +2. Once indexing is done, refresh this page to view the status and some stats. + == Changelog == += 1.9 = + +ElasticPress 1.9 adds in an admin UI, where you can set your Elasticsearch Host and run your index command, without needing to us WP-CLI. Version 1.9 also adds in some performance improvements to reduce memory consumption during indexing. Full list of enhancements and bug fixes: + +### Enhancements: +* Add in an Admin GUI to handle indexing. Props [ChrisWiegman](https://github.com/ChrisWiegman). +* Add option to not disable ElasticPress while indexing. Props [lukaspawlik](https://github.com/lukaspawlik). +* Allow filtering of which post types we want to search for. Props [rossluebe](https://github.com/rossluebe). +* Remove composer.lock from the repo. Props [ChrisWiegman](https://github.com/ChrisWiegman). +* Ensure both PHPUnit and WP-CLI are available in the development environment. Props [ChrisWiegman](https://github.com/ChrisWiegman). +* User lower-case for our composer name, so packagist can find us. Props [johnpbloch](https://github.com/johnpbloch). +* Check query_vars, not query to determine status. Props [ChrisWiegman](https://github.com/ChrisWiegman). +* Improve memory usage during indexing and fix unnecessary cache flushes. Props [cmmarslender](https://github.com/cmmarslender). +* Further reduce memory usage during indexing. Props [lukaspawlik](https://github.com/lukaspawlik). +* Add post__in and post__not_in documentation. Props [mgibbs189](https://github.com/mgibbs189). +* Add Elasticsearch Shield authentication headers if constant is set. Props [rveitch](https://github.com/rveitch). + +### Bugs: +* Fix the --no-bulk indexing option. Props [lukaspawlik](https://github.com/lukaspawlik). +* Fixed an error that occurs if no Elasticsearch host is running. Props [petenelson](https://github.com/petenelson). +* Fixed an exception error. Props [dkotter](https://github.com/dkotter). +* Fixed the WP-CLI status command. Props [dkotter](https://github.com/dkotter). + = 1.8 (Mapping change, requires reindex) = ElasticPress 1.8 adds a bunch of mapping changes for accomplishing more complex WP_Query functions such as filtering by term id and sorting by any Elasticsearch property. Version 1.8 also speeds up post syncing dramatically through non-blocking queries. Full list of enhancements and bug fixes: From 67a9448c30ade392e42f30a32215d2a1572d72d7 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Mon, 14 Mar 2016 16:16:45 -0600 Subject: [PATCH 116/117] Modify contributors. --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 4ee02c34cf..0021a87473 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ === ElasticPress === -Contributors: aaronholbrook, tlovett1, ChrisWiegman, sc0ttkclark, collinsinternet, 10up +Contributors: aaronholbrook, tlovett1, ChrisWiegman, sc0ttkclark, collinsinternet, dkotter, 10up Author URI: http://10up.com Plugin URI: https://github.com/10up/ElasticPress Tags: search, elasticsearch, fuzzy, facet, searching, autosuggest, suggest, elastic, advanced search From f6d0e921ba6f2d3b1b9a20e29e6d9aab49cf889a Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Tue, 15 Mar 2016 09:35:20 -0600 Subject: [PATCH 117/117] Bump version to 1.9 --- elasticpress.php | 4 ++-- lang/elasticpress.pot | 32 ++++++++++++++------------------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/elasticpress.php b/elasticpress.php index abc5f302dd..d4e1fbfc2a 100644 --- a/elasticpress.php +++ b/elasticpress.php @@ -3,7 +3,7 @@ /** * Plugin Name: ElasticPress * Description: Integrate WordPress search with Elasticsearch - * Version: 1.8 + * Version: 1.9 * Author: Aaron Holbrook, Taylor Lovett, Matt Gross, 10up * Author URI: http://10up.com * License: GPLv2 or later @@ -20,7 +20,7 @@ } define( 'EP_URL', plugin_dir_url( __FILE__ ) ); -define( 'EP_VERSION', '1.8' ); +define( 'EP_VERSION', '1.9' ); require_once( 'classes/class-ep-config.php' ); require_once( 'classes/class-ep-api.php' ); diff --git a/lang/elasticpress.pot b/lang/elasticpress.pot index 2d6ac66a4c..d90179a49c 100644 --- a/lang/elasticpress.pot +++ b/lang/elasticpress.pot @@ -2,16 +2,16 @@ # This file is distributed under the GPLv2 or later. msgid "" msgstr "" -"Project-Id-Version: ElasticPress 1.8\n" +"Project-Id-Version: ElasticPress 1.9\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/elasticpress\n" -"POT-Creation-Date: 2016-02-25 22:32:52+00:00\n" +"POT-Creation-Date: 2016-03-15 15:34:46+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -"X-Generator: grunt-wp-i18n 0.5.3\n" +"X-Generator: grunt-wp-i18n 0.5.4\n" #: bin/wp-cli.php:55 msgid "Adding mapping for site %d..." @@ -85,41 +85,41 @@ msgstr "" msgid "Total time elapsed: " msgstr "" -#: bin/wp-cli.php:532 +#: bin/wp-cli.php:541 msgid "" "The following posts failed to index:\r\n" "\r\n" msgstr "" -#: bin/wp-cli.php:718 classes/class-ep-config.php:174 +#: bin/wp-cli.php:745 classes/class-ep-config.php:186 msgid "EP_HOST is not defined! Check wp-config.php" msgstr "" -#: bin/wp-cli.php:722 classes/class-ep-config.php:178 +#: bin/wp-cli.php:749 classes/class-ep-config.php:190 msgid "Unable to reach Elasticsearch Server! Check that service is running." msgstr "" -#: classes/class-ep-api.php:1764 +#: classes/class-ep-api.php:1778 msgid "" "Invalid response from ElasticPress server. Please contact your " "administrator." msgstr "" -#: classes/class-ep-api.php:1777 +#: classes/class-ep-api.php:1791 msgid "" "Site not indexed.

    Please run: wp elasticpress index --setup " "--network-wide using WP-CLI. Or use the index button on the left of " "this screen.

    " msgstr "" -#: classes/class-ep-api.php:1781 +#: classes/class-ep-api.php:1795 msgid "" "Site not indexed.

    Please run: wp elasticpress index --setup " "using WP-CLI. Or use the index button on the left of this screen.

    " msgstr "" -#: classes/class-ep-api.php:1819 classes/class-ep-api.php:1878 -#: classes/class-ep-api.php:1918 classes/class-ep-api.php:1969 +#: classes/class-ep-api.php:1833 classes/class-ep-api.php:1892 +#: classes/class-ep-api.php:1932 classes/class-ep-api.php:1983 msgid "Elasticsearch Host is not available." msgstr "" @@ -181,7 +181,7 @@ msgstr "" msgid "Index Status" msgstr "" -#: classes/class-ep-index-worker.php:398 +#: classes/class-ep-index-worker.php:410 msgid ": ElasticPress Index Errors" msgstr "" @@ -257,15 +257,11 @@ msgstr "" msgid "The following values do not describe a valid date: month %1$s, day %2$s." msgstr "" -#: includes/settings/index.php:43 +#: includes/settings/index.php:42 msgid "Restart Index" msgstr "" -#: includes/settings/index.php:45 -msgid "ElasticPress needs to be enabled to run an index." -msgstr "" - -#: includes/settings/index.php:48 +#: includes/settings/index.php:44 msgid "A proper host must be set before running an index." msgstr ""
    ::