-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d4651f
commit 22e2f5c
Showing
3 changed files
with
109 additions
and
7 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
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 | ||
if( function_exists('acf_add_local_field_group') ): | ||
|
||
acf_add_local_field_group(array( | ||
'key' => 'group_5a733fff991cf', | ||
'title' => 'Options', | ||
'fields' => array( | ||
array( | ||
'key' => 'field_5a734005957ef', | ||
'label' => 'Clean Admin UI', | ||
'name' => 'clean_admin_ui', | ||
'type' => 'user', | ||
'instructions' => '', | ||
'required' => 0, | ||
'conditional_logic' => 0, | ||
'wrapper' => array( | ||
'width' => '', | ||
'class' => '', | ||
'id' => '', | ||
), | ||
'role' => '', | ||
'allow_null' => 0, | ||
'multiple' => 1, | ||
), | ||
), | ||
'location' => array( | ||
array( | ||
array( | ||
'param' => 'options_page', | ||
'operator' => '==', | ||
'value' => 'origin', | ||
), | ||
), | ||
), | ||
'menu_order' => 0, | ||
'position' => 'normal', | ||
'style' => 'default', | ||
'label_placement' => 'top', | ||
'instruction_placement' => 'label', | ||
'hide_on_screen' => '', | ||
'active' => 1, | ||
'description' => '', | ||
'origin_acf_options_clean_taxonomy' => 0, | ||
)); | ||
|
||
endif; | ||
?> |
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,54 @@ | ||
<?php | ||
|
||
if( ! class_exists('origin_acf_options') ) : | ||
|
||
class origin_acf_options { | ||
|
||
function __construct() { | ||
require_once 'origin-acf-options-fields.php'; | ||
acf_add_options_page([ 'page_title' => 'Origin', 'post_id' => 'origin', 'menu_slug' => 'origin']); | ||
$this->check_clean_admin_ui(); | ||
} | ||
|
||
function check_clean_admin_ui() { | ||
$users = get_field('clean_admin_ui', 'origin'); | ||
$current_user = wp_get_current_user(); | ||
|
||
$clean = false; | ||
|
||
foreach($users as $user): | ||
if($user['ID'] == $current_user->ID) | ||
$clean = true; | ||
endforeach; | ||
|
||
if($clean): | ||
add_action('admin_menu', [$this, 'clean_admin_ui'], 9999); | ||
add_filter('acf/settings/show_admin', '__return_false'); | ||
endif; | ||
} | ||
|
||
function clean_admin_ui() { | ||
$menus = [ | ||
'themes.php', | ||
'options-general.php', | ||
'tools.php', | ||
'users.php', | ||
'plugins.php', | ||
'edit-comments.php', | ||
'edit.php?post_type=page', | ||
'edit.php', | ||
'admin.php?page=origin', | ||
]; | ||
foreach($menus as $menu) { remove_menu_page($menu); } | ||
?> | ||
<style>.wp-menu-separator{display: none} .toplevel_page_origin{display: none}</style> | ||
<?php | ||
} | ||
|
||
} | ||
|
||
new origin_acf_options(); | ||
|
||
endif; | ||
|
||
?> |