wp/wp-content/plugins/portfolio/bws_menu/deactivation-form.php
author ymh <ymh.work@gmail.com>
Mon, 08 Sep 2025 19:44:41 +0200
changeset 23 417f20492bf7
parent 21 48c4eec2b7e6
permissions -rwxr-xr-x
Update Docker configuration and plugin versions - Upgrade MariaDB from 10.6 to 11 with auto-upgrade support - Add WordPress debug environment variable to FPM container - Update PHP-FPM Dockerfile base image - Update Include Mastodon Feed plugin with bug fixes and improvements - Update Portfolio plugin (v2.58) with latest translations and demo data enhancements - Remove old README.md from Mastodon Feed plugin 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Displays the content of the dialog box when the user clicks on the "Deactivate" link on the plugin settings page
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
     4
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package BestWebSoft
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @since 2.1.3
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
     8
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
     9
if ( ! defined( 'ABSPATH' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
	exit;
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    11
}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
if ( ! function_exists( 'bws_add_deactivation_feedback_dialog_box' ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    14
	/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    15
	 * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    16
	 * page.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    17
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    18
	 * @since  2.1.3
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    19
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
	function bws_add_deactivation_feedback_dialog_box() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
		global $bstwbsftwppdtplgns_active_plugins;
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    22
		if ( empty( $bstwbsftwppdtplgns_active_plugins ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    23
			return;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    24
		}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    25
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    26
		$contact_support_template = __( 'Need help? We are ready to answer your questions.', 'bestwebsoft' ) . ' <a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . __( 'Contact Support', 'bestwebsoft' ) . '</a>';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    27
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    28
		$reasons = array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    29
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    30
				'id'                => 'NOT_WORKING',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    31
				'text'              => __( 'The plugin is not working', 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    32
				'input_type'        => 'textarea',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    33
				'input_placeholder' => __( "Kindly share what didn't work so we can fix it in future updates...", 'bestwebsoft' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    34
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    35
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    36
				'id'                => 'DIDNT_WORK_AS_EXPECTED',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    37
				'text'              => __( "The plugin didn't work as expected", 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    38
				'input_type'        => 'textarea',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    39
				'input_placeholder' => __( 'What did you expect?', 'bestwebsoft' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    40
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    41
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    42
				'id'                => 'SUDDENLY_STOPPED_WORKING',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    43
				'text'              => __( 'The plugin suddenly stopped working', 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    44
				'input_type'        => '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    45
				'input_placeholder' => '',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    46
				'internal_message'  => $contact_support_template,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    47
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    48
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    49
				'id'                => 'BROKE_MY_SITE',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    50
				'text'              => __( 'The plugin broke my site', 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    51
				'input_type'        => '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    52
				'input_placeholder' => '',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    53
				'internal_message'  => $contact_support_template,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    54
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    55
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    56
				'id'                => 'COULDNT_MAKE_IT_WORK',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    57
				'text'              => __( "I couldn't understand how to get it work", 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    58
				'input_type'        => '',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    59
				'input_placeholder' => '',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    60
				'internal_message'  => $contact_support_template,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    61
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    62
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    63
				'id'                => 'FOUND_A_BETTER_PLUGIN',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    64
				'text'              => __( 'I found a better plugin', 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    65
				'input_type'        => 'textfield',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    66
				'input_placeholder' => __( "What's the plugin name?", 'bestwebsoft' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    67
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    68
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    69
				'id'                => 'GREAT_BUT_NEED_SPECIFIC_FEATURE',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    70
				'text'              => __( "The plugin is great, but I need specific feature that you don't support", 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    71
				'input_type'        => 'textarea',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    72
				'input_placeholder' => __( 'What feature?', 'bestwebsoft' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    73
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    74
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    75
				'id'                => 'NO_LONGER_NEEDED',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    76
				'text'              => __( 'I no longer need the plugin', 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    77
				'input_type'        => '',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    78
				'input_placeholder' => '',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    79
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    80
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    81
				'id'                => 'TEMPORARY_DEACTIVATION',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    82
				'text'              => __( "It's a temporary deactivation, I'm just debugging an issue", 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    83
				'input_type'        => '',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    84
				'input_placeholder' => '',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    85
			),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    86
			array(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    87
				'id'                => 'OTHER',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    88
				'text'              => __( 'Other', 'bestwebsoft' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    89
				'input_type'        => 'textfield',
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    90
				'input_placeholder' => '',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    91
			),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    92
		);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    93
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    94
		$modal_html = '<div class="bws-modal bws-modal-deactivation-feedback">
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    95
	    	<div class="bws-modal-dialog">
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    96
	    		<div class="bws-modal-body">
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    97
	    			<h2>' . __( 'Quick Feedback', 'bestwebsoft' ) . '</h2>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
    98
	    			<div class="bws-modal-panel active">
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    99
	    				<p>' . __( 'If you have a moment, please let us know why you are deactivating', 'bestwebsoft' ) . ':</p><ul>';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   100
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   101
		foreach ( $reasons as $reason ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   102
			$list_item_classes = 'bws-modal-reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   103
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   104
			if ( ! empty( $reason['internal_message'] ) ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   105
				$list_item_classes      .= ' has-internal-message';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   106
				$reason_internal_message = $reason['internal_message'];
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   107
			} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   108
				$reason_internal_message = '';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   109
			}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   110
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   111
			$modal_html .= '<li class="' . $list_item_classes . '" data-input-type="' . $reason['input_type'] . '" data-input-placeholder="' . $reason['input_placeholder'] . '">
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   112
				<label>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   113
					<span>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   114
						<input type="radio" name="selected-reason" value="' . $reason['id'] . '"/>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   115
					</span>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   116
					<span>' . $reason['text'] . '</span>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   117
				</label>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   118
				<div class="bws-modal-internal-message">' . $reason_internal_message . '</div>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   119
			</li>';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   120
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   121
		$modal_html .= '</ul>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   122
		    				<label class="bws-modal-anonymous-label">
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   123
			    				<input type="checkbox" />' .
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   124
								__( 'Send website data and allow to contact me back', 'bestwebsoft' ) .
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   125
							'</label>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   126
						</div>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   127
					</div>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   128
					<div class="bws-modal-footer">
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   129
						<a href="#" class="button button-primary bws-modal-button-deactivate disabled">' . __( 'Submit and Deactivate', 'bestwebsoft' ) . '</a>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   130
						<a href="#" class="bws-modal-skip-link">' . __( 'Skip and Deactivate', 'bestwebsoft' ) . '</a>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   131
						<span class="bws-modal-processing hidden">' . __( 'Processing', 'bestwebsoft' ) . '...</span>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   132
						<div class="clear"></div>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   133
					</div>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   134
				</div>
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   135
			</div>';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   136
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   137
		$script = '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
		foreach ( $bstwbsftwppdtplgns_active_plugins as $basename => $plugin_data ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   141
			$slug      = dirname( $basename );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
			$plugin_id = sanitize_title( $plugin_data['Name'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   144
			$script .= "(function($) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   145
					var modalHtml = " . wp_json_encode( $modal_html ) . ",
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   146
					    \$modal                = $( modalHtml ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   147
					    \$deactivateLink       = $( '#the-list .active[data-plugin=\"" . $basename . "\"] .deactivate a' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   148
						\$anonymousFeedback    = \$modal.find( '.bws-modal-anonymous-label' ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
						selectedReasonID      = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
					/* WP added data-plugin attr after 4.5 version/ In prev version was id attr */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   152
					if ( 0 == \$deactivateLink.length )
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   153
						\$deactivateLink = $( '#the-list .active#" . $plugin_id . " .deactivate a' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   155
					\$modal.appendTo( $( 'body' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
					BwsModalRegisterEventHandlers();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
					
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
					function BwsModalRegisterEventHandlers() {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   160
						\$deactivateLink.click( function( evt ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
							evt.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
							/* Display the dialog box.*/
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
							BwsModalReset();
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   165
							\$modal.addClass( 'active' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
							$( 'body' ).addClass( 'has-bws-modal' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
						});
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   169
						\$modal.on( 'input propertychange', '.bws-modal-reason-input input', function() {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
							if ( ! BwsModalIsReasonSelected( 'OTHER' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
								return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
							}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
							var reason = $( this ).val().trim();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
							/* If reason is not empty, remove the error-message class of the message container to change the message color back to default. */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
							if ( reason.length > 0 ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   178
								\$modal.find( '.message' ).removeClass( 'error-message' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
								BwsModalEnableDeactivateButton();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
							}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
						});
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   183
						\$modal.on( 'blur', '.bws-modal-reason-input input', function() {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   184
							var \$userReason = $( this );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
							setTimeout( function() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
								if ( ! BwsModalIsReasonSelected( 'OTHER' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
									return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
								}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
							}, 150 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
						});
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   193
						\$modal.on( 'click', '.bws-modal-footer .bws-modal-skip-link', function( evt ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   194
							evt.preventDefault();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   195
							
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   196
							/* If no selected reason, just deactivate the plugin. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   197
							window.location.href = \$deactivateLink.attr( 'href' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   198
							return;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   199
						});
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   200
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   201
						\$modal.on( 'click', '.bws-modal-footer .button', function( evt ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
							evt.preventDefault();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
							if ( $( this ).hasClass( 'disabled' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
								return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
							}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
							var _parent = $( this ).parents( '.bws-modal:first' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   209
								_this =  $( this );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   211
							var \$radio = \$modal.find( 'input[type=\"radio\"]:checked' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   213
							if ( 0 === \$radio.length ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   214
								/* If no selected reason */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   215
								BwsModalDisableDeactivateButton();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   216
								return;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   217
							}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   219
							var \$selected_reason = \$radio.parents( 'li:first' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   220
							    \$input = \$selected_reason.find( 'textarea, input[type=\"text\"]' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   221
							    userReason = ( 0 !== \$input.length ) ? \$input.val().trim() : '';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   222
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   223
							var is_anonymous = ( \$anonymousFeedback.find( 'input' ).is( ':checked' ) ) ? 0 : 1;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   225
							$.ajax({
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   226
								url       : ajaxurl,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   227
								method    : 'POST',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   228
								data      : {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   229
									'action'			: 'bws_submit_uninstall_reason_action',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   230
									'plugin'			: '" . $basename . "',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   231
									'reason_id'			: \$radio.val(),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   232
									'reason_info'		: userReason,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   233
									'is_anonymous'		: is_anonymous,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   234
									'bws_ajax_nonce'	: '" . wp_create_nonce( 'bws_ajax_nonce' ) . "'
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   235
								},
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   236
								beforeSend: function() {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   237
									_parent.find( '.bws-modal-footer .button' ).hide();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   238
									_parent.find( '.bws-modal-footer .bws-modal-processing' ).show();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   239
								},
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   240
								complete  : function( message ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   241
									/* Do not show the dialog box, deactivate the plugin. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   242
									window.location.href = \$deactivateLink.attr( 'href' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   243
								}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   244
							});
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
						});
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   247
						\$modal.on( 'click', 'input[type=\"radio\"]', function() {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   248
							var \$selectedReasonOption = $( this );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
							/* If the selection has not changed, do not proceed. */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   251
							if ( selectedReasonID === \$selectedReasonOption.val() )
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
								return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   254
							selectedReasonID = \$selectedReasonOption.val();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   256
							\$anonymousFeedback.show();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
							var _parent = $( this ).parents( 'li:first' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   260
							\$modal.find( '.bws-modal-reason-input' ).remove();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   261
							\$modal.find( '.bws-modal-internal-message' ).hide();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
							BwsModalEnableDeactivateButton();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
							if ( _parent.hasClass( 'has-internal-message' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
								_parent.find( '.bws-modal-internal-message' ).show();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
							}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
							if (_parent.hasClass('has-input')) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   270
								var reasonInputHtml = '<div class=\"bws-modal-reason-input\"><span class=\"message\"></span>' + ( ( 'textfield' === _parent.data( 'input-type' ) ) ? '<input type=\"text\" />' : '<textarea rows=\"5\" maxlength=\"200\"></textarea>' ) + '</div>';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
								_parent.append( $( reasonInputHtml ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
								_parent.find( 'input, textarea' ).attr( 'placeholder', _parent.data( 'input-placeholder' ) ).focus();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
								if ( BwsModalIsReasonSelected( 'OTHER' ) ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   276
									\$modal.find( '.message' ).text( '" . esc_html__( 'Please tell us the reason so we can improve it.', 'bestwebsoft' ) . "' ).show();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
								}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
							}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
						});
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
						/* If the user has clicked outside the window, cancel it. */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   282
						\$modal.on( 'click', function( evt ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   283
							var \$target = $( evt.target );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
							/* If the user has clicked anywhere in the modal dialog, just return. */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   286
							if ( \$target.hasClass( 'bws-modal-body' ) || \$target.hasClass( 'bws-modal-footer' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
								return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
							}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
							/* If the user has not clicked the close button and the clicked element is inside the modal dialog, just return. */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   291
							if ( ! \$target.hasClass( 'bws-modal-button-close' ) && ( \$target.parents( '.bws-modal-body' ).length > 0 || \$target.parents( '.bws-modal-footer' ).length > 0 ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
								return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
							}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
							/* Close the modal dialog */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   296
							\$modal.removeClass( 'active' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
							$( 'body' ).removeClass( 'has-bws-modal' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
							return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
						});
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
					function BwsModalIsReasonSelected( reasonID ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
						/* Get the selected radio input element.*/
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   305
						return ( reasonID == \$modal.find('input[type=\"radio\"]:checked').val() );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
					function BwsModalReset() {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   309
						selectedReasonID = false;						
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
						/* Uncheck all radio buttons.*/
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   312
						\$modal.find( 'input[type=\"radio\"]' ).prop( 'checked', false );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
						/* Remove all input fields ( textfield, textarea ).*/
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   315
						\$modal.find( '.bws-modal-reason-input' ).remove();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   317
						\$modal.find( '.message' ).hide();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
						/* Hide, since by default there is no selected reason.*/
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   320
						\$anonymousFeedback.hide();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   322
						BwsModalDisableDeactivateButton();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
						BwsModalShowPanel();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
					function BwsModalEnableDeactivateButton() {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   328
						\$modal.find( '.bws-modal-button-deactivate' ).removeClass( 'disabled' ).show();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   329
						\$modal.find( '.bws-modal-processing' ).hide();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
					function BwsModalDisableDeactivateButton() {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   333
						\$modal.find( '.bws-modal-button-deactivate' ).addClass( 'disabled' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
					function BwsModalShowPanel() {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   337
						\$modal.find( '.bws-modal-panel' ).addClass( 'active' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
					}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   339
				})(jQuery);";
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   340
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   341
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   342
		/* add script in FOOTER */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   343
		wp_register_script( 'bws-deactivation-feedback-dialog-boxes', '', array( 'jquery' ), false, true );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 12
diff changeset
   344
		wp_enqueue_script( 'bws-deactivation-feedback-dialog-boxes' );
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   345
		wp_add_inline_script( 'bws-deactivation-feedback-dialog-boxes', $script );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
if ( ! function_exists( 'bws_submit_uninstall_reason_action' ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   350
	/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   351
	 * Called after the user has submitted his reason for deactivating the plugin.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   352
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   353
	 * @since  2.1.3
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   354
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
	function bws_submit_uninstall_reason_action() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
		global $bstwbsftwppdtplgns_options, $wp_version, $bstwbsftwppdtplgns_active_plugins, $current_user;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   358
		if ( isset( $_REQUEST['bws_ajax_nonce'] ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   360
			check_ajax_referer( 'bws_ajax_nonce', sanitize_text_field( wp_unslash( $_REQUEST['bws_ajax_nonce'] ) ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   362
			$reason_id = isset( $_REQUEST['reason_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['reason_id'] ) ) : '';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   363
			$basename  = isset( $_REQUEST['plugin'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['plugin'] ) ) : '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   365
			if ( empty( $reason_id ) || empty( $basename ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   366
				exit;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   369
			$reason_info = isset( $_REQUEST['reason_info'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['reason_info'] ) ) : '';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   370
			if ( ! empty( $reason_info ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   371
				$reason_info = substr( $reason_info, 0, 255 );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   372
			}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   373
			$is_anonymous = isset( $_REQUEST['is_anonymous'] ) && 1 === intval( $_REQUEST['is_anonymous'] );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   374
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   375
			$options = array(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   376
				'product'     => $basename,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   377
				'reason_id'   => $reason_id,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   378
				'reason_info' => $reason_info,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   379
			);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   381
			if ( ! $is_anonymous ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   382
				if ( ! isset( $bstwbsftwppdtplgns_options ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   383
					$bstwbsftwppdtplgns_options = ( is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   384
				}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   386
				if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   387
					$options['usage_id'] = $bstwbsftwppdtplgns_options['track_usage']['usage_id'];
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   388
				} else {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   389
					$options['usage_id']   = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   390
					$options['url']        = get_bloginfo( 'url' );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   391
					$options['wp_version'] = $wp_version;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   392
					$options['is_active']  = false;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   393
					$options['version']    = $bstwbsftwppdtplgns_active_plugins[ $basename ]['Version'];
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   394
				}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   395
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   396
				$options['email'] = $current_user->data->user_email;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   397
			}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   399
			/* send data */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   400
			$raw_response = wp_remote_post(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   401
				'https://bestwebsoft.com/wp-content/plugins/products-statistics/deactivation-feedback/',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   402
				array(
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   403
					'method'  => 'POST',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   404
					'body'    => $options,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   405
					'timeout' => 15,
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   406
				)
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   407
			);
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   408
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   409
			if ( ! is_wp_error( $raw_response ) && 200 === intval( wp_remote_retrieve_response_code( $raw_response ) ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   410
				if ( ! $is_anonymous ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   411
					$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   413
					if ( is_array( $response ) && ! empty( $response['usage_id'] ) && $response['usage_id'] !== $options['usage_id'] ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   414
						$bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id'];
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   415
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   416
						if ( is_multisite() ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   417
							update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   418
						} else {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   419
							update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   420
						}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   421
					}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   424
				echo 'done';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   425
			} else {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   426
				echo wp_kses_data( $response->get_error_code() ) . ': ' . wp_kses_data( $response->get_error_message() );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   427
			}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
		exit;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   433
add_action( 'wp_ajax_bws_submit_uninstall_reason_action', 'bws_submit_uninstall_reason_action' );