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

Added deactivation reason to plugin file and updated readme file #256

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
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
148 changes: 148 additions & 0 deletions includes/component/plugin-deactivation/assets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
.ts-modal {
position: fixed;
overflow: auto;
height: 100%;
width: 100%;
top: 0;
z-index: 100000;
display: none;
background: rgba(0, 0, 0, 0.6)
}

.ts-modal .ts-modal-dialog {
background: transparent;
position: absolute;
left: 50%;
margin-left: -298px;
padding-bottom: 30px;
top: -100%;
z-index: 100001;
width: 596px
}

.ts-modal li.reason.has_html .reason_html {
display: none;
border: 1px solid #ddd;
padding: 4px 6px;
margin: 6px 0 0 20px;
}

.ts-modal li.reason.has_html.li-active .reason_html {
display: block;
}

@media (max-width: 650px) {
.ts-modal .ts-modal-dialog {
margin-left: -50%;
box-sizing: border-box;
padding-left: 10px;
padding-right: 10px;
width: 100%
}

.ts-modal .ts-modal-dialog .ts-modal-panel>h3>strong {
font-size: 1.3em
}

.ts-modal .ts-modal-dialog li.reason {
margin-bottom: 10px
}

.ts-modal .ts-modal-dialog li.reason .reason-input {
margin-left: 29px
}

.ts-modal .ts-modal-dialog li.reason label {
display: table
}

.ts-modal .ts-modal-dialog li.reason label>span {
display: table-cell;
font-size: 1.3em
}
}

.ts-modal.active {
display: block
}

.ts-modal.active:before {
display: block
}

.ts-modal.active .ts-modal-dialog {
top: 10%
}

.ts-modal .ts-modal-body,
.ts-modal .ts-modal-footer {
border: 0;
background: #fefefe;
padding: 20px
}

.ts-modal .ts-modal-body {
border-bottom: 0
}

.ts-modal .ts-modal-body h2 {
font-size: 20px
}

.ts-modal .ts-modal-body>div {
margin-top: 10px
}

.ts-modal .ts-modal-body>div h2 {
font-weight: bold;
font-size: 20px;
margin-top: 0
}

.ts-modal .ts-modal-footer {
border-top: #eeeeee solid 1px;
text-align: right
}

.ts-modal .ts-modal-footer>.button {
margin: 0 7px
}

.ts-modal .ts-modal-footer>.button:first-child {
margin: 0
}

.ts-modal .ts-modal-panel:not(.active) {
display: none
}

.ts-modal .reason-input {
margin: 3px 0 3px 22px
}

.ts-modal .reason-input input,
.ts-modal .reason-input textarea {
width: 100%
}

body.has-ts-modal {
overflow: hidden
}

#the-list .deactivate>.ts-slug {
display: none
}

.ts-modal li.reason-hide {
display: none;
}

.ts-modal-footer p {
/* display: inline-block; */
margin: 0 10px;
vertical-align: middle;
font-weight: 500;
color: red;
padding: 5px 0;
display: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function enqueue_scripts() {

wp_enqueue_style(
'tyche_plugin_deactivation',
$this->api_url . '/assets/plugin-deactivation/css/style.css',
plugins_url( '/assets/css/style.css', __FILE__ ),
array(),
$this->plugin_version
);
Expand All @@ -164,17 +164,91 @@ public function enqueue_scripts() {
true
);

$request = wp_remote_get( $this->api_url . '?action=fetch-deactivation-data&plugin=' . $this->plugin_short_name . '&language=' . apply_filters( 'tyche_plugin_deactivation_language', 'en' ) . '&version=' . $this->version );

if ( is_wp_error( $request ) || 200 !== wp_remote_retrieve_response_code( $request ) ) {
return false; // In case the user is offline or something else that could have probably caused an error.
}

$data = json_decode( wp_remote_retrieve_body( $request ), true );

if ( ! is_array( $data ) ) {
return false;
}
// Hardcoded deactivation data.
$data = array(
'reasons' => array(
array(
'id' => 1,
'text' => __( 'I only needed the plugin for a short period.', 'checkout-fees-for-woocommerce' ),
'input_type' => '',
'input_placeholder' => '',
),
array(
'id' => 2,
'text' => __( 'I found a better plugin.', 'checkout-fees-for-woocommerce' ),
'input_type' => 'textfield',
'input_placeholder' => __( 'Please let us have the plugin\'s name so that we can make improvements', 'checkout-fees-for-woocommerce' ),
),
array(
'id' => 3,
'text' => __( 'The plugin is not working.', 'checkout-fees-for-woocommerce' ),
'input_type' => 'textfield',
'input_placeholder' => __( 'Please share what was faulty with the plugin so that we may get the issue fixed.', 'checkout-fees-for-woocommerce' ),
),
array(
'id' => 4,
'text' => __( 'The plugin is causing issues on my site', 'checkout-fees-for-woocommerce' ),
'input_type' => 'textfield',
'input_placeholder' => __( 'We’re sorry! Please tell us about the issues so that we can get them fixed.', 'checkout-fees-for-woocommerce' ),
),
array(
'id' => 6,
'text' => __( 'Some features I need are not working as per my expectations', 'checkout-fees-for-woocommerce' ),
'input_type' => 'textfield',
'input_placeholder' => __( 'Please tell us about these features.', 'checkout-fees-for-woocommerce' ),
),
array(
'id' => 7,
'text' => __( 'The plugin is not compatible with another plugin/theme', 'checkout-fees-for-woocommerce' ),
'input_type' => 'textfield',
'input_placeholder' => __( 'We’re sorry! We would like you to tell us the plugin/theme so that we can work on the compatibility.', 'checkout-fees-for-woocommerce' ),
),
array(
'id' => 10,
'text' => __( 'Other', 'checkout-fees-for-woocommerce' ),
'input_type' => 'textfield',
'input_placeholder' => '',
),
array(
'id' => 11,
'text' => __( 'The Tax fees are not calculated correctly', 'checkout-fees-for-woocommerce' ),
'input_type' => '',
'input_placeholder' => '',
),
array(
'id' => 12,
'text' => __( 'I’m unable to set up fees for my Custom Payment Gateway plugin', 'checkout-fees-for-woocommerce' ),
'input_type' => '',
'input_placeholder' => '',
),
),
'template' => '<div class="{PLUGIN} ts-modal no-confirmation-message">
<div class="ts-modal-dialog">
<div class="ts-modal-body">
<div class="ts-modal-panel" data-panel-id="confirm">
<p></p>
</div>
<div class="ts-modal-panel active" data-panel-id="reasons">
<h3>
<strong>
' . __( 'If you have a moment, please let us know why you are deactivating:', 'checkout-fees-for-woocommerce' ) . '
</strong>
</h3>

<ul id="reasons-list">
{HTML}
</ul>
</div>
</div>

<div class="ts-modal-footer">
<a href="javascript:void(0);" class="button button-secondary button-skip-deactivate"> ' . __( 'Skip & Deactivate', 'checkout-fees-for-woocommerce' ) . '</a>
<a href="javascript:void(0);" class="button button-secondary button-deactivate"> ' . __( 'Submit & Deactivate', 'checkout-fees-for-woocommerce' ) . '</a>
<a href="javascript:void(0);" class="button button-primary button-close">' . __( 'Cancel', 'checkout-fees-for-woocommerce' ) . '</a>
</div>
</div>
</div>',
);

wp_localize_script(
'tyche_plugin_deactivation_' . $this->plugin_short_name,
Expand All @@ -183,7 +257,7 @@ public function enqueue_scripts() {
'deactivation_data' => $data,
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'tyche_plugin_deactivation_submit_action' ),
'deactivation_req_msg' => __( 'Please select a reason for deactivation!', $this->plugin_locale ),
'deactivation_req_msg' => __( 'Please select a reason for deactivation!', 'checkout-fees-for-woocommerce' ),
)
);

Expand Down
Loading
Loading