Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Docs Home

Packages

  • Abandoned-Cart-Lite-for-WooCommerce
    • Admin
      • Admin-Action
      • Admin-Notice
      • Component
      • Default-Template
      • List-Class
      • Tracking-Data
      • Welcome-Page
    • Common-Functions
    • Core
    • Cron
    • Encrypt-Decrypt-Data
    • Frontend
      • Capture-Guest-Cart
    • Tracking
    • Uninstaller
  • None

Classes

  • Class_Wcal_Ts_Tracker
  • TS_deactivate
  • TS_Faq_Support
  • ts_pro_notices
  • TS_Tracker
  • TS_tracking
  • TS_Welcome
  • TS_Woo_Active
  • WCAL_Abandoned_Orders_Table
  • Wcal_Admin_Notice
  • Wcal_Aes
  • Wcal_Aes_Ctr
  • Wcal_All_Component
  • wcal_common
  • wcal_default_template_settings
  • wcal_delete_bulk_action_handler
  • Wcal_Personal_Data_Eraser
  • Wcal_Personal_Data_Export
  • WCAL_Product_Report_Table
  • wcal_Recover_Orders_Table
  • WCAL_Templates_Table
  • Wcal_Tracking_msg
  • Wcal_TS_Tracking
  • Wcal_Welcome
  • woocommerce_abandon_cart_lite
  • woocommerce_guest_ac

Functions

  • guest_checkout_fields
  • load_ac_ajax
  • save_data
  • user_side_js
  • wcal_add_cron_schedule
  • wcal_send_email_cron
  • woocommerce_ac_delete_lite
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 
<?php

/**
 * Contains the logic for deactivation popups
 * @since 1.0.0
 */
class TS_deactivate {
    public static $ts_deactivation_str;

    public static $ts_generic_questions;

    public static $ts_plugin_specific_questions;

    /**
     * URL to the  Tracker API endpoint.
     * @var string
     */

    private static $api_url = 'http://trackingdev.tychesoftwares.com/v1/';

    /**
    * @var string Plugin name
    * @access public 
    */

    public static $plugin_name = '';

    /**
     * @var string Plugin file name
     * @access public
     */
    public static $ts_plugin_file_name = '';

    /**
     * @var string Plugin URL
     * @access public
     */
    public static $ts_plugin_url = '';

    /**
     * Initialization of hooks where we prepare the functionality to ask use for survey
     */
    public static function init( $ts_plugin_file_name = '', $ts_plugin_name = '' ) {
        self::$ts_plugin_file_name = $ts_plugin_file_name;
        self::$plugin_name         = $ts_plugin_name;
        self::$ts_plugin_url       = untrailingslashit( plugin_dir_path ( __FILE__ ) );
        
        self::ts_load_all_str();
        add_action( 'admin_footer',                       array( __CLASS__, 'maybe_load_deactivate_options' ) );
        add_action( 'wp_ajax_ts_submit_uninstall_reason', array( __CLASS__, '_submit_uninstall_reason_action' ) );

        add_filter( 'plugin_action_links_' . self::$ts_plugin_file_name, array( __CLASS__, 'ts_plugin_settings_link' ) );
    }

    /**
     * Settings link on Plugins page
     * 
     * @access public
     * @param array $links 
     * @return array
     */
    public static function ts_plugin_settings_link( $links ) {
        
        if ( isset ( $links['deactivate'] ) ) {
            $links['deactivate'] .= '<i class="ts-slug" data-slug="' . self::$ts_plugin_file_name  . '"></i>';
        }
        return $links;
    }

    /**
     * Localizes all the string used
     */
    public static function ts_load_all_str() {
        self::$ts_deactivation_str = array(
            "deactivation-share-reason"                => __( "If you have a moment, please let us know why you are deactivating", "ts-deactivation-survey" ),
            "deactivation-modal-button-submit"         => __( "Submit & Deactivate", "ts-deactivation-survey" ),
            "deactivation-modal-button-deactivate"     => __( "Deactivate", "ts-deactivation-survey" ),
            "deactivation-modal-button-cancel"         => __( "Cancel", "ts-deactivation-survey" ),
            "deactivation-modal-button-confirm"        => __( 'Yes - Deactivate', 'ts-deactivation-survey' ),
        );

        self::$ts_generic_questions = array(
            "reason-found-a-better-plugin"             => __( "I found a better plugin", "ts-deactivation-survey" ),
            "placeholder-plugin-name"                  => __( "What's the plugin's name?", "ts-deactivation-survey" ),
            "reason-needed-for-a-short-period"         => __( "I only needed the plugin for a short period", "ts-deactivation-survey" ),
            "reason-not-working"                       => __( "The plugin is not working", "ts-deactivation-survey" ),
            "placeholder-share-what-didnt-work"        => __( "Kindly share what didn't work so we can fix it for future users...", "ts-deactivation-survey" ),
            "reason-great-but-need-specific-feature"   => __( "The plugin is great, but I need specific feature that you don't support", "ts-deactivation-survey" ),
            "placeholder-feature"                      => __( "What feature?", "ts-deactivation-survey" ),
            "reason-dont-like-to-share-my-information" => __( "I don't like to share my information with you", "ts-deactivation-survey" ),
            "reason-other"                             => _x( "Other", "the text of the 'other' reason for deactivating the plugin that is shown in the modal box.", "ts-deactivation-survey" ),
        );
    }

