File Manager

Current Path : /webspace/www.beetasty.be/html/wp-content/themes/Divi/core/code-snippets/app/lib/
Upload File :
Current File : //webspace/www.beetasty.be/html/wp-content/themes/Divi/core/code-snippets/app/lib/capabilities.js

// External dependencies.
import {
  every,
  get,
  isArray,
  isEmpty,
} from 'lodash';

// Internal dependencies.
import config from './config';


const isAllowedActionPure = (capabilities, action, restrictByDefault = false) => {
  if (isEmpty(action)) {
    return true;
  }

  const defaultValue = restrictByDefault ? 'off' : 'on';

  if (isArray(action)) {
    return every(action, action => 'on' === get(capabilities, action, defaultValue));
  }

  return 'on' === get(capabilities, action, defaultValue);
};

export const isAllowedAction = (...args) => isAllowedActionPure(config.capabilities, ...args);

File Manager Version 1.0, Coded By Lucas
Email: hehe@yahoo.com