-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3162 from 10up/feature/new-epio-page
Create a new ElasticPress.io page with client messages
- Loading branch information
Showing
8 changed files
with
160 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ | |
margin-bottom: 1rem; | ||
} | ||
|
||
& .components-notice { | ||
margin: 0; | ||
} | ||
|
||
& table { | ||
table-layout: fixed; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Class for interacting with ElasticPress.io | ||
* | ||
* @since 4.5.0 | ||
* @package elasticpress | ||
*/ | ||
|
||
namespace ElasticPress; | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; // Exit if accessed directly. | ||
} | ||
|
||
/** | ||
* ElasticPressIo class | ||
* | ||
* @package ElasticPress | ||
*/ | ||
class ElasticPressIo { | ||
/** | ||
* Return singleton instance of class | ||
* | ||
* @return object | ||
*/ | ||
public static function factory() { | ||
static $instance = false; | ||
|
||
if ( ! $instance ) { | ||
$instance = new self(); | ||
} | ||
|
||
return $instance; | ||
} | ||
|
||
/** | ||
* Get messages from ElasticPress.io. | ||
* | ||
* @return array ElasticPress.io messages. | ||
*/ | ||
public function get_endpoint_messages() { | ||
$transient = 'ep_elasticpress_io_messages'; | ||
$messages = get_transient( $transient ); | ||
|
||
if ( false !== $messages ) { | ||
return $messages; | ||
} | ||
|
||
$response = \ElasticPress\Elasticsearch::factory()->remote_request( 'endpoint-messages' ); | ||
$messages = (array) json_decode( wp_remote_retrieve_body( $response ), true ); | ||
|
||
set_transient( $transient, $messages, HOUR_IN_SECONDS ); | ||
|
||
return $messages; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters