Skip to content

Commit

Permalink
Bump permissions requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
oakesjosh committed Nov 19, 2024
1 parent e97b2d4 commit e1550f6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions includes/class-kadence-blocks-cpt-import-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function handle_bulk_export($redirect_to, $action, $post_ids)
return $redirect_to;
}

if (!current_user_can('edit_posts')) {
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to export content.', 'kadence-blocks'));
}

Expand Down Expand Up @@ -201,7 +201,7 @@ public function display_import_notices() {
public function add_import_export_buttons() {
global $pagenow, $typenow;

if ('edit.php' === $pagenow && $this->slug === $typenow && current_user_can('edit_posts') ) {
if ('edit.php' === $pagenow && $this->slug === $typenow && current_user_can('manage_options') ) {
add_action('admin_notices', array($this, 'render_import_export_buttons'));
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ public function render_import_export_buttons() {
* Export to zip and download.
*/
public function handle_export( $post_ids = array(), $check_referrer = true ) {
if (!current_user_can('edit_posts')) {
if (!current_user_can('manage_options')) {
$this->redirect_with_error( __('You do not have sufficient permissions to export content.', 'kadence-blocks') );
}

Expand Down Expand Up @@ -339,7 +339,7 @@ private function get_related_posts_recursive($content, &$related_posts, $parent_
}

public function handle_import() {
if (!current_user_can('publish_posts')) {
if (!current_user_can('manage_options')) {
$this->redirect_with_error( __('You do not have sufficient permissions to import content.', 'kadence-blocks' ) );
return;
}
Expand Down Expand Up @@ -367,6 +367,11 @@ public function handle_import() {

$zip = new ZipArchive();
if ($zip->open($file['tmp_name']) === TRUE) {
if ($zip->numFiles > 5) {
$this->redirect_with_error( __('Invalid data in import file.', 'kadence-blocks' ) );
return;
}

$zip->extractTo($temp_dir);
$zip->close();

Expand Down

0 comments on commit e1550f6

Please sign in to comment.