first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
use FSVendor\WPDesk\ABTesting\ABVariant;
class WPDesk_Flexible_Shipping_AB_Variant_Old implements ABVariant {
/**
* Define a new value for the generated variant.
*
* @var int
*/
const VARIANT_ID = 0;
/**
* Is On?
*
* @param string $functionality Functionality.
*
* @return bool
*/
public function is_on( $functionality ) {
return WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information::CONTACT_INFORMATION_ON_TOP === ! $functionality;
}
/**
* Get variant id.
*
* @return int|string
*/
public function get_variant_id() {
return self::VARIANT_ID;
}
}

View File

@@ -0,0 +1,34 @@
<?php
use FSVendor\WPDesk\ABTesting\ABVariant;
class WPDesk_Flexible_Shipping_AB_Variant_With_Contact_Information_Button implements ABVariant {
/**
* Define a new value for the generated variant
*
* @var int
*/
const VARIANT_ID = 12;
/**
* Is on?
*
* @param string $functionality Functionality.
*
* @return bool
*/
public function is_on( $functionality ) {
return WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information::CONTACT_INFORMATION_BUTTON === $functionality;
}
/**
* Get variant id.
*
* @return int|string
*/
public function get_variant_id() {
return self::VARIANT_ID;
}
}

View File

@@ -0,0 +1,34 @@
<?php
use FSVendor\WPDesk\ABTesting\ABVariant;
class WPDesk_Flexible_Shipping_AB_Variant_With_Contact_Information_On_Bottom implements ABVariant {
/**
* Define a new value for the generated variant
*
* @var int
*/
const VARIANT_ID = 11;
/**
* Is on?
*
* @param string $functionality Functionality.
*
* @return bool
*/
public function is_on( $functionality ) {
return WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information::CONTACT_INFORMATION_ON_BOTTOM === $functionality;
}
/**
* Get variant id.
*
* @return int|string
*/
public function get_variant_id() {
return self::VARIANT_ID;
}
}

View File

@@ -0,0 +1,34 @@
<?php
use FSVendor\WPDesk\ABTesting\ABVariant;
class WPDesk_Flexible_Shipping_AB_Variant_With_Contact_Information_On_Top implements ABVariant {
/**
* Define a new value for the generated variant
*
* @var int
*/
const VARIANT_ID = 10;
/**
* Is on?
*
* @param string $functionality Functionality.
*
* @return bool
*/
public function is_on( $functionality ) {
return WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information::CONTACT_INFORMATION_ON_TOP === $functionality;
}
/**
* Get variant id.
*
* @return int|string
*/
public function get_variant_id() {
return self::VARIANT_ID;
}
}

View File

