Skip to content

Commit

Permalink
cleanup backend for user
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanedemotte committed Feb 1, 2018
1 parent 6d4651f commit 22e2f5c
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 7 deletions.
15 changes: 8 additions & 7 deletions acf-origin.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/*
Plugin Name: ACF Origin
Plugin Name: Origin
Plugin URI: PLUGIN_URL
Description: Origin ACF
Description: Origin
Version: 1.0.0
Author: Stephane Demotte
Author URI: NULL
Expand All @@ -13,9 +13,9 @@

if( ! defined( 'ABSPATH' ) ) exit;

if( !class_exists('origin_acf_plugin') ) :
if( !class_exists('origin_plugin') ) :

class origin_acf_plugin {
class origin_plugin {
var $settings;

function __construct() {
Expand All @@ -26,20 +26,21 @@ function __construct() {
);

add_action('acf/init', [$this, 'acf_init']);
add_action('acf/include_field_types', [$this, 'include_field_types']);
add_action('acf/include_field_types', [$this, 'acf_include_field_types']);
}

function acf_init() {
include_once('options/origin-acf-options.php');
include_once('options/origin-acf-taxonomy.php');
}

function include_field_types( $version = false ) {
function acf_include_field_types( $version = false ) {
include_once('fields/origin-acf-field-unique.php');
include_once('fields/origin-acf-field-slug.php');
}
}

new origin_acf_plugin();
new origin_plugin();
endif;

?>
47 changes: 47 additions & 0 deletions options/origin-acf-options-fields.php
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;
?>
54 changes: 54 additions & 0 deletions options/origin-acf-options.php
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;

?>

0 comments on commit 22e2f5c

Please sign in to comment.