| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for ElasticPress install page |
| 4 |
* |
| 5 |
* @since 2.1 |
| 6 |
* @package elasticpress |
| 7 |
*/ |
| 8 |
|
| 9 |
use ElasticPress\FeatureRequirementsStatus; |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; // Exit if accessed directly. |
| 13 |
} |
| 14 |
|
| 15 |
$install_status = \ElasticPress\Installer::factory()->get_install_status(); |
| 16 |
|
| 17 |
if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { |
| 18 |
$setup_url = admin_url( 'network/admin.php?page=elasticpress-settings' ); |
| 19 |
$dashboard_url = admin_url( 'network/admin.php?page=elasticpress' ); |
| 20 |
} else { |
| 21 |
$setup_url = admin_url( 'admin.php?page=elasticpress-settings' ); |
| 22 |
$dashboard_url = admin_url( 'admin.php?page=elasticpress' ); |
| 23 |
} |
| 24 |
|
| 25 |
$sync_url = \ElasticPress\Utils\get_sync_url( 'install' ); |
| 26 |
|
| 27 |
$skip_install_url = add_query_arg( |
| 28 |
[ |
| 29 |
'ep-skip-install' => 1, |
| 30 |
'ep-skip-features' => 1, |
| 31 |
'nonce' => wp_create_nonce( 'ep-skip-install' ), |
| 32 |
] |
| 33 |
); |
| 34 |
|
| 35 |
$skip_index_url = remove_query_arg( 'ep-skip-features', $skip_install_url ); |
| 36 |
?> |
| 37 |
|
| 38 |
<?php require_once __DIR__ . '/header.php'; ?> |
| 39 |
|
| 40 |
<div class="wrap intro"> |
| 41 |
<h1><?php esc_html_e( 'A Fast and Flexible Search and Query Engine for WordPress.', 'elasticpress' ); ?></h1> |
| 42 |
|
| 43 |
<?php if ( isset( $_GET['install_complete'] ) ) : // phpcs:ignore WordPress.Security.NonceVerification ?> |
| 44 |
<div class="intro-container-success"> |
| 45 |
<h2 class="setup-complete">Setup Completed!</h2> |
| 46 |
<div class="ep-circle ep-circle--active ep-config-success"> |
| 47 |
<span class="dashicons dashicons-yes"></span> |
| 48 |
</div> |
| 49 |
<p><?php esc_html_e( 'That’s it! You’re ready to experience faster search and gain the ability to create powerful queries on your site!', 'elasticpress' ); ?></p> |
| 50 |
<div class="setup-message"> |
| 51 |
<a class="setup-button" href="<?php echo esc_url( $dashboard_url ); ?>"><?php esc_html_e( 'Go to dashboard', 'elasticpress' ); ?></a> |
| 52 |
</div> |
| 53 |
</div> |
| 54 |
<?php else : ?> |
| 55 |
<form method="post" action=""> |
| 56 |
<?php wp_nonce_field( 'ep_install_page', 'ep_install_page_nonce' ); ?> |
| 57 |
<div class="intro-container"> |
| 58 |
<div class="intro-box"> |
| 59 |
<div class="ep-circle ep-circle--first white-ep-circle"> |
| 60 |
<?php esc_html_e( 'Step', 'elasticpress' ); ?><p>1</p> |
| 61 |
</div> |
| 62 |
<h2><?php esc_html_e( 'Plugin has been installed', 'elasticpress' ); ?></h2> |
| 63 |
<p class="ep-copy-text"><?php esc_html_e( 'You\'ve taken your first step into a faster and more flexible search and query engine for WordPress', 'elasticpress' ); ?></p> |
| 64 |
</div> |
| 65 |
<div class="intro-box"> |
| 66 |
<div class="ep-circle <?php echo 2 === $install_status ? 'ep-circle--active' : ''; ?>"> |
| 67 |
<?php esc_html_e( 'Step', 'elasticpress' ); ?><p>2</p> |
| 68 |
</div> |
| 69 |
<h2><?php esc_html_e( 'Set up Elasticsearch hosting', 'elasticpress' ); ?></h2> |
| 70 |
<p class="ep-copy-text"> |
| 71 |
<?php echo wp_kses_post( __( 'The next step is to make sure you have a working Elasticsearch server. We recommend creating an <a href="https://elasticpress.io" target="_blank">ElasticPress.io</a> account or if you want you can set up your own hosting.', 'elasticpress' ) ); ?> |
| 72 |
</p> |
| 73 |
<?php if ( 2 === $install_status ) : ?> |
| 74 |
<div class="setup-message"> |
| 75 |
<a class="setup-button" href="<?php echo esc_url( $setup_url ); ?>"><?php esc_html_e( 'Got hosting? Get Started', 'elasticpress' ); ?></a> |
| 76 |
<p><a href="<?php echo esc_url( $skip_install_url ); ?>"><?php esc_html_e( 'Skip Install »', 'elasticpress' ); ?></a></p> |
| 77 |
</div> |
| 78 |
<?php endif; ?> |
| 79 |
</div> |
| 80 |
<div class="intro-box"> |
| 81 |
<div class="ep-circle <?php echo 3 === $install_status ? 'ep-circle--active' : ''; ?>"> |
| 82 |
<?php esc_html_e( 'Step', 'elasticpress' ); ?><p>3</p> |
| 83 |
</div> |
| 84 |
<h2><?php esc_html_e( 'Select your features', 'elasticpress' ); ?></h2> |
| 85 |
<div class="ep-copy-text"> |
| 86 |
<p><?php esc_html_e( 'ElasticPress will sync the data you select, then keep it up-to-date automatically.', 'elasticpress' ); ?></p> |
| 87 |
<?php if ( 3 === $install_status ) : ?> |
| 88 |
<ul class="ep-feature-list"> |
| 89 |
<?php |
| 90 |
$features = \ElasticPress\Features::factory()->registered_features; |
| 91 |
foreach ( $features as $feature ) { |
| 92 |
$feature_status_code = (int) $feature->requirements_status()->get_code(); |
| 93 |
$activation_available = $feature->available_during_installation; |
| 94 |
|
| 95 |
if ( in_array( $feature_status_code, [ FeatureRequirementsStatus::FORCE_DISABLED, FeatureRequirementsStatus::TEMPORARILY_DISABLED ], true ) ) { |
| 96 |
continue; |
| 97 |
} |
| 98 |
|
| 99 |
if ( ! $activation_available ) { |
| 100 |
continue; |
| 101 |
} |
| 102 |
|
| 103 |
$should_be_checked = FeatureRequirementsStatus::AUTO_ENABLED === $feature_status_code || $feature->is_active(); |
| 104 |
?> |
| 105 |
<li> |
| 106 |
<label> |
| 107 |
<input |
| 108 |
type="checkbox" |
| 109 |
name="features[]" |
| 110 |
value="<?php echo esc_attr( $feature->slug ); ?>" |
| 111 |
<?php checked( $should_be_checked ); ?>> |
| 112 |
<?php echo esc_html( $feature->get_short_title() ); ?> |
| 113 |
</label> |
| 114 |
<?php if ( $feature->summary ) : ?> |
| 115 |
<span class="a11y-tip a11y-tip--no-delay"> |
| 116 |
<a href="<?php echo esc_url( $feature->docs_url ); ?>" class="a11y-tip__trigger ep-feature-info" target="_blank" rel="noreferrer noopener"> |
| 117 |
<span class="dashicons dashicons-info" role="presentation"></span> |
| 118 |
<span class="screen-reader-text"> |
| 119 |
<?php |
| 120 |
printf( |
| 121 |
/* translators: %s: Feature name. */ |
| 122 |
esc_html__( 'Learn more about %s.', 'elasticpress' ), |
| 123 |
esc_html( $feature->get_short_title() ) |
| 124 |
); |
| 125 |
?> |
| 126 |
</span> |
| 127 |
</a> |
| 128 |
<span role="tooltip" class="a11y-tip__help a11y-tip__help--top"> |
| 129 |
<?php echo wp_kses( $feature->summary, 'ep-html' ); ?> |
| 130 |
<?php esc_html_e( 'Click to learn more.', 'elasticpress' ); ?> |
| 131 |
</span> |
| 132 |
</span> |
| 133 |
<?php endif; ?> |
| 134 |
</li> |
| 135 |
<?php |
| 136 |
} |
| 137 |
?> |
| 138 |
</ul> |
| 139 |
<p><?php esc_html_e( 'Don\'t worry if you\'re not sure what features you need, you can always make changes to them later on.', 'elasticpress' ); ?></p> |
| 140 |
<?php endif; ?> |
| 141 |
</div> |
| 142 |
<?php if ( 3 === $install_status ) : ?> |
| 143 |
<div class="setup-message"> |
| 144 |
<button type="submit" class="setup-button"><?php esc_html_e( 'Save Features', 'elasticpress' ); ?></button> |
| 145 |
<p><a href="<?php echo esc_url( $skip_install_url ); ?>"><?php esc_html_e( 'Skip Install »', 'elasticpress' ); ?></a></p> |
| 146 |
</div> |
| 147 |
<?php endif; ?> |
| 148 |
</div> |
| 149 |
<div class="intro-box"> |
| 150 |
<div class="ep-circle <?php echo 4 === $install_status ? 'ep-circle--active' : ''; ?>"> |
| 151 |
<?php esc_html_e( 'Step', 'elasticpress' ); ?><p>4</p> |
| 152 |
</div> |
| 153 |
<h2><?php esc_html_e( 'Index your content', 'elasticpress' ); ?></h2> |
| 154 |
<p class="ep-copy-text"> |
| 155 |
<?php esc_html_e( 'Click below to index your content through ElasticPress. You can also activate optional Features such as Protected Content and Autosuggest in the Features page', 'elasticpress' ); ?> |
| 156 |
</p> |
| 157 |
<?php if ( 4 === $install_status ) : ?> |
| 158 |
<div class="setup-message"> |
| 159 |
<a class="setup-button" href="<?php echo esc_url( $sync_url ); ?>"><?php esc_html_e( 'Index Your Content', 'elasticpress' ); ?></a> |
| 160 |
<p><a href="<?php echo esc_url( $skip_index_url ); ?>"><?php esc_html_e( 'Skip Install »', 'elasticpress' ); ?></a></p> |
| 161 |
</div> |
| 162 |
<?php endif; ?> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
</form> |
| 166 |
<?php endif; ?> |
| 167 |
</div> |
| 168 |
|