-
Notifications
You must be signed in to change notification settings - Fork 6
/
wpcd-sample-addon.php
88 lines (75 loc) · 2.31 KB
/
wpcd-sample-addon.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
<?php
/**
* Plugin Name: WPCD Sample Add-on
* Plugin URI: https://wpclouddeploy.com
* Description: A sample add-on for the WPCloudPanel (formerly WPCloudDeploy) plugin
* Version: 1.1.0
* Author: WPCloudDeploy
* Author URI: https://wpclouddeploy.com
*/
require_once ABSPATH . 'wp-admin/includes/plugin.php';
/**
* Bootstrap class for this sample plugin.
*/
class WPCD_Sample_AddOn {
/**
* Constructor function of course.
*/
public function __construct() {
$plugin_data = get_plugin_data( __FILE__ );
if ( ! defined( 'WPCDSAMPLE_URL' ) ) {
define( 'WPCDSAMPLE_URL', plugin_dir_url( __FILE__ ) );
define( 'WPCDSAMPLE_PATH', plugin_dir_path( __FILE__ ) );
define( 'WPCDSAMPLE_PLUGIN', plugin_basename( __FILE__ ) );
define( 'WPCDSAMPLE_EXTENSION', $plugin_data['Name'] );
define( 'WPCDSAMPLE_VERSION', $plugin_data['Version'] );
define( 'WPCDSAMPLE_TEXTDOMAIN', 'wpcd' );
define( 'WPCDAMPLE_REQUIRES', '2.0.3' );
}
/* Run things after WordPress is loaded */
add_action( 'init', array( $this, 'required_files' ), -20 );
/* Insert wpapp tabs where they need to go */
add_action( 'wpcd_wpapp_include_app_tabs', array( $this, 'required_wpapp_tab_files' ) );
}
/**
* Include additional files as needed
*
* Action Hook: init
*/
public function required_files() {
include_once wpcd_path . 'includes/core/apps/wordpress-app/tabs/tabs.php';
include_once WPCDSAMPLE_PATH . '/includes/wpapp-tutorial04.php';
}
/**
* Insert tabs on the app detail screen
*
* Action Hook: wpcd_wpapp_include_app_tabs
*/
public function required_wpapp_tab_files() {
include_once WPCDSAMPLE_PATH . '/includes/wpapp-tabs-sample.php';
}
/**
* Placeholder activation function.
*
* @TODO: You can hook into this function with a WP filter
* if you need to do things when the plugin is activated.
* Right now nothing in this gets executed.
*/
public function activation_hook() {
// first install.
$version = get_option( 'wpcdsample_version' );
if ( ! $version ) {
update_option( 'wpcdsample_last_version_upgrade', WPCDSAMPLE_VERSION );
}
if ( WPCDSAMPLE_VERSION !== $version ) {
update_option( 'wpcd_version', WPCDSAMPLE_VERSION );
}
// Some setup options here?
}
}
/**
* Bootstrap the class
*/
if ( class_exists( 'WPCD_Init' ) ) {
$wpcdsample = new WPCD_Sample_AddOn();
}