本文整理匯總了PHP中Path::get_path方法的典型用法代碼示例。如果您正苦於以下問題:PHP Path::get_path方法的具體用法?PHP Path::get_path怎麽用?PHP Path::get_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Path
的用法示例。
在下文中一共展示了Path::get_path方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: tearDown
public function tearDown()
{
if (file_exists(Path::get_path() . '/.files')) {
unlink(Path::get_path() . '/.files');
}
$this->cleanup_test_data();
delete_transient('hmbkp_directory_filesizes_running');
}
示例2: highlight
public static function highlight($nav)
{
if (!empty(Path::get_path()['call_parts'][0])) {
if (Path::get_path()['call_parts'][0] == $nav) {
return 'active';
}
} else {
if ($nav == 'index') {
return 'active';
}
}
}
示例3: backup
/**
* Perform a Backup.
*
* ## OPTIONS
*
* [--files_only]
* : Backup files only, default to off
*
* [--database_only]
* : Backup database only, defaults to off
*
* [--destination]
* : dir that the backup should be save in, defaults to your existing backups directory
*
* [--root]
* : dir that should be backed up, defaults to site root.
*
* [--archive_filename]
* : filename for the resulting zip file
*
* [--excludes]
* : list of paths you'd like to exclude
*
* ## Usage
*
* wp backupwordpress backup [--files_only] [--database_only] [--path<dir>] [--root<dir>] [--zip_command_path=<path>] [--mysqldump_command_path=<path>]
*
* @todo errors should be bubbled from Backup, Scheduled_Backup and the like instead of being repeated.
*/
public function backup($args, $assoc_args)
{
add_action('hmbkp_mysqldump_started', function () {
\WP_CLI::line(__('Backup: Dumping database...', 'backupwordpress'));
});
add_action('hmbkp_archive_started', function () {
\WP_CLI::line(__('Backup: Zipping everything up...', 'backupwordpress'));
});
if (!empty($assoc_args['destination'])) {
Path::get_instance()->set_path($assoc_args['destination']);
}
Path::get_instance()->cleanup();
if (!empty($assoc_args['root'])) {
Path::get_instance()->set_root($assoc_args['root']);
}
if (!is_dir(Path::get_path())) {
\WP_CLI::error(__('Invalid backup path', 'backupwordpress'));
return false;
}
if (!is_dir(Path::get_root()) || !is_readable(Path::get_root())) {
\WP_CLI::error(__('Invalid root path', 'backupwordpress'));
return false;
}
$filename = 'backup.zip';
if (isset($assoc_args['archive_filename'])) {
$filename = $assoc_args['archive_filename'];
}
$hm_backup = new Backup($filename);
if (!empty($assoc_args['files_only'])) {
$hm_backup->set_type('file');
}
if (!empty($assoc_args['database_only'])) {
$hm_backup->set_type('database');
}
if (!empty($assoc_args['excludes'])) {
$hm_backup->set_excludes($assoc_args['excludes']);
}
$hm_backup->run();
if (file_exists($hm_backup->get_backup_filepath())) {
\WP_CLI::success(__('Backup Complete: ', 'backupwordpress') . $hm_backup->get_backup_filepath());
} else {
\WP_CLI::error(__('Backup Failed', 'backupwordpress'));
}
}
示例4: control
public static function control()
{
$view = Path::get_path()['call_parts'][0];
$addUrl = HOST_NAME . 'admin/' . $view . '/add';
$editUrl = HOST_NAME . 'admin/' . $view . '/edit/';
$deleteUrl = HOST_NAME . 'admin/' . $view . '/delete/';
$allCategories = self::read("SELECT * FROM categories", PDO::FETCH_CLASS, __CLASS__);
$table = '<a href="' . $addUrl . '" class="add-link">+ Add New Category</a>';
$table .= '<table class="admin-table">
<tr>
<th width="3%">#</th>
<th>Category Name</th>
<th width="10%" colspan="2">Control</th>
</tr>
';
if ($allCategories != false) {
if (is_object($allCategories)) {
$table .= '<tr>
<td>' . $allCategories->id . '</td>
<td>' . $allCategories->name . '</td>
<td class="button">
<a href="' . $editUrl . $allCategories->id . '"><i class="fa fa-edit"></i></a>
<a href="' . $deleteUrl . $allCategories->id . '" class="delete"><i class="fa fa-trash-o"></i></a>
</td>
</tr>';
} else {
foreach ($allCategories as $category) {
$table .= '<tr>
<td>' . $category->id . '</td>
<td>' . $category->name . '</td>
<td class="button">
<a href="' . $editUrl . $category->id . '"><i class="fa fa-edit"></i></a>
<a href="' . $deleteUrl . $category->id . '" class="delete"><i class="fa fa-trash-o"></i></a>
</td>
</tr>';
}
}
} else {
$table .= '<tr><td colspan="4">No Categories Found</td></tr>';
}
$table .= '</table>';
return $table;
}
示例5: control
public static function control()
{
$view = Path::get_path()['call_parts'][0];
$editUrl = HOST_NAME . 'admin/' . $view . '/edit/';
$deleteUrl = HOST_NAME . 'admin/' . $view . '/delete/';
$users = self::read("SELECT * FROM Users WHERE id != " . User::theUser()->id, PDO::FETCH_CLASS, __CLASS__);
$table = '<table class="admin-table">
<tr>
<th width="3%">#</th>
<th>Username</th>
<th width="10%" colspan="2">Control</th>
</tr>
';
if ($users != false) {
if (is_object($users)) {
$table .= '<tr>
<td>' . $users->id . '</td>
<td>' . $users->username . '</td>
<td class="button">
<a href="' . $editUrl . $users->id . '"><i class="fa fa-edit"></i></a>
<a href="' . $deleteUrl . $users->id . '" class="delete"><i class="fa fa-trash-o"></i></a>
</td>
</tr>';
} else {
foreach ($users as $item) {
$table .= '<tr>
<td>' . $item->id . '</td>
<td>' . $item->username . '</td>
<td class="button">
<a href="' . $editUrl . $item->id . '"><i class="fa fa-edit"></i></a>
<a href="' . $deleteUrl . $item->username . '" class="delete"><i class="fa fa-trash-o"></i></a>
</td>
</tr>';
}
}
} else {
$table .= '<tr><td colspan="4">No User Found</td></tr>';
}
$table .= '</table>';
return $table;
}
示例6: backup_database
public function backup_database()
{
if ($this->status) {
$this->status->set_status(__('Backing up database...', 'backupwordpress'));
}
$database_backup_engines = apply_filters('hmbkp_database_backup_engines', array(new Mysqldump_Database_Backup_Engine(), new IMysqldump_Database_Backup_Engine()));
// Set the file backup engine settings
if ($this->database_dump_filename) {
foreach ($database_backup_engines as &$backup_engine) {
$backup_engine->set_backup_filename($this->database_dump_filename);
}
}
// Dump the database
$database_dump = $this->perform_backup($database_backup_engines);
if (is_a($database_dump, __NAMESPACE__ . '\\Backup_Engine')) {
$this->database_dump_filepath = $database_dump->get_backup_filepath();
}
// Fire up the file backup engines
$file_backup_engines = apply_filters('hmbkp_file_backup_engines', array(new Zip_File_Backup_Engine(), new Zip_Archive_File_Backup_Engine()));
// Set the file backup engine settings
foreach ($file_backup_engines as &$backup_engine) {
$backup_engine->set_backup_filename($this->backup_filename);
$backup_engine->set_excludes(new Excludes(array('*.zip', 'index.html', '.htaccess', '.*-running')));
}
// Zip up the database dump
$root = Path::get_root();
Path::get_instance()->set_root(Path::get_path());
$file_backup = $this->perform_backup($file_backup_engines);
Path::get_instance()->set_root($root);
if (is_a($file_backup, __NAMESPACE__ . '\\Backup_Engine')) {
$this->backup_filepath = $file_backup->get_backup_filepath();
}
// Delete the Database Backup now that we've zipped it up
if (file_exists($this->database_dump_filepath)) {
unlink($this->database_dump_filepath);
}
}
示例7: get_user_excludes
/**
* Get the user defined excludes.
*
* @return array The array of excludes.
*/
public function get_user_excludes()
{
$excludes = $this->excludes;
// If path() is inside root(), exclude it.
if (strpos(Path::get_path(), Path::get_root()) !== false && Path::get_root() !== Path::get_path()) {
array_unshift($excludes, trailingslashit(Path::get_path()));
}
return $this->normalize($excludes);
}
示例8: recalculate_directory_filesize
/**
*
* @param null
*/
function recalculate_directory_filesize()
{
if (!isset($_GET['hmbkp_recalculate_directory_filesize']) || !check_admin_referer('hmbkp-recalculate_directory_filesize')) {
return;
}
// Delete the cached directory size
@unlink(trailingslashit(Path::get_path()) . '.files');
$url = add_query_arg(array('action' => 'hmbkp_edit_schedule', 'hmbkp_panel' => 'hmbkp_edit_schedule_excludes'), get_settings_url());
if (isset($_GET['hmbkp_directory_browse'])) {
$url = add_query_arg('hmbkp_directory_browse', sanitize_text_field($_GET['hmbkp_directory_browse']), $url);
}
wp_safe_redirect($url, '303');
die;
}
示例9: set_server_config_notices
function set_server_config_notices()
{
$notices = Notices::get_instance();
$messages = array();
if (!is_dir(Path::get_path())) {
$messages[] = sprintf(__('The backups directory can\'t be created because your %s directory isn\'t writable. Please create the folder manually.', 'backupwordpress'), '<code>' . esc_html(dirname(Path::get_path())) . '</code>');
}
if (is_dir(Path::get_path()) && !wp_is_writable(Path::get_path())) {
$messages[] = __('The backups directory isn\'t writable. Please fix the permissions.', 'backupwordpress');
}
if (Backup_Utilities::is_safe_mode_on()) {
$messages[] = sprintf(__('%1$s is running in %2$s, please contact your host and ask them to disable it. BackUpWordPress may not work correctly whilst %3$s is on.', 'backupwordpress'), '<code>PHP</code>', sprintf('<a href="%1$s">%2$s</a>', __('http://php.net/manual/en/features.safe-mode.php', 'backupwordpress'), __('Safe Mode', 'backupwordpress')), '<code>' . __('Safe Mode', 'backupwordpress') . '</code>');
}
if (defined('HMBKP_PATH') && HMBKP_PATH) {
// Suppress open_basedir warning https://bugs.php.net/bug.php?id=53041
if (!path_in_php_open_basedir(HMBKP_PATH)) {
$messages[] = sprintf(__('Your server has an %1$s restriction in effect and your custom backups directory (%2$s) is not within the allowed path(s): (%3$s).', 'backupwordpress'), '<code>open_basedir</code>', '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(@ini_get('open_basedir')) . '</code>');
} elseif (!file_exists(HMBKP_PATH)) {
$messages[] = sprintf(__('Your custom path does not exist', 'backupwordpress'));
} else {
if (!is_dir(HMBKP_PATH)) {
$messages[] = sprintf(__('Your custom backups directory %1$s doesn\'t exist and can\'t be created, your backups will be saved to %2$s instead.', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(Path::get_path()) . '</code>');
}
if (is_dir(HMBKP_PATH) && !wp_is_writable(HMBKP_PATH)) {
$messages[] = sprintf(__('Your custom backups directory %1$s isn\'t writable, new backups will be saved to %2$s instead.', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(Path::get_path()) . '</code>');
}
}
}
if (!is_readable(Path::get_root())) {
$messages[] = sprintf(__('Your site root path %s isn\'t readable.', 'backupwordpress'), '<code>' . Path::get_root() . '</code>');
}
if (!Requirement_Mysqldump_Command_Path::test() && !Requirement_PDO::test()) {
$messages[] = sprintf(__('Your database cannot be backed up because your server doesn\'t support %1$s or %2$s. Please contact your host and ask them to enable them.', 'backupwordpress'), '<code>mysqldump</code>', '<code>PDO</code>');
}
if (count($messages) > 0) {
$notices->set_notices('server_config', $messages, false);
}
}
示例10: printf
<td>
<?php
if (defined('HMBKP_PATH')) {
?>
<p><?php
printf(__('You\'ve set it to: %s', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>');
?>
</p>
<?php
}
?>
<p><?php
printf(__('The path to the folder you would like to store your backup files in, defaults to %s.', 'backupwordpress'), '<code>' . esc_html(Path::get_path()) . '</code>');
?>
<?php
_e('e.g.', 'backupwordpress');
?>
<code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p>
</td>
</tr>
<tr<?php
if (defined('HMBKP_MYSQLDUMP_PATH')) {
?>
class="hmbkp_active"<?php
}
示例11: get_status_filepath
/**
* Get the path to the backup running file that stores the running backup status
*
* @return string
*/
public function get_status_filepath()
{
return Path::get_path() . '/.backup-' . $this->id . '-running';
}
示例12: cleanup
/**
* Clean any temporary / incomplete backups from the backups directory
*/
public function cleanup()
{
// Don't cleanup a custom path, who knows what other stuff is there
if (Path::get_path() === $this->get_custom_path()) {
return;
}
foreach (new CleanUpIterator(new \DirectoryIterator($this->path)) as $file) {
if ($file->isDot() || !$file->isReadable() || !$file->isFile()) {
continue;
}
@unlink($file->getPathname());
}
}
示例13: request_cancel_backup
/**
* Cancels a running backup then redirect back to the backups page
*/
function request_cancel_backup()
{
check_admin_referer('hmbkp_request_cancel_backup', 'hmbkp-request_cancel_backup_nonce');
$schedule = new Scheduled_Backup(sanitize_text_field(urldecode($_GET['hmbkp_schedule_id'])));
$status = $schedule->get_status();
// Delete the running backup
if ($status->get_backup_filename() && file_exists(trailingslashit(Path::get_path()) . $status->get_backup_filename())) {
unlink(trailingslashit(Path::get_path()) . $status->get_backup_filename());
}
if (file_exists($status->get_status_filepath())) {
unlink($status->get_status_filepath());
}
Path::get_instance()->cleanup();
wp_safe_redirect(get_settings_url(), 303);
die;
}
示例14:
<?php
if (isset(Path::get_path()['call_parts'][1])) {
$catId = Path::get_path()['call_parts'][1];
$cat = Category::read("SELECT * FROM categories WHERE id = ?", PDO::FETCH_CLASS, 'Category', [$catId]);
if ($cat) {
echo '<h2>' . $cat->name . '</h2>';
echo '<p>' . $cat->content . '</p>';
}
}
示例15: isset
<?php
$activate_code = isset(Path::get_path()['call_parts'][1]) ? Path::get_path()['call_parts'][1] : null;
if ($activate_code) {
$user = User::read("SELECT * FROM users WHERE activation = ?", PDO::FETCH_CLASS, 'User', [$activate_code]);
if ($user) {
$user->activation = '';
$user->status = 1;
$user->save();
echo '<p class="success">Your account has been activated</p>';
} else {
echo '<p class="error">This activation link doesn\'t exist</p>';
}
} else {
header('Location: ' . HOST_NAME);
}