@@ -0,0 +1,111 @@
<?php
use FSVendor\WPDesk\ABTesting\ABTest\EqualGroupsRandomABTest;
use FSVendor\WPDesk\Persistence\PersistentContainer;
use FSVendor\WPDesk\Persistence\Wordpress\WordpressOptionsContainer;
use FSVendor\WPDesk\ABTesting\ABVariant;
/**
* AB Menu Test https://docs.google.com/document/d/1O7SDr-suN1ooLrHdtkM7L6ARbsnveSj_fsRWMpFr5Ac/
*
* We've created 2 groups/variants.
*/
class WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information extends EqualGroupsRandomABTest {
const TEST_NAME = 'deactivation-contact-information';
const GROUP_COUNT = 3;
const VARIANT_WITH_CONTACT_INFORMATION_ON_TOP = 1;
const VARIANT_WITH_CONTACT_INFORMATION_ON_BOTTOM = 2;
const VARIANT_WITH_CONTACT_BUTTON = 3;
const NEW_USER_AFTER_THIS_DATE = '2019-11-06 01:00:00';
const VARIANT_ID_FOR_OLD_INSTALLATION = 0;
const CONTACT_INFORMATION_ON_TOP = 'contact_information_on_top';
const CONTACT_INFORMATION_ON_BOTTOM = 'contact_information_on_bottom';
const CONTACT_INFORMATION_BUTTON = 'contact_information_button';
/**
* Persistent container
*
* @var PersistentContainer
*/
public $container;
/**
* WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information constructor.
*/
public function __construct() {
$container = new WordpressOptionsContainer();
$this->container = $container;
parent::__construct( self::GROUP_COUNT, self::TEST_NAME, $container );
$this->override_id_for_old_user( $container );
}
/**
* Clears info about variant and draws again
*/
public function reset() {
parent::reset();
$this->override_id_for_old_user( $this->container );
}
/**
* If old user then should have static group
*
* @param PersistentContainer $container Persistent container.
*/
private function override_id_for_old_user( PersistentContainer $container ) {
if ( self::VARIANT_ID_FOR_OLD_INSTALLATION !== $this->current_variant_id && $this->is_old_installation() ) {
$this->current_variant_id = self::VARIANT_ID_FOR_OLD_INSTALLATION;
$container->set( $this->get_container_key(), self::VARIANT_ID_FOR_OLD_INSTALLATION );
}
}
/**
* If this a old user? If so then FS should work like always.
*
* @return bool
*/
private function is_old_installation() {
return strtotime( self::NEW_USER_AFTER_THIS_DATE ) > $this->activation_date_according_to_wpdesk_helper();
}
/**
* Activation date according to wpdesk helper.
*
* @return int timestamp
*/
private function activation_date_according_to_wpdesk_helper() {
$option_name = 'plugin_activation_flexible-shipping/flexible-shipping.php';
$activation_date = get_option( $option_name, current_time( 'mysql' ) );
if ( ! $activation_date ) {
return time();
}
return strtotime( $activation_date );
}
/**
* Get variant.
*
* @return ABVariant
*/
public function get_variant() {
switch ( $this->current_variant_id ) {
case self::VARIANT_WITH_CONTACT_INFORMATION_ON_TOP:
return new WPDesk_Flexible_Shipping_AB_Variant_With_Contact_Information_On_Top();
case self::VARIANT_WITH_CONTACT_INFORMATION_ON_BOTTOM:
return new WPDesk_Flexible_Shipping_AB_Variant_With_Contact_Information_On_Bottom();
case self::VARIANT_WITH_CONTACT_BUTTON:
return new WPDesk_Flexible_Shipping_AB_Variant_With_Contact_Information_Button();
default:
return new WPDesk_Flexible_Shipping_AB_Variant_Old();
}
}
}

View File

@@ -0,0 +1,51 @@
<?php
use FSVendor\WPDesk\ABTesting\ABVariant;
/**
* AB Test https://docs.google.com/document/d/1JA49dgOqJ1SawEdL506tWdW6zgD30cXDpFZhJ7r_SNo/edit?usp=sharing
*
* Class by which we can push some data to the deactivation filter
*/
class WPDesk_Flexible_Shipping_AB_Tracker_Deactivation_Data implements \FSVendor\WPDesk\PluginBuilder\Plugin\Hookable {
/**
* Variant.
*
* @var ABVariant
*/
protected $variant;
/**
* WPDesk_Flexible_Shipping_AB_Tracker_Deactivation_Data constructor.
*
* @param ABVariant $variant Variant.
*/
public function __construct( ABVariant $variant ) {
$this->variant = $variant;
}
/**
* Fires hooks
*
* @return void
*/
public function hooks() {
add_filter( 'wpdesk_tracker_deactivation_data', array( $this, 'append_variant_id_to_data' ) );
}
/**
* Set variant ID to data array
*
* @param array $data Data.
*
* @return array
*/
public function append_variant_id_to_data( array $data ) {
if ( WPDesk_Flexible_Shipping_Tracker::is_plugin_flexible_shipping_in_data( $data ) ) {
$data['variant_id'] = $this->variant->get_variant_id();
}
return $data;
}
}

View File

