Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions admin/class-h5p-plugin-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ public function display_settings_page() {
$enable_lrs_content_types = filter_input(INPUT_POST, 'enable_lrs_content_types', FILTER_VALIDATE_BOOLEAN);
update_option('h5p_enable_lrs_content_types', $enable_lrs_content_types);

$use_system_temp_dir = filter_input(INPUT_POST, 'use_system_temp_dir', FILTER_VALIDATE_BOOLEAN);
update_option('h5p_use_system_temp_dir', $use_system_temp_dir);

// TODO: Make it possible to change site key
// $site_key = filter_input(INPUT_POST, 'site_key', FILTER_SANITIZE_SPECIAL_CHARS);
// if (preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', $site_key)) {
Expand Down Expand Up @@ -497,6 +500,7 @@ public function display_settings_page() {
$about = get_option('h5p_icon', TRUE);
$track_user = get_option('h5p_track_user', TRUE);
$save_content_state = get_option('h5p_save_content_state', FALSE);
$use_system_temp_dir = get_option('h5p_use_system_temp_dir', FALSE);
$save_content_frequency = get_option('h5p_save_content_frequency', 30);
$show_toggle_view_others_h5p_contents = get_option('h5p_show_toggle_view_others_h5p_contents', 0);
$insert_method = get_option('h5p_insert_method', 'id');
Expand Down
10 changes: 10 additions & 0 deletions admin/views/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ class="h5p-settings-disable-hub-checkbox"
</p>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e("Temporary Working Directory", $this->plugin_slug); ?></th>
<td>
<label>
<input name="use_system_temp_dir" type="checkbox" value="true"<?php if ($use_system_temp_dir): ?> checked="checked"<?php endif; ?>/>
<?php _e("Use the system defined temporary space instead of in the plugin directory", $this->plugin_slug); ?>
</label>
</td>
</tr>
</tr>
<!-- <tr valign="top">-->
<!-- <th scope="row">--><?php //_e("Site Key", $this->plugin_slug); ?><!--</th>-->
<!-- <td>-->
Expand Down
1 change: 1 addition & 0 deletions public/class-h5p-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ public static function update_database() {
add_option('h5p_icon', TRUE);
add_option('h5p_track_user', TRUE);
add_option('h5p_save_content_state', FALSE);
add_option('h5p_use_system_temp_dir', FALSE);
add_option('h5p_save_content_frequency', 30);
add_option('h5p_site_key', get_option('h5p_h5p_site_uuid', FALSE));
add_option('h5p_show_toggle_view_others_h5p_contents', 0);
Expand Down
21 changes: 14 additions & 7 deletions public/class-h5p-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ public function getUploadedH5pFolderPath() {
static $dir;

if (is_null($dir)) {
$plugin = H5P_Plugin::get_instance();
$core = $plugin->get_h5p_instance('core');
$dir = $core->fs->getTmpPath();
if (get_option('h5p_use_system_temp_dir', FALSE)) {
$dir = sys_get_temp_dir() . "/" . uniqid('h5p-');
} else {
$plugin = H5P_Plugin::get_instance();
$core = $plugin->get_h5p_instance('core');
$dir = $core->fs->getTmpPath();
}
}

return $dir;
Expand All @@ -107,11 +111,14 @@ public function getUploadedH5pPath() {
static $path;

if (is_null($path)) {
$plugin = H5P_Plugin::get_instance();
$core = $plugin->get_h5p_instance('core');
$path = $core->fs->getTmpPath() . '.h5p';
if (get_option('h5p_use_system_temp_dir', FALSE)) {
$path = sys_get_temp_dir() . '/' . uniqid('h5p-') . '.h5p';
} else {
$plugin = H5P_Plugin::get_instance();
$core = $plugin->get_h5p_instance('core');
$path = $core->fs->getTmpPath() . '.h5p';
}
}

return $path;
}

Expand Down