-
Notifications
You must be signed in to change notification settings - Fork 1
/
coupon_creator.php
95 lines (83 loc) · 2.94 KB
/
coupon_creator.php
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
<?php
/*
Plugin Name: Coupon Creator
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.
Version: 3.4.0
Author: Brian Jessee
Author URI: http://couponcreatorplugin.com
Text Domain: coupon-creator
License: GPLv2 or later
*/
//If Direct Access Kill the Script
if ( $_SERVER['SCRIPT_FILENAME'] == __FILE__ ) {
die( 'Access denied.' );
}
define( 'COUPON_CREATOR_DIR', dirname( __FILE__ ) );
define( 'COUPON_CREATOR_MAIN_PLUGIN_FILE', __FILE__ );
// Load the Composer autoload file.
require_once dirname( COUPON_CREATOR_MAIN_PLUGIN_FILE ) . '/vendor/autoload.php';
// the main plugin class
require_once dirname( __FILE__ ) . '/src/Cctor/Main.php';
Cctor__Coupon__Main::instance();
register_activation_hook( __FILE__, [ 'Cctor__Coupon__Main', 'activate' ] );
register_deactivation_hook( __FILE__, [ 'Cctor__Coupon__Main', 'deactivate' ] );
/**
* Register uninstall script.
*
* @since 3.4.0
*/
register_uninstall_hook( __FILE__, 'cctor_uninstall_script' );
function cctor_uninstall_script() {
require_once dirname( __FILE__ ) . '/src/Cctor/Main.php';
}
/**
* Get Options from Array
*
* echo cctor_options('cctor_coupon_base');
*
* @param $option
* @param null $falseable
* @param null $default
*
* @return bool|null
*/
function cctor_options( $option, $falseable = null, $default = null ) {
$options = get_option( Cctor__Coupon__Main::OPTIONS_ID );
if ( isset( $options[ $option ] ) && $options[ $option ] != '' ) {
return $options[ $option ];
} elseif ( $falseable ) {
return false;
} elseif ( $default ) {
return $default;
} else {
return false;
}
}
if ( ! class_exists( 'Plugin_Usage_Tracker' ) ) {
require_once dirname( __FILE__ ) . '/src/tracking/class-plugin-usage-tracker.php';
}
if ( ! function_exists( 'coupon_creator_start_plugin_tracking' ) ) {
function coupon_creator_start_plugin_tracking() {
$wisdom = new Plugin_Usage_Tracker( __FILE__, 'https://couponcreatorplugin.com', array( 'coupon_creator_options' ), true, true, 1 );
}
coupon_creator_start_plugin_tracking();
}
/**
* Custom Deactivation Reasons
*/
add_filter( 'wisdom_form_text_coupon_creator', 'cctor_filter_deactivation_form' );
function cctor_filter_deactivation_form( $form ) {
$form['heading'] = __( 'Sorry to see you go', 'coupon-creator' );
$form['body'] = __( 'Before you deactivate the plugin, would you quickly give us your reason for doing so?', 'coupon-creator' );
$form['options'] = array(
__( 'Could not create a coupon', 'coupon-creator' ),
__( 'Could not display my coupons', 'coupon-creator' ),
__( 'Looking for affiliate coupon features', 'coupon-creator' ),
__( 'Could not find where to get started', 'coupon-creator' ),
__( 'Not the features I wanted', 'coupon-creator' ),
__( 'Only required temporarily', 'coupon-creator' ),
__( 'Lack of technical documentation', 'coupon-creator' ),
__( 'Found a better plugin', 'coupon-creator' ),
);
return $form;
}