forked from cklosowski/edd-git-download-updater
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit-download-updater.php
executable file
·146 lines (117 loc) · 3.3 KB
/
git-download-updater.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
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
<?php
/*
Plugin Name: Easy Digital Downloads - Git Update Downloads
Plugin URI: http://ninjaforms.com
Description: Update Download files and changelog directly from BitBucket or GitHub
Version: 1.0.1
Author: The WP Ninjas
Author URI: http://wpninjas.com
*/
if ( ! defined( 'EDD_GIT_PLUGIN_DIR' ) ) {
define( 'EDD_GIT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'EDD_GIT_PLUGIN_URL' ) ) {
define( 'EDD_GIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'EDD_GIT_VERSION' ) ) {
define( 'EDD_GIT_VERSION', '1.0.1' );
}
class EDD_GIT_Download_Updater {
/*
* Store our git Username. This will be used to login to the desired repo.
*/
public $username;
/*
* Store our git Password. This wil be used to login to the desired repo.
*/
public $password;
/*
* Store our git repo name
*/
public $git_repo;
/*
* Store our desired version #.
*/
public $version;
/*
* Store our download's "version" number if Licensing is installed
*/
public $sl_version;
/*
* Store our git Repo URL
*/
public $url;
/*
* Store our destination filename
*/
public $file_name;
/*
* Store our temporary dir name
*/
public $tmp_dir;
/*
* Store our newly unzipped folder name
*/
public $sub_dir;
/*
* Store the id of the download we're updating
*/
public $download_id;
/*
* Store our EDD upload dir information
*/
public $edd_dir;
/*
* Store the current file key for our download
*/
public $file_key;
/*
* Store our errors
*/
public $errors;
/*
* Store our folder name
*/
public $folder_name;
/*
* Store our source (either bitbucket or github)
*/
public $source;
/*
* Store our changelog
*/
public $changelog = '';
/*
* Get things up and running.
*
* @since 1.0
* @return void
*/
public function __construct() {
global $post;
// Bail if the zip extension hasn't been loaded.
if ( ! class_exists('ZipArchive') )
return false;
// Include our ajax class.
require_once( EDD_GIT_PLUGIN_DIR . 'classes/ajax.php' );
$this->ajax = new EDD_GIT_Download_Updater_Ajax( $this );
// Include our admin class.
require_once( EDD_GIT_PLUGIN_DIR . 'classes/admin.php' );
$this->admin = new EDD_GIT_Download_Updater_Admin( $this );
// Include our file processing class.
require_once( EDD_GIT_PLUGIN_DIR . 'classes/process-file.php' );
$this->process_file = new EDD_GIT_Download_Updater_Process_File( $this );
// Include our repo interaction class.
require_once( EDD_GIT_PLUGIN_DIR . 'classes/repos.php' );
$this->repos = new EDD_GIT_Download_Updater_Repos( $this );
if ( class_exists( 'EDD_License' ) ) {
$license = new EDD_License( __FILE__, 'Git Download Updater', EDD_GIT_VERSION, 'WP Ninjas' );
}
}
} // End EDD_GIT_Download_Updater class
// Get the download updater class started
function edd_git_download_updater() {
$EDD_GIT_Download_Updater = new EDD_GIT_Download_Updater();
}
// Instantiate our main class
add_action( 'admin_init', 'edd_git_download_updater', 9 );