coupon_creator.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /*
  3. Plugin Name: Coupon Creator
  4. Description: This plugin creates a custom post type for coupons with a shortcode to display it on website and a single view template for printing.
  5. Version: 3.0
  6. Author: Brian Jessee
  7. Author URI: http://couponcreatorplugin.com
  8. Text Domain: coupon-creator
  9. License: GPLv2 or later
  10. */
  11. //If Direct Access Kill the Script
  12. if ( $_SERVER['SCRIPT_FILENAME'] == __FILE__ ) {
  13. die( 'Access denied.' );
  14. }
  15. define( 'COUPON_CREATOR_DIR', dirname( __FILE__ ) );
  16. define( 'COUPON_CREATOR_MAIN_PLUGIN_FILE', __FILE__ );
  17. // the main plugin class
  18. require_once dirname( __FILE__ ) . '/src/Cctor/Main.php';
  19. Cctor__Coupon__Main::instance();
  20. register_activation_hook( __FILE__, array( 'Cctor__Coupon__Main', 'activate' ) );
  21. register_deactivation_hook( __FILE__, array( 'Cctor__Coupon__Main', 'deactivate' ) );
  22. /**
  23. * Get Options from Array
  24. *
  25. * echo cctor_options('cctor_coupon_base');
  26. *
  27. * @param $option
  28. * @param null $falseable
  29. * @param null $default
  30. *
  31. * @return bool|null
  32. */
  33. function cctor_options( $option, $falseable = null, $default = null ) {
  34. $options = get_option( Cctor__Coupon__Main::OPTIONS_ID );
  35. if ( isset( $options[ $option ] ) && $options[ $option ] != '' ) {
  36. return $options[ $option ];
  37. } elseif ( $falseable ) {
  38. return false;
  39. } elseif ( $default ) {
  40. return $default;
  41. } else {
  42. return false;
  43. }
  44. }
  45. if ( ! class_exists( 'Plugin_Usage_Tracker' ) ) {
  46. require_once dirname( __FILE__ ) . '/src/tracking/class-plugin-usage-tracker.php';
  47. }
  48. if ( ! function_exists( 'coupon_creator_start_plugin_tracking' ) ) {
  49. function coupon_creator_start_plugin_tracking() {
  50. $wisdom = new Plugin_Usage_Tracker( __FILE__, 'https://couponcreatorplugin.com', array( 'coupon_creator_options' ), true, true, 1 );
  51. }
  52. coupon_creator_start_plugin_tracking();
  53. }
  54. /**
  55. * Custom Deactivation Reasons
  56. */
  57. add_filter( 'wisdom_form_text_coupon_creator', 'cctor_filter_deactivation_form' );
  58. function cctor_filter_deactivation_form( $form ) {
  59. $form['heading'] = __( 'Sorry to see you go', 'coupon-creator' );
  60. $form['body'] = __( 'Before you deactivate the plugin, would you quickly give us your reason for doing so?', 'coupon-creator' );
  61. $form['options'] = array(
  62. __( 'Could not create a coupon', 'coupon-creator' ),
  63. __( 'Could not display my coupons', 'coupon-creator' ),
  64. __( 'Looking for affiliate coupon features', 'coupon-creator' ),
  65. __( 'Could not find where to get started', 'coupon-creator' ),
  66. __( 'Not the features I wanted', 'coupon-creator' ),
  67. __( 'Only required temporarily', 'coupon-creator' ),
  68. __( 'Lack of technical documentation', 'coupon-creator' ),
  69. __( 'Found a better plugin', 'coupon-creator' ),
  70. );
  71. return $form;
  72. }