Skip to content

Commit

Permalink
Merge pull request #446 from Codeinwp/feat/hyve-promo
Browse files Browse the repository at this point in the history
Feat/hyve promo
  • Loading branch information
HardeepAsrani authored Sep 17, 2024
2 parents f1433e5 + 600fd87 commit e5e98bf
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Setup PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.1'
php-version: '7.2'
extensions: simplexml, mysql
tools: phpunit-polyfills
- name: Checkout source code
Expand All @@ -73,5 +73,5 @@ jobs:
- name: Install composer
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
- name: Run phpunit
run: phpunit
run: composer run-script phpunit

23 changes: 23 additions & 0 deletions assets/css/style-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,29 @@ input[type="button"].button.button-secondary.is-busy {
height: 1em;
}

.wpmm-notice {
background-color: #fff;
border-left: 4px solid #00a0d2;
box-shadow: 0 1px 1px rgba(0,0,0,.04);
padding: 12px;
display: flex;
align-items: center;
}

.wpmm-notice-content {
flex-grow: 1;
}

.wpmm-notice h3 {
margin: 0.5em 0;
font-size: 14px;
}

.wpmm-notice p {
margin: 0.5em 0;
font-size: 13px;
}

@keyframes spin {
from {
transform: rotate(0deg);
Expand Down
2 changes: 2 additions & 0 deletions assets/css/style-wizard.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ h2.wpmm-title span img {

letter-spacing: .04em;
line-height: 1;
--checkbox-input-size: 20px;
--checkmark-size: calc(var(--checkbox-input-size) + 4px);
}

#wpmm-wizard-wrapper .slider-wrap {
Expand Down
46 changes: 34 additions & 12 deletions assets/js/scripts-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ jQuery( function( $ ) {
$( this ).addClass( 'is-busy' );
$( this ).trigger( 'blur' );

handleOptimole().then( function() {
handlePlugins().then( function() {
$.post( wpmmVars.ajaxURL, {
action: 'wpmm_skip_wizard',
_wpnonce: wpmmVars.wizardNonce,
Expand Down Expand Up @@ -519,7 +519,7 @@ jQuery( function( $ ) {
*/
function importTemplate( data, callback ) {
handleOtter()
.then( () => handleOptimole() )
.then( () => handlePlugins() )
.then( () => addToPage( data, callback ) )
.catch( ( error ) => {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -575,23 +575,43 @@ jQuery( function( $ ) {
}

/**
* Install and activate Optimole if the checkbox is checked.
* Install and activate recommended plugins if the checkboxes is checked.
*/
function handleOptimole() {
function handlePlugins() {
const optimoleCheckbox = $( '#wizard-optimole-checkbox' );
const hyveCheckbox = $( '#wizard-hyve-checkbox' );

let promiseChain = Promise.resolve();

if ( optimoleCheckbox.length && optimoleCheckbox.is( ':checked' ) ) {
if ( ! wpmmVars.isOptimoleInstalled ) {
return installPlugin( 'optimole-wp' )
.then( () => {
promiseChain = promiseChain
.then(() => {
if ( ! wpmmVars.isOptimoleInstalled ) {
return installPlugin( 'optimole-wp' ).then( () => activatePlugin( 'optimole-wp' ) );
}

if ( ! wpmmVars.isOptimoleActive ) {
return activatePlugin( 'optimole-wp' );
} );
} else if ( ! wpmmVars.isOptimoleActive ) {
return activatePlugin( 'optimole-wp' );
}
}
});
}

return Promise.resolve();
if ( hyveCheckbox.length && hyveCheckbox.is( ':checked' ) ) {
promiseChain = promiseChain
.then(() => {
if ( ! wpmmVars.isHyveInstalled ) {
return installPlugin( 'hyve-lite' ).then( () => activatePlugin( 'hyve-lite' ) );
}

if ( ! wpmmVars.isHyveActive ) {
return activatePlugin( 'hyve-lite' );
}
});
}

return promiseChain.catch( ( error ) => {
console.error( 'Error in plugin installation or activation:', error );
});
}

/**
Expand Down Expand Up @@ -656,6 +676,8 @@ jQuery( function( $ ) {
return $.get( wpmmVars.otterActivationLink );
case 'optimole-wp':
return $.get( wpmmVars.optimoleActivationLink );
case 'hyve-lite':
return $.get( wpmmVars.hyveActivationLink );
default:
break;
}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"format-fix-exit": "./vendor/bin/phpcbf-fix-exit-0 --standard=phpcs.xml --report-summary --report-source -s --runtime-set testVersion 7.0- ",
"phpcs": "phpcs --standard=phpcs.xml -s --runtime-set testVersion 7.0-",
"lint": "composer run-script phpcs",
"phpcs-i": "phpcs -i"
"phpcs-i": "phpcs -i",
"phpunit": "phpunit"
}
}
14 changes: 13 additions & 1 deletion includes/classes/wp-maintenance-mode-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public function enqueue_admin_scripts() {
'isOtterActive' => is_plugin_active( 'otter-blocks/otter-blocks.php' ),
'isOptimoleInstalled' => file_exists( ABSPATH . 'wp-content/plugins/optimole-wp/optimole-wp.php' ),
'isOptimoleActive' => is_plugin_active( 'optimole-wp/optimole-wp.php' ),
'isHyveInstalled' => file_exists( ABSPATH . 'wp-content/plugins/hyve-lite/hyve-lite.php' ),
'isHyveActive' => is_plugin_active( 'hyve-lite/hyve-lite.php' ),
'errorString' => __( 'Something went wrong, please try again.', 'wp-maintenance-mode' ),
'loadingString' => __( 'Doing some magic...', 'wp-maintenance-mode' ),
'importingText' => __( 'Importing', 'wp-maintenance-mode' ),
Expand Down Expand Up @@ -187,6 +189,16 @@ public function enqueue_admin_scripts() {
),
esc_url( network_admin_url( 'plugins.php' ) )
),
'hyveActivationLink' => add_query_arg(
array(
'action' => 'activate',
'plugin' => rawurlencode( 'hyve-lite/hyve-lite.php' ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce( 'activate-plugin_hyve-lite/hyve-lite.php' ),
),
esc_url( network_admin_url( 'plugins.php' ) )
),
'modalTexts' => array(
'title' => __( 'The template has been imported!', 'wp-maintenance-mode' ),
'description' => __( 'The template has been imported to a new draft page. You can take a look and enable it from plugin settings.', 'wp-maintenance-mode' ),
Expand Down Expand Up @@ -1169,7 +1181,7 @@ public function add_display_post_states( $post_states, $post ) {
* @return string
*/
public function add_wizard_classes( $classes ) {
if ( get_option( 'wpmm_fresh_install', false ) ) {
if ( ! get_option( 'wpmm_fresh_install', false ) ) {
$classes .= 'wpmm-wizard-fullscreen';
}

Expand Down
23 changes: 22 additions & 1 deletion views/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@
$this->plugin_settings['design']['page_id'] = 0;
}

$is_otter_active = is_plugin_active( 'otter-blocks/otter-blocks.php' ) || defined( 'OTTER_BLOCKS_VERSION' );
$is_otter_active = is_plugin_active( 'otter-blocks/otter-blocks.php' ) || defined( 'OTTER_BLOCKS_VERSION' );
$is_hyve_installed = file_exists( ABSPATH . 'wp-content/plugins/hyve-lite/hyve-lite.php' ) || defined( 'HYVE_LITE_VERSION' );

$hyve_url = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => 'hyve-lite',
'TB_iframe' => true,
'width' => 800,
'height' => 800,
),
network_admin_url( 'plugin-install.php' )
);
?>
<div class="wrap">
<h2 class="wpmm-title"><?php echo esc_html( get_admin_page_title() ); ?>
Expand Down Expand Up @@ -818,6 +830,15 @@ class="button image_uploader_trigger"
<tbody>
<tr valign="top">
<td colspan="2">
<?php if ( ! $is_hyve_installed ) : ?>
<div class="wpmm-notice">
<div class="wpmm-notice-content">
<h3><?php esc_html_e( 'Enhance Your WordPress Site with Hyve AI Chatbot', 'wp-maintenance-mode' ); ?></h3>
<p><?php esc_html_e( 'Hyve is an AI chatbot plugin for WordPress, ideal for sites in maintenance mode. It enhances user experience by turning your content into interactive conversations, helping visitors access information while your site is under development.', 'wp-maintenance-mode' ); ?></p>
</div>
<a target="_black" href="<?php echo esc_url( $hyve_url ); ?>" class="button button-primary"><?php esc_html_e( 'Install Hyve', 'wp-maintenance-mode' ); ?></a>
</div>
<?php endif; ?>
<h4><?php esc_html_e( 'Setup the conversation steps to capture more subscribers with this friendly way of asking email addresses.', 'wp-maintenance-mode' ); ?></h4>
<p><?php esc_html_e( 'You may also want to use these wildcards: {bot_name} and {visitor_name} to make the conversation even more realistic.', 'wp-maintenance-mode' ); ?></p>
<p><?php esc_html_e( 'It is also ok if you don\'t fill in all the conversation steps if you don\'t need to.', 'wp-maintenance-mode' ); ?></p>
Expand Down
26 changes: 26 additions & 0 deletions views/wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@
?>
</div>
<?php } ?>

<?php if ( ! is_plugin_active( 'hyve-lite/hyve-lite.php' ) || ! defined( 'HYVE_LITE_VERSION' ) ) { ?>
<div class="optimole-upsell">
<div class="optimole-upsell-container">
<span class="components-checkbox-control__input-container">
<input id="wizard-hyve-checkbox" type="checkbox" class="components-checkbox-control__input" checked>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="presentation" class="components-checkbox-control__checked" aria-hidden="true" focusable="false"><path d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"></path></svg>
</span>
<label for="wizard-hyve-checkbox">
<?php esc_html_e( 'Interactive Chatbot', 'wp-maintenance-mode' ); ?>
</label>
</div>
<p class="description">
<?php
printf(
wp_kses(
/* translators: Hyve Lite url */
__( '<a href="%1$s" target="_blank">Hyve%2$s</a> is an AI chatbot plugin for WordPress, ideal for sites in maintenance mode. It enhances user experience by turning your content into interactive conversations, helping visitors access information while your site is under development.', 'wp-maintenance-mode' ),
wpmm_translated_string_allowed_html()
),
esc_url( 'https://wordpress.org/plugins/hyve-lite/' ),
$this->get_external_link_icon()
);
?>
</div>
<?php } ?>
<div id="wizard-buttons" class="import-button">
<input type="button" class="button button-big button-primary disabled button-import" value="<?php esc_html_e( 'Continue', 'wp-maintenance-mode' ); ?>"/>
<input type="button" class="button button-big button-secondary button-skip" value="<?php esc_html_e( 'I don’t want to use a template', 'wp-maintenance-mode' ); ?>"/>
Expand Down

0 comments on commit e5e98bf

Please sign in to comment.