本文整理汇总了PHP中UpdraftPlus_Options::admin_page方法的典型用法代码示例。如果您正苦于以下问题:PHP UpdraftPlus_Options::admin_page方法的具体用法?PHP UpdraftPlus_Options::admin_page怎么用?PHP UpdraftPlus_Options::admin_page使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UpdraftPlus_Options
的用法示例。
在下文中一共展示了UpdraftPlus_Options::admin_page方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restore_backup
private function restore_backup($timestamp, $continuation_data = null)
{
@set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);
global $wp_filesystem, $updraftplus;
$backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
if (!isset($backup_history[$timestamp]) || !is_array($backup_history[$timestamp])) {
echo '<p>' . __('This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus') . " {$timestamp}</p><br/>";
return new WP_Error('does_not_exist', __('Backup does not exist in the backup history', 'updraftplus'));
}
// request_filesystem_credentials passes on fields just via hidden name/value pairs.
// Build array of parameters to be passed via this
$extra_fields = array();
if (isset($_POST['updraft_restore']) && is_array($_POST['updraft_restore'])) {
foreach ($_POST['updraft_restore'] as $entity) {
$_POST['updraft_restore_' . $entity] = 1;
$extra_fields[] = 'updraft_restore_' . $entity;
}
}
if (is_array($continuation_data)) {
foreach ($continuation_data['second_loop_entities'] as $type => $files) {
$_POST['updraft_restore_' . $type] = 1;
if (!in_array('updraft_restore_' . $type, $extra_fields)) {
$extra_fields[] = 'updraft_restore_' . $type;
}
}
if (!empty($continuation_data['restore_options'])) {
$restore_options = $continuation_data['restore_options'];
}
}
// Now make sure that updraft_restorer_ option fields get passed along to request_filesystem_credentials
foreach ($_POST as $key => $value) {
if (0 === strpos($key, 'updraft_restorer_')) {
$extra_fields[] = $key;
}
}
$credentials = request_filesystem_credentials(UpdraftPlus_Options::admin_page() . "?page=updraftplus&action=updraft_restore&backup_timestamp={$timestamp}", '', false, false, $extra_fields);
WP_Filesystem($credentials);
if ($wp_filesystem->errors->get_error_code()) {
echo '<p><em><a href="https://updraftplus.com/faqs/asked-ftp-details-upon-restorationmigration-updates/">' . __('Why am I seeing this?', 'updraftplus') . '</a></em></p>';
foreach ($wp_filesystem->errors->get_error_messages() as $message) {
show_message($message);
}
exit;
}
// If we make it this far then WP_Filesystem has been instantiated and is functional
# Set up logging
$updraftplus->backup_time_nonce();
$updraftplus->jobdata_set('job_type', 'restore');
$updraftplus->jobdata_set('job_time_ms', $updraftplus->job_time_ms);
$updraftplus->logfile_open($updraftplus->nonce);
# Provide download link for the log file
# TODO: Automatic purging of old log files
# TODO: Provide option to auto-email the log file
echo '<h1>' . __('UpdraftPlus Restoration: Progress', 'updraftplus') . '</h1><div id="updraft-restore-progress">';
$this->show_admin_warning('<a target="_blank" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce=' . htmlspecialchars($updraftplus->nonce) . '">' . __('Follow this link to download the log file for this restoration (needed for any support requests).', 'updraftplus') . '</a>');
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
$foreign_known = apply_filters('updraftplus_accept_archivename', array());
$service = isset($backup_history[$timestamp]['service']) ? $backup_history[$timestamp]['service'] : false;
if (!is_array($service)) {
$service = array($service);
}
// Now, need to turn any updraft_restore_<entity> fields (that came from a potential WP_Filesystem form) back into parts of the _POST array (which we want to use)
if (empty($_POST['updraft_restore']) || !is_array($_POST['updraft_restore'])) {
$_POST['updraft_restore'] = array();
}
$backup_set = $backup_history[$timestamp];
$entities_to_restore = array();
foreach ($_POST['updraft_restore'] as $entity) {
if (empty($backup_set['meta_foreign'])) {
$entities_to_restore[$entity] = $entity;
} else {
if ('db' == $entity && !empty($foreign_known[$backup_set['meta_foreign']]) && !empty($foreign_known[$backup_set['meta_foreign']]['separatedb'])) {
$entities_to_restore[$entity] = 'db';
} else {
$entities_to_restore[$entity] = 'wpcore';
}
}
}
foreach ($_POST as $key => $value) {
if (0 === strpos($key, 'updraft_restore_')) {
$nkey = substr($key, 16);
if (!isset($entities_to_restore[$nkey])) {
$_POST['updraft_restore'][] = $nkey;
if (empty($backup_set['meta_foreign'])) {
$entities_to_restore[$nkey] = $nkey;
} else {
if ('db' == $entity && !empty($foreign_known[$backup_set['meta_foreign']]['separatedb'])) {
$entities_to_restore[$nkey] = 'db';
} else {
$entities_to_restore[$nkey] = 'wpcore';
}
}
}
}
}
if (0 == count($_POST['updraft_restore'])) {
echo '<p>' . __('ABORT: Could not find the information on which entities to restore.', 'updraftplus') . '</p>';
echo '<p>' . __('If making a request for support, please include this information:', 'updraftplus') . ' ' . count($_POST) . ' : ' . htmlspecialchars(serialize($_POST)) . '</p>';
return new WP_Error('missing_info', 'Backup information not found');
}
//.........这里部分代码省略.........
示例2: admin_footer
public function admin_footer()
{
global $updraftplus, $pagenow;
// Next, the actions that only come on the UpdraftPlus page
if ($pagenow != UpdraftPlus_Options::admin_page() || empty($_REQUEST['page']) || 'updraftplus' != $_REQUEST['page']) {
return;
}
?>
<script>
jQuery(document).ready(function($) {
$('#updraft_migrate_modal_main').on('click', '.updraft_migrate_local_key_delete', function() {
var $keylink = $(this);
var keyid = $keylink.data('keyid');
var data = {
action: 'updraft_ajax',
subaction: 'doaction',
subsubaction: 'updraft_migrate_key_delete',
nonce: '<?php
echo wp_create_nonce('updraftplus-credentialtest-nonce');
?>
',
keyid: keyid,
}
$keylink.html(updraftlion.deleting);
jQuery.post(ajaxurl, data, function(response) {
try {
resp = jQuery.parseJSON(response);
if (resp.hasOwnProperty('ourkeys')) {
$('#updraft_migrate_our_keys_container').html(resp.ourkeys);
} else {
alert(updraftlion.unexpectedresponse+' '+response);
console.log(resp);
console.log(response);
}
} catch(err) {
alert(updraftlion.unexpectedresponse+' '+response);
console.log(err);
console.log(response);
return;
}
});
});
$('#updraft_migrate_modal_main').on('click', '#updraft_migrate_send_button', function() {
$('#updraft_migrate_modal_main').hide();
var site_id = $('#updraft_remotesites_selector').val();
var site_url = $('#updraft_remotesites_selector option:selected').text();
$('#updraft_migrate_modal_alt').html('<p><strong>'+updraftlion.sendtosite+'</strong> '+site_url+'</p><p id="updraft_migrate_testinginprogress">'+updraftlion.testingconnection+'</p>').slideDown('fast');
var data = {
action: 'updraft_ajax',
subaction: 'doaction',
subsubaction: 'updraft_remote_ping_test',
nonce: '<?php
echo wp_create_nonce('updraftplus-credentialtest-nonce');
?>
',
id: site_id,
url: site_url
}
$.post(ajaxurl, data, function(response) {
try {
resp = $.parseJSON(response);
if (resp.hasOwnProperty('e')) {
console.log(resp);
$('#updraft_migrate_modal_alt').append('<p style="color:red;">'+updraftlion.unexpectedresponse+' '+resp.r+' ('+resp.code+'). '+updraftlion.checkrpcsetup+'</p>');
if (resp.hasOwnProperty('moreinfo')) {
$('#updraft_migrate_modal_alt').append(resp.moreinfo);
}
// alert(updraftlion.unexpectedresponse+' '+resp.r+' ('+resp.code+'). '+updraftlion.checkrpcsetup);
} else if (resp.hasOwnProperty('success')) {
if (resp.hasOwnProperty('r')) {
$('#updraft_migrate_testinginprogress').replaceWith('<p style="">'+resp.r+'</p>');
}
var entities = [ '<?php
$entities = $updraftplus->get_backupable_file_entities();
echo implode("', '", array_keys($entities));
?>
' ];
var $mmodal = $("#updraft-migrate-modal");
var buttons = {};
buttons[updraftlion.send] = function () {
var onlythisfileentity = '';
var arrayLength = entities.length;
for (var i = 0; i < arrayLength; i++) {
if ($('#remotesend_updraft_include_'+entities[i]).is(':checked')) {
if (onlythisfileentity != '') { onlythisfileentity += ','; }
onlythisfileentity += entities[i];
}
//Do something
}
var backupnow_nodb = $('#remotesend_backupnow_db').is(':checked') ? 0 : 1;
var backupnow_nofiles = 0;
if ('' == onlythisfileentity) { backupnow_nofiles = 1; }
var backupnow_nocloud = 1;
//.........这里部分代码省略.........
示例3: restore_backup
function restore_backup($timestamp)
{
@set_time_limit(900);
global $wp_filesystem, $updraftplus;
$backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
if (!is_array($backup_history[$timestamp])) {
echo '<p>' . __('This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus') . " {$timestamp}</p><br/>";
return new WP_Error('does_not_exist', __('Backup does not exist in the backup history', 'updraftplus'));
}
// request_filesystem_credentials passes on fields just via hidden name/value pairs.
// Build array of parameters to be passed via this
$extra_fields = array();
if (isset($_POST['updraft_restore']) && is_array($_POST['updraft_restore'])) {
foreach ($_POST['updraft_restore'] as $entity) {
$_POST['updraft_restore_' . $entity] = 1;
$extra_fields[] = 'updraft_restore_' . $entity;
}
}
// Now make sure that updraft_restorer_ option fields get passed along to request_filesystem_credentials
foreach ($_POST as $key => $value) {
if (0 === strpos($key, 'updraft_restorer_')) {
$extra_fields[] = $key;
}
}
$credentials = request_filesystem_credentials(UpdraftPlus_Options::admin_page() . "?page=updraftplus&action=updraft_restore&backup_timestamp={$timestamp}", '', false, false, $extra_fields);
WP_Filesystem($credentials);
if ($wp_filesystem->errors->get_error_code()) {
foreach ($wp_filesystem->errors->get_error_messages() as $message) {
show_message($message);
}
exit;
}
# Set up logging
$updraftplus->backup_time_nonce();
$updraftplus->jobdata_set('job_type', 'restore');
$updraftplus->jobdata_set('job_time_ms', $updraftplus->job_time_ms);
$updraftplus->logfile_open($updraftplus->nonce);
# Provide download link for the log file
#echo '<p><a target="_new" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce='.htmlspecialchars($updraftplus->nonce).'">'.__('Follow this link to download the log file for this restoration.', 'updraftplus').'</a></p>';
# TODO: Automatic purging of old log files
# TODO: Provide option to auto-email the log file
//if we make it this far then WP_Filesystem has been instantiated and is functional (tested with ftpext, what about suPHP and other situations where direct may work?)
echo '<h1>' . __('UpdraftPlus Restoration: Progress', 'updraftplus') . '</h1><div id="updraft-restore-progress">';
$this->show_admin_warning('<a target="_new" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce=' . htmlspecialchars($updraftplus->nonce) . '">' . __('Follow this link to download the log file for this restoration (needed for any support requests).', 'updraftplus') . '</a>');
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
$service = isset($backup_history[$timestamp]['service']) ? $backup_history[$timestamp]['service'] : false;
if (!is_array($service)) {
$service = array($service);
}
// Now, need to turn any updraft_restore_<entity> fields (that came from a potential WP_Filesystem form) back into parts of the _POST array (which we want to use)
if (empty($_POST['updraft_restore']) || !is_array($_POST['updraft_restore'])) {
$_POST['updraft_restore'] = array();
}
$entities_to_restore = array_flip($_POST['updraft_restore']);
$entities_log = '';
foreach ($_POST as $key => $value) {
if (strpos($key, 'updraft_restore_') === 0) {
$nkey = substr($key, 16);
if (!isset($entities_to_restore[$nkey])) {
$_POST['updraft_restore'][] = $nkey;
$entities_to_restore[$nkey] = 1;
$entities_log .= '' == $entities_log ? $nkey : ",{$nkey}";
}
}
}
$updraftplus->log("Restore job started. Entities to restore: {$entities_log}");
if (0 == count($_POST['updraft_restore'])) {
echo '<p>' . __('ABORT: Could not find the information on which entities to restore.', 'updraftplus') . '</p>';
echo '<p>' . __('If making a request for support, please include this information:', 'updraftplus') . ' ' . count($_POST) . ' : ' . htmlspecialchars(serialize($_POST)) . '</p>';
return new WP_Error('missing_info', 'Backup information not found');
}
set_error_handler(array($updraftplus, 'php_error'), E_ALL & ~E_STRICT);
/*
$_POST['updraft_restore'] is typically something like: array( 0=>'db', 1=>'plugins', 2=>'themes'), etc.
i.e. array ( 'db', 'plugins', themes')
*/
$backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
$backup_set = $backup_history[$timestamp];
uksort($backup_set, array($this, 'sort_restoration_entities'));
// We use a single object for each entity, because we want to store information about the backup set
require_once UPDRAFTPLUS_DIR . '/restorer.php';
global $updraftplus_restorer;
$updraftplus_restorer = new Updraft_Restorer(new Updraft_Restorer_Skin());
$second_loop = array();
echo "<h2>" . __('Final checks', 'updraftplus') . '</h2>';
// First loop: make sure that files are present + readable; and populate array for second loop
foreach ($backup_set as $type => $files) {
// All restorable entities must be given explicitly, as we can store other arbitrary data in the history array
if (!isset($backupable_entities[$type]) && 'db' != $type) {
continue;
}
if (isset($backupable_entities[$type]['restorable']) && $backupable_entities[$type]['restorable'] == false) {
continue;
}
if (!isset($entities_to_restore[$type])) {
continue;
}
if ($type == 'wpcore' && is_multisite() && 0 === $updraftplus_restorer->ud_backup_is_multisite) {
echo "<p>{$type}: <strong>";
echo __('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.', 'updraftplus');
//.........这里部分代码省略.........
示例4: addons_admin_url
public function addons_admin_url()
{
return UpdraftPlus_Options::admin_page() . '?page=' . UDADDONS2_PAGESLUG . '&tab=addons';
// if (is_multisite()) {
// return network_admin_url('settings.php?page='.UDADDONS2_PAGESLUG.'&tab=addons');
// } else {
// return admin_url('options-general.php?page='.UDADDONS2_PAGESLUG.'&tab=addons');
// }
}
示例5: log_button
private function log_button($backup)
{
global $updraftplus;
$updraft_dir = $updraftplus->backups_dir_location();
$ret = '';
if (isset($backup['nonce']) && preg_match('/^[0-9a-f]{12}$/', $backup['nonce']) && is_readable($updraft_dir . '/log.' . $backup['nonce'] . '.txt')) {
$nval = $backup['nonce'];
$lt = esc_attr(__('View Log', 'updraftplus'));
$url = UpdraftPlus_Options::admin_page();
$ret .= <<<ENDHERE
<div style="float:left; clear:none;" class="mwp-updraft-viewlogdiv">
<form action="{$url}" method="get">
<input type="hidden" name="action" value="downloadlog" />
<input type="hidden" name="page" value="updraftplus" />
<input type="hidden" name="updraftplus_backup_nonce" value="{$nval}" />
<input type="submit" value="{$lt}" class="updraft-log-link button" onclick="event.preventDefault(); mainwp_updraft_popuplog('{$nval}', this);" />
</form>
</div>
ENDHERE;
return $ret;
}
}