Skip to content

Commit

Permalink
Merge branch 'master' into latest
Browse files Browse the repository at this point in the history
  • Loading branch information
priyomukul committed Apr 23, 2021
2 parents 53257f2 + 1134c82 commit bcc97b9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 51 deletions.
88 changes: 47 additions & 41 deletions EmbedPress/Includes/Classes/EmbedPress_Notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ public function hooks(){
}
$return_notice = $this->next_notice();
$current_notice = current( $return_notice );
$next_notice = next( $return_notice );
$next_notice = next( $return_notice );

$deserve_notice = $this->deserve_notice( $current_notice );
$options_data = $this->get_options_data();
$user_notices = $this->get_user_notices();

$notice_time = isset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] )
$notice_time = isset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] )
? $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] : $this->timestamp;
$next_notice_time = $next_notice ? $options_data[ $this->plugin_name ]['notice_will_show'][ $next_notice ] : $this->timestamp;
$current_notice_end = $this->makeTime( $notice_time, $this->cne_time );
Expand All @@ -177,7 +177,7 @@ public function hooks(){
$notice_time = false;
}
}

if( $notice_time != false ) {
if( $notice_time <= $this->timestamp ) {
if( $current_notice === 'upsale' ) {
Expand All @@ -195,7 +195,7 @@ public function hooks(){
return;
}
break;
case 'function' :
case 'function' :
if( isset( $upsale_args['condition']['function'] ) && function_exists( $upsale_args['condition']['function'] ) ) {
unset( $options_data[ $this->plugin_name ]['notice_will_show'][ $current_notice ] );
$this->update_options_data( $options_data[ $this->plugin_name ] );
Expand All @@ -204,14 +204,16 @@ public function hooks(){
break;
}
}
if ( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
$pkey = $upsale_args['slug'] . '/' . $upsale_args['file'];
if( isset( $plugins[ $pkey ] ) ) {
$this->update( $current_notice );
return;
if( isset( $upsale_args['slug'], $upsale_args['file'] ) ) {
if ( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
$pkey = $upsale_args['slug'] . '/' . $upsale_args['file'];
if( isset( $plugins[ $pkey ] ) ) {
$this->update( $current_notice );
return;
}
}
add_action( 'admin_notices', array( $this, 'upsale_notice' ) );
}
Expand Down Expand Up @@ -249,7 +251,7 @@ private function maybe_later( $notice ){
* When links are clicked, this function will invoked.
* @return void
*/
public function clicked(){
public function clicked(){
if( isset( $_GET['plugin'] ) ) {
$plugin = sanitize_text_field( $_GET['plugin'] );
if( $plugin === $this->plugin_name ) {
Expand All @@ -264,38 +266,38 @@ public function clicked(){
if( isset( $_GET['later'] ) ) {
$later = sanitize_text_field( $_GET['later'] );
}

$later_time = '';

switch( $clicked_from ) {

case 'opt_in' :
$dismiss = ( isset( $plugin_action ) ) ? $plugin_action : false ;
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
case 'first_install' :

case 'first_install' :
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
case 'update' :

case 'update' :
$dismiss = ( isset( $plugin_action ) ) ? $plugin_action : false ;
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
case 'review' :

case 'review' :
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
case 'upsale' :

case 'upsale' :
$later_time = $this->makeTime( $this->timestamp, $this->maybe_later_time );
break;
}
if( isset( $later ) && $later == true ) {

if( isset( $later ) && $later == true ) {
$options_data[ $this->plugin_name ]['notice_will_show'][ $clicked_from ] = $later_time;
}
if( isset( $dismiss ) && $dismiss == true ) {
if( isset( $dismiss ) && $dismiss == true ) {
update_user_meta( get_current_user_id(), $this->plugin_name . '_' . $clicked_from, true );
$this->update( $clicked_from );
}
Expand Down Expand Up @@ -362,20 +364,20 @@ public function content(){
case 'opt_in' :
do_action('wpdeveloper_optin_notice_for_' . $this->plugin_name );
break;
case 'first_install' :
case 'first_install' :
if( $options_data[ $this->plugin_name ]['first_install'] !== 'deactivated' ) {
do_action( 'wpdeveloper_first_install_notice_for_' . $this->plugin_name );
$this->get_thumbnail( 'first_install' );
$this->get_message( 'first_install' );
}
break;
case 'update' :
case 'update' :
do_action( 'wpdeveloper_update_notice_for_' . $this->plugin_name );
$this->get_thumbnail( 'update' );
$this->get_message( 'update' );
$this->dismiss_button_scripts();
break;
case 'review' :
case 'review' :
do_action( 'wpdeveloper_review_notice_for_' . $this->plugin_name );
$this->get_thumbnail( 'review' );
$this->get_message( 'review' );
Expand Down Expand Up @@ -416,6 +418,10 @@ private function get_upsale_args(){
*/
private function upsale_button(){
$upsale_args = $this->get_upsale_args();
if( isset( $upsale_args['href'] ) ) {
echo '<a href="'. $upsale_args['href'] .'" target="_blank" class="button button-primary">'. $upsale_args['btn_text'] .'</a>';
return;
}
$plugin_slug = ( isset( $upsale_args['slug'] )) ? $upsale_args['slug'] : '' ;
if( empty( $plugin_slug ) ) {
return;
Expand Down Expand Up @@ -494,7 +500,7 @@ protected function next_notice(){
* @param string $notice
* @return boolean
*/
private function deserve_notice( $notice ) {
private function deserve_notice( $notice ) {
$notices = $this->get_user_notices();
if( $notice === false ) {
return false;
Expand Down Expand Up @@ -596,7 +602,7 @@ public function first_install_track( $args = array() ){
}
$options_data = $this->get_options_data();
$args = wp_parse_args( $args, $this->get_args() );
if( ! isset( $options_data[ $this->plugin_name ] )
if( ! isset( $options_data[ $this->plugin_name ] )
|| ( isset( $options_data[ $this->plugin_name ]['version'] ) && version_compare( $options_data[ $this->plugin_name ]['version'], $this->version, '!=' ) ) ) {
$this->update_options_data( $args );
}
Expand Down Expand Up @@ -748,14 +754,14 @@ public function notice_dissmiss(){
if( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'wpdeveloper_notice_dissmiss' ) ) {
return;
}

if( ! isset( $_POST['action'] ) || ( $_POST['action'] !== 'wpdeveloper_notice_dissmiss_for_' . $this->plugin_name ) ) {
return;
}

$dismiss = isset( $_POST['dismiss'] ) ? $_POST['dismiss'] : false;
$notice = isset( $_POST['notice'] ) ? $_POST['notice'] : false;
if( $dismiss ) {
if( $dismiss ) {
$this->update( $notice );
echo 'success';
} else {
Expand All @@ -765,21 +771,21 @@ public function notice_dissmiss(){
}

/**
* This function is responsible for do action when
* This function is responsible for do action when
* the dismiss button clicked in upsale notice.
*/
public function upsale_notice_dissmiss(){

if( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'wpdeveloper_upsale_notice_dissmiss' ) ) {
return;
}

if( ! isset( $_POST['action'] ) || ( $_POST['action'] !== 'wpdeveloper_upsale_notice_dissmiss_for_' . $this->plugin_name ) ) {
return;
}

$dismiss = isset( $_POST['dismiss'] ) ? $_POST['dismiss'] : false;
if( $dismiss ) {
if( $dismiss ) {
$this->update( 'upsale' );
echo 'success';
} else {
Expand Down Expand Up @@ -898,7 +904,7 @@ public function upsale_button_script(){
});
} );
</script>

<?php
}
}
13 changes: 3 additions & 10 deletions EmbedPress/Includes/Traits/Shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ public function admin_notice() {
* Message message for showing.
*/
$notice->classes( 'upsale', 'notice is-dismissible ' );
$notice->message( 'upsale', '<p>' . __( 'If you are using Gutenberg, you must install <a href="https://essential-blocks.com/" target="_blank">Essential Blocks</a>, it extends your capacity, with 22 Free Blocks!', $notice->text_domain ) . '</p>' );
$notice->thumbnail( 'upsale', plugins_url( 'assets/images/essential-blocks.png', EMBEDPRESS_PLUGIN_BASENAME ) );
$notice->message( 'upsale', '<p>' . __( 'Thank you for relying on EmbedPress with 30,000 other websites. Checkout our Pro features.', $notice->text_domain ) . '</p>' );

// Update Notice For PRO Version
if ( $this->is_pro_active() && \version_compare( EMBEDPRESS_PRO_VERSION, '2.0.0', '<' ) ) {
Expand All @@ -113,14 +112,8 @@ public function admin_notice() {
}

$notice->upsale_args = array(
'slug' => 'essential-blocks',
'page_slug' => 'essential-blocks',
'file' => 'essential-blocks.php',
'btn_text' => __( 'Install Free', 'embedpress' ),
'condition' => [
'by' => 'class',
'class' => 'EssentialAdmin'
],
'href' => 'https://embedpress.com/?utm_source=plugin&utm_medium=free&utm_campaign=pro_upgrade#pricing',
'btn_text' => __( 'Learn More', 'embedpress' ),
);

$notice->options_args = array(
Expand Down

0 comments on commit bcc97b9

Please sign in to comment.