| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) { |
| 8 |
|
| 9 |
class AyeCode_Deactivation_Survey { |
| 10 |
|
| 11 |
/** |
| 12 |
* AyeCode_Deactivation_Survey instance. |
| 13 |
* |
| 14 |
* @access private |
| 15 |
* @since 1.0.0 |
| 16 |
* @var AyeCode_Deactivation_Survey There can be only one! |
| 17 |
*/ |
| 18 |
private static $instance = null; |
| 19 |
|
| 20 |
public static $plugins; |
| 21 |
|
| 22 |
public $version = "1.0.7"; |
| 23 |
|
| 24 |
public static function instance( $plugin = array() ) { |
| 25 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) { |
| 26 |
self::$instance = new AyeCode_Deactivation_Survey; |
| 27 |
self::$plugins = array(); |
| 28 |
|
| 29 |
add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) ); |
| 30 |
|
| 31 |
do_action( 'ayecode_deactivation_survey_loaded' ); |
| 32 |
} |
| 33 |
|
| 34 |
if(!empty($plugin)){ |
| 35 |
self::$plugins[] = (object)$plugin; |
| 36 |
} |
| 37 |
|
| 38 |
return self::$instance; |
| 39 |
} |
| 40 |
|
| 41 |
public function scripts() { |
| 42 |
global $pagenow; |
| 43 |
|
| 44 |
// Bail if we are not on the plugins page |
| 45 |
if ( $pagenow != "plugins.php" ) { |
| 46 |
return; |
| 47 |
} |
| 48 |
|
| 49 |
// Enqueue scripts |
| 50 |
add_thickbox(); |
| 51 |
wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js'); |
| 52 |
|
| 53 |
/* |
| 54 |
* Localized strings. Strings can be localised by plugins using this class. |
| 55 |
* We deliberately don't add textdomains here so that double textdomain warning is not given in theme review. |
| 56 |
*/ |
| 57 |
wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array( |
| 58 |
'quick_feedback' => __( 'Quick Feedback', 'ayecode-connect' ), |
| 59 |
'foreword' => __( 'If you would be kind enough, please tell us why you\'re deactivating?', 'ayecode-connect' ), |
| 60 |
'better_plugins_name' => __( 'Please tell us which plugin?', 'ayecode-connect' ), |
| 61 |
'please_tell_us' => __( 'Please tell us the reason so we can improve the plugin', 'ayecode-connect' ), |
| 62 |
'do_not_attach_email' => __( 'Do not send my e-mail address with this feedback', 'ayecode-connect' ), |
| 63 |
'brief_description' => __( 'Please give us any feedback that could help us improve', 'ayecode-connect' ), |
| 64 |
'cancel' => __( 'Cancel', 'ayecode-connect' ), |
| 65 |
'skip_and_deactivate' => __( 'Skip & Deactivate', 'ayecode-connect' ), |
| 66 |
'submit_and_deactivate' => __( 'Submit & Deactivate', 'ayecode-connect' ), |
| 67 |
'please_wait' => __( 'Please wait', 'ayecode-connect' ), |
| 68 |
'get_support' => __( 'Get Support', 'ayecode-connect' ), |
| 69 |
'documentation' => __( 'Documentation', 'ayecode-connect' ), |
| 70 |
'thank_you' => __( 'Thank you!', 'ayecode-connect' ), |
| 71 |
)); |
| 72 |
|
| 73 |
// Plugins |
| 74 |
$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins); |
| 75 |
|
| 76 |
// Reasons |
| 77 |
$defaultReasons = array( |
| 78 |
'suddenly-stopped-working' => __( 'The plugin suddenly stopped working', 'ayecode-connect' ), |
| 79 |
'plugin-broke-site' => __( 'The plugin broke my site', 'ayecode-connect' ), |
| 80 |
'plugin-setup-difficult' => __( 'Too difficult to setup', 'ayecode-connect' ), |
| 81 |
'plugin-design-difficult' => __( 'Too difficult to get the design i want', 'ayecode-connect' ), |
| 82 |
'no-longer-needed' => __( 'I don\'t need this plugin any more', 'ayecode-connect' ), |
| 83 |
'found-better-plugin' => __( 'I found a better plugin', 'ayecode-connect' ), |
| 84 |
'temporary-deactivation' => __( 'It\'s a temporary deactivation, I\'m troubleshooting', 'ayecode-connect' ), |
| 85 |
'other' => __( 'Other', 'ayecode-connect' ), |
| 86 |
); |
| 87 |
|
| 88 |
foreach( $plugins as $plugin ) { |
| 89 |
$plugin->reasons = apply_filters( 'ayecode_deactivation_survey_reasons', $defaultReasons, $plugin ); |
| 90 |
$plugin->url = home_url(); |
| 91 |
$plugin->activated = 0; |
| 92 |
} |
| 93 |
|
| 94 |
// Send plugin data |
| 95 |
wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
} |