@@ -0,0 +1,51 @@
<?php
use FSVendor\WPDesk\ABTesting\ABVariant;
use FSVendor\WPDesk\Tracker\Deactivation\PluginData;
use FSVendor\WPDesk\Tracker\Deactivation\Thickbox;
/**
* Can display deactivation thickbox content.
*/
class WPDesk_Flexible_Shipping_Deactivation_Thickbox_Factory {
/**
* Variant.
*
* @var ABVariant
*/
private $variant;
/**
* @var PluginData
*/
private $plugin_data;
/**
* WPDesk_Flexible_Shipping_Deactivation_Thickbox_Factory constructor.
*
* @param ABVariant $variant Variant.
* @param PluginData $plugin_data .
*/
public function __construct( ABVariant $variant, PluginData $plugin_data ) {
$this->variant = $variant;
$this->plugin_data = $plugin_data;
}
/**
* Create thickbox.
*
* @return Thickbox
*/
public function create_thickbox() {
$view_file = null;
if ( $this->variant->is_on( WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information::CONTACT_INFORMATION_ON_TOP ) ) {
$view_file = __DIR__ . '/views/html-thickbox-contact-information-on-top.php';
} elseif ( $this->variant->is_on( WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information::CONTACT_INFORMATION_ON_BOTTOM ) ) {
$view_file = __DIR__ . '/views/html-thickbox-contact-information-on-bottom.php';
} elseif ( $this->variant->is_on( WPDesk_Flexible_Shipping_AB_Deactivation_Contact_Information::CONTACT_INFORMATION_BUTTON ) ) {
$view_file = __DIR__ . '/views/html-thickbox-contact-information-button.php';
}
return new Thickbox( $this->plugin_data, $view_file );
}
}

View File

