本文整理汇总了PHP中Path::get_home_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::get_home_path方法的具体用法?PHP Path::get_home_path怎么用?PHP Path::get_home_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::get_home_path方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_standard_install_in_subdirectory_2
/**
* In this scenario, WordPress is installed in a subdirectory with index.php in root and wp-config.php in the subdirectory.
*/
function test_standard_install_in_subdirectory_2()
{
$abspath = $this->test_data . '/exclude';
$this->wp_config_in($abspath);
$this->index_in(dirname($abspath));
$path = Path::get_home_path($abspath);
$this->assertEquals(dirname($abspath), $path);
}
示例2: request_download_backup
/**
* Send the download file to the browser and then redirect back to the backups page
*/
function request_download_backup()
{
check_admin_referer('hmbkp_download_backup', 'hmbkp_download_backup_nonce');
if (!file_exists(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])))) {
return;
}
$url = str_replace(wp_normalize_path(Path::get_home_path()), home_url('/'), trailingslashit(dirname(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive']))))) . urlencode(pathinfo(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])), PATHINFO_BASENAME));
global $is_apache;
if ($is_apache) {
Path::get_instance()->protect_path('reset');
$url = add_query_arg('key', HMBKP_SECURE_KEY, $url);
}
wp_safe_redirect($url, 303);
die;
}
示例3: test_standard_install_in_subdirectory
/**
* In this scenario, WordPress is installed in a subdirectory with index.php and wp-config both in root.
*/
function test_standard_install_in_subdirectory()
{
$home = get_option('home');
$siteurl = get_option('siteurl');
$sfn = $_SERVER['SCRIPT_FILENAME'];
$this->assertEquals(wp_normalize_path(untrailingslashit(ABSPATH)), Path::get_home_path());
update_option('home', 'http://localhost');
update_option('siteurl', 'http://localhost/wp');
$_SERVER['SCRIPT_FILENAME'] = 'D:\\root\\vhosts\\site\\httpdocs\\wp\\wp-admin\\options-permalink.php';
$this->assertEquals('D:/root/vhosts/site/httpdocs/', trailingslashit(Path::get_home_path()));
$_SERVER['SCRIPT_FILENAME'] = '/Users/foo/public_html/trunk/wp/wp-admin/options-permalink.php';
$this->assertEquals('/Users/foo/public_html/trunk/', trailingslashit(Path::get_home_path()));
$_SERVER['SCRIPT_FILENAME'] = 'S:/home/wordpress/trunk/wp/wp-admin/options-permalink.php';
$this->assertEquals('S:/home/wordpress/trunk/', trailingslashit(Path::get_home_path()));
update_option('home', $home);
update_option('siteurl', $siteurl);
$_SERVER['SCRIPT_FILENAME'] = $sfn;
}
示例4: printf
<td>
<?php
if (defined('HMBKP_ROOT')) {
?>
<p><?php
printf(__('You\'ve set it to: %s', 'backupwordpress'), '<code>' . esc_html(HMBKP_ROOT) . '</code>');
?>
</p>
<?php
}
?>
<p><?php
printf(__('The root directory that is backed up. Defaults to %s.', 'backupwordpress'), '<code>' . Path::get_home_path() . '</code>');
?>
<?php
_e('e.g.', 'backupwordpress');
?>
<code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p>
</td>
</tr>
<tr<?php
if (defined('HMBKP_SCHEDULE_TIME') && HMBKP_SCHEDULE_TIME !== '11pm') {
?>
class="hmbkp_active"<?php
}
示例5: sprintf
$reoccurrence = sprintf(__('weekly on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html($day) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
break;
case 'fortnightly':
$reoccurrence = sprintf(__('every two weeks on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
break;
case 'monthly':
$reoccurrence = sprintf(__('on the %1$s of each month at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(date_i18n('jS', $schedule->get_next_occurrence(false))) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
break;
case 'manually':
$reoccurrence = __('manually', 'backupwordpress');
break;
default:
$reoccurrence = __('manually', 'backupwordpress');
$schedule->set_reoccurrence('manually');
}
$server = '<code title="' . __('Check the help tab to learn how to change where your backups are stored.', 'backupwordpress') . '">' . esc_attr(str_replace(Path::get_home_path(), '', Path::get_path())) . '</code>';
// Backup to keep
switch ($schedule->get_max_backups()) {
case 1:
$backup_to_keep = sprintf(__('store the most recent backup in %s', 'backupwordpress'), $server);
break;
case 0:
$backup_to_keep = sprintf(__('don\'t store any backups in on this server', 'backupwordpress'), Path::get_path());
break;
default:
$backup_to_keep = sprintf(__('store the last %1$s backups in %2$s', 'backupwordpress'), esc_html($schedule->get_max_backups()), $server);
}
$email_msg = '';
$services = array();
foreach (Services::get_services($schedule) as $file => $service) {
if (is_wp_error($service)) {
示例6: is_path_accessible
function is_path_accessible($dir)
{
// Path is inaccessible
if (strpos($dir, Path::get_home_path()) === false) {
return false;
}
return true;
}
示例7: sprintf
break;
case 'fortnightly':
$reoccurrence = sprintf(__('every two weeks on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . $day . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
break;
case 'monthly':
$reoccurrence = sprintf(__('on the %1$s of each month at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(date_i18n('jS', $schedule->get_next_occurrence(false))) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
break;
case 'manually':
$reoccurrence = __('manually', 'backupwordpress');
break;
default:
$reoccurrence = __('manually', 'backupwordpress');
$schedule->set_reoccurrence('manually');
}
$server = '<span title="' . esc_attr(Path::get_path()) . '">' . __('this server', 'backupwordpress') . '</span>';
$server = '<code>' . esc_attr(str_replace(Path::get_home_path(), '', Path::get_path())) . '</code>';
// Backup to keep
switch ($schedule->get_max_backups()) {
case 1:
$backup_to_keep = sprintf(__('store the most recent backup in %s', 'backupwordpress'), $server);
break;
case 0:
$backup_to_keep = sprintf(__('don\'t store any backups in on this server', 'backupwordpress'), Path::get_path());
break;
default:
$backup_to_keep = sprintf(__('store the last %1$s backups in %2$s', 'backupwordpress'), esc_html($schedule->get_max_backups()), $server);
}
$email_msg = '';
$services = array();
foreach (Services::get_services($schedule) as $file => $service) {
if (is_wp_error($service)) {