Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove weForms promotion from admin setup wizard #798

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 1 addition & 89 deletions includes/Admin/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public function __construct() {
if ( current_user_can( 'manage_woocommerce' ) ) {
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
add_action( 'admin_init', array( $this, 'setup_wizard' ), 99 );
add_action( 'activated_plugin', array( $this, 'activated_plugin' ) );
add_action( 'weforms_loaded', [ $this, 'after_weforms_activate' ] );

if ( get_transient( 'dokan_setup_wizard_no_wc' ) ) {
add_filter( 'dokan_admin_setup_wizard_steps', array( SetupWizardNoWC::class, 'add_wc_steps_to_wizard' ) );
Expand Down Expand Up @@ -559,17 +557,6 @@ public function dokan_setup_recommended() {
'plugins' => array( array( 'name' => __( 'WooCommerce Conversion Tracking', 'dokan-lite' ), 'slug' => 'woocommerce-conversion-tracking' ) ),
) );
}

if ( ! $this->is_weforms_active() ) {
$this->display_recommended_item( array(
'type' => 'weforms',
'title' => __( 'weForms', 'dokan-lite' ),
'description' => __( 'Best Contact Form Plugin for WordPress.', 'dokan-lite' ),
'img_url' => DOKAN_PLUGIN_ASSEST . '/images/weforms-logo.png',
'img_alt' => __( 'weForms logo', 'dokan-lite' ),
'plugins' => array( array( 'name' => __( 'weForms', 'dokan-lite' ), 'slug' => 'weforms' ) ),
) );
}
};
?>
</ul>
Expand All @@ -593,7 +580,6 @@ public function dokan_setup_recommended_save() {
check_admin_referer( 'dokan-setup' );

$setup_wc_conversion_tracking = isset( $_POST['setup_wc_conversion_tracking'] ) && 'yes' === $_POST['setup_wc_conversion_tracking'];
$setup_weforms = isset( $_POST['setup_weforms'] ) && 'yes' === $_POST['setup_weforms'];

if ( $setup_wc_conversion_tracking && ! $this->is_wc_conversion_tracking_active() ) {
$this->install_plugin(
Expand All @@ -606,17 +592,6 @@ public function dokan_setup_recommended_save() {
);
}

if ( $setup_weforms && ! $this->is_weforms_active() ) {
$this->install_plugin(
'weforms',
array(
'name' => __( 'weForms', 'dokan-lite' ),
'repo-slug' => 'weforms',
'file' => 'weforms.php',
)
);
}

/**
* WooCoomerce settings manipulation
*/
Expand Down Expand Up @@ -694,7 +669,7 @@ protected function should_show_recommended_step() {
return false;
}

if ( $this->is_wc_conversion_tracking_active() && $this->is_weforms_active() ) {
if ( $this->is_wc_conversion_tracking_active() ) {
return false;
}

Expand All @@ -712,17 +687,6 @@ protected function is_wc_conversion_tracking_active() {
return is_plugin_active( 'woocommerce-conversion-tracking/conversion-tracking.php' );
}

/**
* Check if weForms is active or not
*
* @since 2.8.7
*
* @return bool
*/
protected function is_weforms_active() {
return is_plugin_active( 'weforms/weforms.php' );
}

/**
* Should we show the WooCommerce Conversion Tracking install option?
*
Expand Down Expand Up @@ -865,56 +829,4 @@ protected function close_http_connection() {
flush();
}
}

/**
* activate_plugin hook
*
* @since 2.8.7
*
* @param string $plugin
*
* @return void
*/
public function activated_plugin( $plugin ) {
if ( 'weforms/weforms.php' === $plugin ) {
update_option( 'dokan_setup_wizard_activated_weforms', true );
}
}

/**
* Action after weForms activate
*
* @since 2.8.7
*
* @return void
*/
public function after_weforms_activate() {
$did_activate = get_option( 'dokan_setup_wizard_activated_weforms', false );

if ( ! $did_activate ) {
return;
}

add_action( 'shutdown', 'flush_rewrite_rules' );

$forms_data = weforms()->form->all();

$forms = $forms_data['forms'];

if ( empty( $forms_data['forms'][0] ) ) {
return;
}

$form = $forms_data['forms'][0];

$settings = array(
'allow_vendor_contact_form' => 'on',
'vendor_contact_section_label' => __( 'Contact Admin', 'dokan-lite' ),
'vendor_contact_form' => $form->id,
);

update_option( 'weforms_integration', $settings );

delete_option( 'dokan_setup_wizard_activated_weforms' );
}
}