@@ -0,0 +1,18 @@
<?php
/**
* @var $support_link string
*
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?><h4><strong><?php
echo sprintf(
__(
'Do you have a problem with our plugin or do not know how to configure it? Write to our support department - we will try to help. %1$sGo to contact form →%2$s',
'flexible-shipping'
),
"<a target=\"_blank\" href=\"{$support_link}\">",
'</a>'
);
?></strong></h4>

View File

@@ -0,0 +1,13 @@
<?php
/**
* @var $support_link string
*
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?><div class="footer">
<a href="#" class="button button-secondary button-close tracker-button-close"><?php _e( 'Cancel', 'flexible-shipping' ); ?></a>
<a target="_blank" href="<?php echo $support_link; ?>" class="button button-secondary button-support"><?php _e( 'Any problems? Write to us.', 'flexible-shipping' ); ?></a>
<a href="#" class="button button-primary button-deactivate allow-deactivate"><?php _e( 'Skip &amp; Deactivate', 'flexible-shipping' ); ?></a>
</div>

View File

@@ -0,0 +1,4 @@
<div class="footer">
<a href="#" class="button button-secondary button-close tracker-button-close"><?php _e( 'Cancel', 'flexible-shipping' ); ?></a>
<a href="#" class="button button-primary button-deactivate allow-deactivate"><?php _e( 'Skip &amp; Deactivate', 'flexible-shipping' ); ?></a>
</div>

View File

@@ -0,0 +1,8 @@
<?php
$support_link = get_locale() === 'pl_PL' ? 'https://wpde.sk/tracker-help-pl-3' : 'https://wpde.sk/tracker-help-3';
$buttons_html_file = __DIR__ . '/html-thickbox-buttons-additional-button.php';
$top_html_file = __DIR__ . '/html-empty.php';
$bottom_html_file = __DIR__ . '/html-empty.php';
require __DIR__ . '/html-thickbox-content.php';

View File

@@ -0,0 +1,7 @@
<?php
$support_link = get_locale() === 'pl_PL' ? 'https://wpde.sk/tracker-help-pl-2' : 'https://wpde.sk/tracker-help-2';
$buttons_html_file = __DIR__ . '/html-thickbox-buttons.php';
$top_html_file = __DIR__ . '/html-empty.php';
$bottom_html_file = __DIR__ . '/html-information.php';
require __DIR__ . '/html-thickbox-content.php';

View File

@@ -0,0 +1,8 @@
<?php
$support_link = get_locale() === 'pl_PL' ? 'https://wpde.sk/tracker-help-pl-1' : 'https://wpde.sk/tracker-help-1';
$buttons_html_file = __DIR__ . '/html-thickbox-buttons.php';
$top_html_file = __DIR__ . '/html-information.php';
$bottom_html_file = __DIR__ . '/html-empty.php';
require __DIR__ . '/html-thickbox-content.php';

View File

@@ -0,0 +1,91 @@
<?php
/**
* @var $top_html_file string
* @var $bottom_html_file string
* @var $plugin_title string
* @var $plugin_file string
* @var $plugin_slug string
* @var $thickbox_id string
* @var $ajax_action string
* @var $ajax_nonce string
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?><div id="<?php echo $thickbox_id; ?>" style="display:none;">
<h2><?php echo sprintf( __( 'You are deactivating %s plugin.', 'flexible-shipping' ), $plugin_title ); ?></h2>
<div class="wpdesk_tracker_deactivate <?php echo $thickbox_id; ?>">
<?php include $top_html_file; ?>
<div class="body">
<div class="panel active" data-panel-id="reasons">
<h4><strong><?php _e( 'If you have a moment, please let us know why you are deactivating the plugin (anonymous feedback):', 'flexible-shipping' ); ?></strong></h4>
<ul class="reasons-list">
<li class="reason">
<label>
<span>
<input type="radio" name="selected-reason" value="plugin_stopped_working">
</span>
<span><?php _e( 'The plugin suddenly stopped working', 'flexible-shipping' ); ?></span>
</label>
</li>
<li class="reason">
<label>
<span>
<input type="radio" name="selected-reason" value="broke_my_site">
</span>
<span><?php _e( 'The plugin broke my site', 'flexible-shipping' ); ?></span>
</label>
</li>
<li class="reason has-input">
<label>
<span>
<input type="radio" name="selected-reason" value="found_better_plugin" data-show="found-better-plugin">
</span>
<span><?php _e( 'I have found a better plugin', 'flexible-shipping' ); ?></span>
</label>
<div class="found-better-plugin" class="reason-input" style="display: none">
<input type="text" class="additional-info" name="better_plugin_name" placeholder="<?php _e( 'What\'s the plugin\'s name?', 'flexible-shipping' ); ?>">
</div>
</li>
<li class="reason">
<label>
<span>
<input type="radio" name="selected-reason" value="plugin_for_short_period">
</span>
<span><?php _e('I only needed the plugin for a short period', 'flexible-shipping' ); ?></span>
</label>
</li>
<li class="reason">
<label>
<span>
<input type="radio" name="selected-reason" value="no_longer_need">
</span>
<span><?php _e( 'I no longer need the plugin', 'flexible-shipping' ); ?></span>
</label>
</li>
<li class="reason">
<label>
<span>
<input type="radio" name="selected-reason" value="temporary_deactivation">
</span>
<span><?php _e( 'It\'s a temporary deactivation. I\'m just debugging an issue.', 'flexible-shipping' ); ?></span>
</label>
</li>
<li class="reason has-input">
<label>
<span>
<input type="radio" name="selected-reason" value="other" data-show="other">
</span>
<span><?php _e( 'Other', 'flexible-shipping' ); ?></span>
</label>
<div class="other" class="reason-input" style="display: none">
<input type="text" name="other" class="additional-info" placeholder="<?php _e( 'Please let us know how we can improve our plugin', 'flexible-shipping' ); ?>">
</div>
</li>
</ul>
</div>
</div>
<?php include $bottom_html_file; ?>
<?php include $buttons_html_file; ?>
</div>
</div>