    /**
     * Checking current page and pushing html, js and css for this task
     * @global string $pagenow current admin page
     * @global array $VARS global vars to pass to view file
     */
    public static function maybe_load_deactivate_options() {
        global $pagenow;
        if ( $pagenow == "plugins.php" ) {
            global $VARS;
            $VARS = array( 'slug' => "asvbsd", 'reasons' => self::deactivate_options() );
            include_once self::$ts_plugin_url . "/template/ts-deactivate-modal.php";
        }
    }

    /**
     * deactivation reasons in array format
     * @return array reasons array
     * @since 1.0.0
     */
    public static function deactivate_options() {

        self::$ts_plugin_specific_questions = apply_filters( 'ts_deativate_plugin_questions', array () );


        $reason_found_better_plugin = array(
            'id'                => 2,
            'text'              => self::$ts_generic_questions[ 'reason-found-a-better-plugin' ],
            'input_type'        => 'textfield',
            'input_placeholder' => self::$ts_generic_questions[ 'placeholder-plugin-name' ]
        );

        $reason_not_working = array(
            'id'                => 3,
            'text'              => self::$ts_generic_questions[ 'reason-not-working' ],
            'input_type'        => 'textfield',
            'input_placeholder' => self::$ts_generic_questions[ 'placeholder-share-what-didnt-work' ]
        );

        $reason_great_but_need_specific_feature = array(
            'id'                => 8,
            'text'              => self::$ts_generic_questions[ 'reason-great-but-need-specific-feature' ],
            'input_type'        => 'textfield',
            'input_placeholder' => self::$ts_generic_questions[ 'placeholder-feature' ]
        ); 

        $reason_plugin_not_compatible =  isset ( self::$ts_plugin_specific_questions[ 3 ] ) ? self::$ts_plugin_specific_questions[ 3 ] : '' ; 

        $reason_other = array(
            'id'                => 10,
            'text'              => self::$ts_generic_questions[ 'reason-other' ],
            'input_type'        => 'textfield',
            'input_placeholder' => ''
        );

        $long_term_user_reasons = array(
            array(
                'id'                => 1,
                'text'              => self::$ts_generic_questions[ 'reason-needed-for-a-short-period' ],
                'input_type'        => '',
                'input_placeholder' => ''
            ),
            $reason_found_better_plugin,
            $reason_not_working,
            isset ( self::$ts_plugin_specific_questions[ 0 ] ) ? self::$ts_plugin_specific_questions[ 0 ] : '',
            isset ( self::$ts_plugin_specific_questions[ 1 ] ) ? self::$ts_plugin_specific_questions[ 1 ] : '',
            isset ( self::$ts_plugin_specific_questions[ 2 ] ) ? self::$ts_plugin_specific_questions[ 2 ] : '',
            $reason_plugin_not_compatible,
            $reason_great_but_need_specific_feature,
            array(
                'id'                => 9,
                'text'              => self::$ts_generic_questions[ 'reason-dont-like-to-share-my-information' ],
                'input_type'        => '',
                'input_placeholder' => ''
            )
        );


        $uninstall_reasons[ 'default' ] = $long_term_user_reasons;

        $uninstall_reasons = apply_filters( 'ts_uninstall_reasons', $uninstall_reasons );
        array_push( $uninstall_reasons['default'], $reason_other );

        return $uninstall_reasons;
    }

    /**
     * get exact str against the slug
     *
     * @param type $slug
     *
     * @return type
     */
    public static function load_str( $slug ) {
        return self::$ts_deactivation_str[ $slug ];
    }

    /**
     * Called after the user has submitted his reason for deactivating the plugin.
     *
     * @since  1.1.2
     */
    public static function _submit_uninstall_reason_action() {
        if ( ! isset( $_POST[ 'reason_id' ] ) ) {
            exit;
        }

        $plugin_data = array();
        
        $plugin_data[ 'url' ]   = home_url();
        $plugin_data[ 'email' ] = apply_filters( 'ts_tracker_admin_email', get_option( 'admin_email' ) );

        $reason_info = isset( $_REQUEST[ 'reason_info' ] ) ? trim( stripslashes( $_REQUEST[ 'reason_info' ] ) ) : '';

        $plugin_data[ 'reason_id' ] = $_POST[ 'reason_id' ];
        $plugin_data[ 'reason_info' ] = substr( $reason_info, 0, 128 );
        $plugin_data[ 'reason_text' ] = $_POST[ 'reason_text' ];

        $plugin_data[ 'ts_meta_data_table_name' ] = 'ts_deactivation_survey';
        $plugin_data[ 'ts_plugin_name' ]          = self::$plugin_name;

        wp_safe_remote_post( self::$api_url, array(
                'method'      => 'POST',
                'timeout'     => 45,
                'redirection' => 5,
                'httpversion' => '1.0',
                'blocking'    => false,
                'headers'     => array( 'user-agent' => 'TSTracker/' . md5( esc_url( home_url( '/' ) ) ) . ';' ),
                'body'        => json_encode( $plugin_data ),
                'cookies'     => array(),
            )
        );
        // Print '1' for successful operation.
        echo 1;
        exit;
    }

}
API documentation generated by ApiGen