-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge develop to master before releasing v2.1.7
- Loading branch information
Showing
6 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace WeDevs\WeDocs; | ||
|
||
/** | ||
* Post type class | ||
*/ | ||
class Capability { | ||
/** | ||
* Initialize the class | ||
*/ | ||
public function __construct() { | ||
add_filter( 'user_has_cap', [ $this, 'grant_delete_capability_to_specific_roles' ], 10, 4 ); | ||
} | ||
|
||
/** | ||
* Grant doc delete capabilities to Admin, Editor and | ||
* weDocs-pro global permission given roles. | ||
* | ||
* @param array $all_caps An array of all the user's capabilities. | ||
* @param array $caps Actual capabilities for meta capability. | ||
* @param array $args Optional parameters passed to has_cap(), typically object ID. | ||
* @param WP_User $user | ||
* | ||
* @return array | ||
*/ | ||
public function grant_delete_capability_to_specific_roles( $all_caps, $caps, $args, $user ) { | ||
$permitted_roles = array( 'administrator', 'editor' ); | ||
$delete_caps = array( | ||
'delete_published_docs' => true, | ||
'delete_others_docs' => true, | ||
'delete_private_docs' => true, | ||
); | ||
|
||
if ( wedocs_pro_exists() ) { | ||
$permitted_roles = wedocs_get_permission_settings( 'global_permission', [ 'administrator', 'editor' ] ); | ||
} | ||
|
||
$has_role = array_intersect( $user->roles, $permitted_roles ); | ||
|
||
if ( ! empty( $user->roles ) && ! empty( $has_role ) ) { | ||
$all_caps = array_merge( $all_caps, $delete_caps ); | ||
} | ||
|
||
return $all_caps; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# This file is distributed under the GPL2. | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: weDocs 2.1.6\n" | ||
"Project-Id-Version: weDocs 2.1.7\n" | ||
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wedocs-plugin\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters