first commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\AtomicWidgets\Database;
|
||||
|
||||
use Elementor\Core\Database\Base_Database_Updater;
|
||||
use Elementor\Modules\AtomicWidgets\Database\Migrations\Add_Capabilities;
|
||||
|
||||
class Atomic_Widgets_Database_Updater extends Base_Database_Updater {
|
||||
const DB_VERSION = 1;
|
||||
const OPTION_NAME = 'elementor_atomic_widgets_db_version';
|
||||
|
||||
protected function get_migrations(): array {
|
||||
return [
|
||||
1 => new Add_Capabilities(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function get_db_version() {
|
||||
return static::DB_VERSION;
|
||||
}
|
||||
|
||||
protected function get_db_version_option_name(): string {
|
||||
return static::OPTION_NAME;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Elementor\Modules\AtomicWidgets\Database\Migrations;
|
||||
|
||||
use Elementor\Core\Database\Base_Migration;
|
||||
|
||||
class Add_Capabilities extends Base_Migration {
|
||||
const ACCESS_STYLES_TAB = 'elementor_atomic_widgets_access_styles_tab';
|
||||
const EDIT_LOCAL_CSS_CLASS = 'elementor_atomic_widgets_edit_local_css_class';
|
||||
|
||||
public function up() {
|
||||
$capabilities = [
|
||||
self::ACCESS_STYLES_TAB => [ 'administrator', 'editor', 'author', 'contributor', 'shop_manager' ],
|
||||
self::EDIT_LOCAL_CSS_CLASS => [ 'administrator', 'editor', 'author', 'contributor', 'shop_manager' ],
|
||||
];
|
||||
|
||||
foreach ( $capabilities as $cap => $roles ) {
|
||||
foreach ( $roles as $role_name ) {
|
||||
$role = get_role( $role_name );
|
||||
|
||||
if ( $role ) {
|
||||
$role->add_cap( $cap );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user