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
5 changes: 5 additions & 0 deletions admin/class-h5p-plugin-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,10 @@ public function display_settings_page() {

$send_usage_statistics = filter_input(INPUT_POST, 'send_usage_statistics', FILTER_VALIDATE_BOOLEAN);
update_option('h5p_send_usage_statistics', $send_usage_statistics);

$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);

}
else {
$frame = get_option('h5p_frame', TRUE);
Expand All @@ -511,6 +515,7 @@ public function display_settings_page() {
$enable_hub = get_option('h5p_hub_is_enabled', TRUE);
// $site_key = get_option('h5p_site_key', get_option('h5p_h5p_site_uuid', FALSE));
$send_usage_statistics = get_option('h5p_send_usage_statistics', TRUE);
$use_system_temp_dir = get_option('h5p_use_system_temp_dir', FALSE);
}

// Attach disable hub configuration
Expand Down
12 changes: 12 additions & 0 deletions admin/views/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ class="h5p-settings-disable-hub-checkbox"
</p>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e("Temporary Storage Location", $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 system temporary folder", $this->plugin_slug); ?>
</label>
<p class="h5p-setting-desc">
<?php _e("When enabled, H5P will store temporary files (such as uploads during editing) in your server's system temporary folder instead of the plugin directory. This can improve performance on servers with limited resources.", $this->plugin_slug); ?>
</p>
</td>
</tr>
</tbody>
</table>
<?php wp_nonce_field('h5p_settings', 'save_these_settings'); ?>
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 @@ -396,6 +396,7 @@ public static function update_database() {
add_option('h5p_hub_is_enabled', FALSE);
add_option('h5p_send_usage_statistics', FALSE);
add_option('h5p_has_request_user_consent', FALSE);
add_option('h5p_use_system_temp_dir', FALSE);
}

/**
Expand Down
20 changes: 14 additions & 6 deletions public/class-h5p-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,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();
} else {
$plugin = H5P_Plugin::get_instance();
$core = $plugin->get_h5p_instance('core');
$dir = $core->fs->getTmpPath();
}
}

return $dir;
Expand All @@ -115,9 +119,13 @@ 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() . '.h5p';
} else {
$plugin = H5P_Plugin::get_instance();
$core = $plugin->get_h5p_instance('core');
$path = $core->fs->getTmpPath() . '.h5p';
}
}

return $path;
Expand Down