2016-11-28 21:52:15 -08:00
|
|
|
<?php
|
|
|
|
|
2018-01-26 15:50:15 +01:00
|
|
|
if (!defined('UPDRAFTCENTRAL_CLIENT_DIR')) die('No access.');
|
2016-11-28 21:52:15 -08:00
|
|
|
|
2018-01-26 15:50:15 +01:00
|
|
|
/**
|
|
|
|
* - A container for all the RPC commands implemented. Commands map exactly onto method names (and hence this class should not implement anything else, beyond the constructor, and private methods)
|
|
|
|
* - Return format is array('response' => (string - a code), 'data' => (mixed));
|
|
|
|
*
|
|
|
|
* RPC commands are not allowed to begin with an underscore. So, any private methods can be prefixed with an underscore.
|
|
|
|
*/
|
2016-11-28 21:52:15 -08:00
|
|
|
abstract class UpdraftCentral_Commands {
|
|
|
|
|
|
|
|
protected $rc;
|
2018-01-26 15:50:15 +01:00
|
|
|
|
2016-11-28 21:52:15 -08:00
|
|
|
protected $ud;
|
|
|
|
|
|
|
|
public function __construct($rc) {
|
|
|
|
$this->rc = $rc;
|
|
|
|
global $updraftplus;
|
|
|
|
$this->ud = $updraftplus;
|
|
|
|
}
|
|
|
|
|
|
|
|
final protected function _admin_include() {
|
|
|
|
$files = func_get_args();
|
|
|
|
foreach ($files as $file) {
|
2018-01-26 15:50:15 +01:00
|
|
|
include_once(ABSPATH.'/wp-admin/includes/'.$file);
|
2016-11-28 21:52:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
final protected function _frontend_include() {
|
|
|
|
$files = func_get_args();
|
|
|
|
foreach ($files as $file) {
|
2018-01-26 15:50:15 +01:00
|
|
|
include_once(ABSPATH.WPINC.'/'.$file);
|
2016-11-28 21:52:15 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
final protected function _response($data = null, $code = 'rpcok') {
|
2018-01-26 15:50:15 +01:00
|
|
|
return array(
|
2016-11-28 21:52:15 -08:00
|
|
|
'response' => $code,
|
|
|
|
'data' => $data
|
2018-01-26 15:50:15 +01:00
|
|
|
);
|
2016-11-28 21:52:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
final protected function _generic_error_response($code = 'central_unspecified', $data = null) {
|
|
|
|
return $this->_response(
|
|
|
|
array(
|
|
|
|
'code' => $code,
|
|
|
|
'data' => $data
|
|
|
|
),
|
|
|
|
'rpcerror'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|