Changeset 2568522
- Timestamp:
- 07/20/2021 08:00:16 PM (5 years ago)
- Location:
- content-visibility-user-role
- Files:
-
- 10 edited
- 1 copied
-
tags/0.1.3 (copied) (copied from content-visibility-user-role/trunk)
-
tags/0.1.3/build/index.asset.php (modified) (1 diff)
-
tags/0.1.3/build/index.js (modified) (3 diffs)
-
tags/0.1.3/build/index.js.map (modified) (1 diff)
-
tags/0.1.3/content-visibility-user-role.php (modified) (1 diff)
-
tags/0.1.3/readme.txt (modified) (2 diffs)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (3 diffs)
-
trunk/build/index.js.map (modified) (1 diff)
-
trunk/content-visibility-user-role.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
content-visibility-user-role/tags/0.1.3/build/index.asset.php
r2482514 r2568522 1 <?php return array('dependencies' => array('wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => ' da884aee0f44795cd9ea17d8eb90ece2');1 <?php return array('dependencies' => array('wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => 'b5de980f7d4611856321d65d747faa6b'); -
content-visibility-user-role/tags/0.1.3/build/index.js
r2482514 r2568522 266 266 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); 267 267 /* harmony import */ var _content_visibility_role_checkbox__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./content-visibility-role-checkbox */ "./src/controls/content-visibility-role-checkbox.js"); 268 /* harmony import */ var _helpers_has_rules__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../helpers/has-rules */ "./src/helpers/has-rules.js"); 269 268 270 269 271 … … 280 282 281 283 var id = "bv-roles-".concat(instanceId); 284 var hasRulesClass = Object(_helpers_has_rules__WEBPACK_IMPORTED_MODULE_5__["default"])(props, 'userRole') ? ' has-active-rules' : ''; 282 285 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["PanelBody"], { 283 286 title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('User Role', 'content-visibility-user-role'), 284 287 initialOpen: false, 285 className: "content-visibility-control-panel content-visibility-user-role-controls" 288 className: "content-visibility-control-panel content-visibility-user-role-controls" + hasRulesClass 286 289 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["PanelRow"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])("ul", null, userRoles.map(function (role) { 287 290 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_content_visibility_role_checkbox__WEBPACK_IMPORTED_MODULE_4__["CheckboxGroupCheckbox"], { … … 395 398 /***/ }), 396 399 400 /***/ "./src/helpers/has-rules.js": 401 /*!**********************************!*\ 402 !*** ./src/helpers/has-rules.js ***! 403 \**********************************/ 404 /*! exports provided: default */ 405 /***/ (function(module, __webpack_exports__, __webpack_require__) { 406 407 "use strict"; 408 __webpack_require__.r(__webpack_exports__); 409 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 410 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__); 411 412 /** 413 * Determine if the passed block props contain rules of the passed type. 414 * 415 * @param {object} props The currently selected block's props. 416 * @param {string} type The type of the rules i.e. userAuthenticated or specialPage (or ones from add-ons). 417 * 418 * @return {bool} true if the passed props contain non-empty rules of the passed type. False otherwise. 419 */ 420 421 function hasRules(props, type) { 422 if (!props.attributes.contentVisibilityRules) { 423 return false; 424 } 425 426 if (!props.attributes.contentVisibilityRules[type]) { 427 return false; 428 } // Default to false. Passed through a filter later. 429 430 431 var hasRules = false; 432 433 switch (type) { 434 case 'userRole': 435 if (props.attributes.contentVisibilityRules[type] && Object.keys(props.attributes.contentVisibilityRules[type]).length !== 0) { 436 hasRules = true; 437 } 438 439 break; 440 441 default: 442 break; 443 } 444 445 return Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__["applyFilters"])('content-visibility-has-rules', hasRules, props, type); 446 } // end hasRules() 447 448 449 /* harmony default export */ __webpack_exports__["default"] = (hasRules); 450 451 /***/ }), 452 397 453 /***/ "./src/index.js": 398 454 /*!**********************!*\ -
content-visibility-user-role/tags/0.1.3/build/index.js.map
r2482514 r2568522 1 {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/controls/content-visibility-role-checkbox.js","webpack:///./src/controls/content-visibility-user-role-panel-body.js","webpack:///./src/controls/content-visibility-user-role.js","webpack:///./src/editor.scss","webpack:///./src/ index.js","webpack:///external {\"this\":[\"wp\",\"components\"]}","webpack:///external {\"this\":[\"wp\",\"compose\"]}","webpack:///external {\"this\":[\"wp\",\"element\"]}","webpack:///external {\"this\":[\"wp\",\"hooks\"]}","webpack:///external {\"this\":[\"wp\",\"i18n\"]}","webpack:///external {\"this\":[\"wp\",\"plugins\"]}"],"names":["CheckboxGroupCheckbox","data","props","role","roleSlug","value","persistedData","attributes","contentVisibilityRules","thisChecked","hasOwnProperty","userRole","label","isChecked","setAttributes","ContentVisibilityUserRolePanelBodyControl","instanceId","userRoles","BlockVisibilityUserRole","roles","id","__","map","clientId","contentVisibility","withInstanceId","ContentVisibilityUserRoleControl","rulesEnabled","contentVisibilityRulesEnabled","ContentVisibilityUserRoleFill","fillProps","registerPlugin","render","addFilter","registerContentVisibilityRule","defaultRules"],"mappings":";;;;;;;;;;;;;;;;QAAA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;QACA,QAAQ,oBAAoB;QAC5B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA,iBAAiB,4BAA4B;QAC7C;QACA;QACA,kBAAkB,2BAA2B;QAC7C;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;;QAEA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;QAEA;QACA;QACA;QACA;QACA,gBAAgB,uBAAuB;QACvC;;;QAGA;QACA;QACA;QACA;;;;;;;;;;;;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA;;AAEA,iC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfA;AAEO,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAAEC,IAAF,EAAY;AAAA,gCAClBA,IADkB;AAAA,MACvCC,KADuC,SACvCA,KADuC;AAAA,MAChCC,IADgC,SAChCA,IADgC,EAG7C;;;AACA,MAAIC,QAAQ,GAAGD,IAAI,CAACE,KAApB,CAJ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ADJ;AAYH,C,CAED;;;AACAC,yEAAc,CAAE,sCAAF,EAA0C;AAAEC,QAAM,EAAEH;AAAV,CAA1C,CAAd,C,CAGA;;AACAI,kEAAS,CAAE,iDAAF,EAAqD,qDAArD,EAA4GC,6BAA5G,CAAT;;AAEA,SAASA,6BAAT,CAAwCC,YAAxC,EAAuD;AAEnDA,cAAY,CAACxB,QAAb,GAAwB,EAAxB;AAEA,SAAOwB,YAAP;AAEH,C;;;;;;;;;;;AC5DD,uC;;;;;;;;;;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;;;;;;;;;;;;ACDA,aAAa,2CAA2C,EAAE,I;;;;;;;;;;;ACA1D,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,sCAAsC,EAAE,I;;;;;;;;;;;ACArD,aAAa,qCAAqC,EAAE,I;;;;;;;;;;;ACApD,aAAa,wCAAwC,EAAE,I","file":"index.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t\"index\": 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// add entry module to deferred list\n \tdeferredModules.push([\"./src/index.js\",\"style-index\"]);\n \t// run deferred modules when ready\n \treturn checkDeferredModules();\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;","import { CheckboxControl } from '@wordpress/components';\n\nexport const CheckboxGroupCheckbox = ( data ) => {\n let { props, role } = { ...data };\n\n // Which role is this for?\n let roleSlug = role.value;\n\n // What data has been persisted in the db?\n let persistedData = props.attributes.contentVisibilityRules;\n\n // If we have persisted data for this role, and it is set to \"1\" then the checkbox should be checked\n // otherwise we fall back to whatever isChecked is which will change when someone alters the value of the checkbox\n let thisChecked = persistedData.hasOwnProperty( 'userRole' ) && persistedData.userRole.hasOwnProperty( roleSlug ) && '1' === props.attributes.contentVisibilityRules.userRole[ roleSlug ];\n\n return (\n <CheckboxControl\n label={ role.label }\n checked={ thisChecked }\n onChange={ ( isChecked ) => {\n props.setAttributes( {\n contentVisibilityRules: {\n ...props.attributes.contentVisibilityRules,\n userRole: {\n ...props.attributes.contentVisibilityRules.userRole,\n [roleSlug]: isChecked ? '1' : '0'\n }\n },\n } );\n }}\n />\n );\n\n};","import { PanelBody, PanelRow } from '@wordpress/components';\nimport { withInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\nimport { CheckboxGroupCheckbox } from './content-visibility-role-checkbox';\n\nfunction ContentVisibilityUserRolePanelBodyControl( { instanceId, props } ) {\n\n // Fetch the roles from PHP\n const userRoles = BlockVisibilityUserRole.roles;\n\n // userRoles is an array of objects, for each registered user role.\n // Each role object looks like: {label: \"Administrator\", value: \"administrator\"}\n\n const id = `bv-roles-${ instanceId }`;\n\n return (\n <PanelBody\n title={ __( 'User Role', 'content-visibility-user-role' ) }\n initialOpen={ false }\n className=\"content-visibility-control-panel content-visibility-user-role-controls\"\n >\n <PanelRow>\n <ul>\n {\n userRoles.map( role => (\n <CheckboxGroupCheckbox name={ id } id={ id } props={ props } role={ role } key={ props.clientId + role.value } />\n ) )\n }\n </ul>\n </PanelRow>\n\n { props.attributes.contentVisibility && (\n <p className=\"user-role-help-intro content-visibility-help-text\">{ __( 'Select one more more roles to whom this block will be ' + props.attributes.contentVisibility + '. If no roles are selected, this block will be ' + props.attributes.contentVisibility + ' regardless of a user\\'s role.', 'content-visibility-user-role' ) }</p>\n ) }\n </PanelBody>\n );\n\n}\n\nexport default withInstanceId( ContentVisibilityUserRolePanelBodyControl );","import { Fill, Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\nimport ContentVisibilityUserRolePanelBodyControl from './content-visibility-user-role-panel-body';\n\nexport function ContentVisibilityUserRoleControl( data ) {\n\n let { props } = { ...data };\n\n let rulesEnabled = props.attributes.contentVisibilityRules.contentVisibilityRulesEnabled;\n let contentVisibility = props.attributes.hasOwnProperty( 'contentVisibility' );\n\n if ( ! rulesEnabled || ! contentVisibility ) {\n return (\n <Disabled><ContentVisibilityUserRolePanelBodyControl props={ props } /></Disabled>\n );\n }\n\n return (\n <ContentVisibilityUserRolePanelBodyControl props={ props } />\n );\n\n}\n\n/**\n * Render the <ContentVisibilityUserRoleControl> component by adding\n * it to the block-visibility-extra-controls Fill.\n *\n * @return {Object} A Fill component wrapping the ContentVisibilityUserRoleControl component.\n */\nfunction ContentVisibilityUserRoleFill() {\n return (\n <Fill name=\"content-visibility-extra-controls\">\n {\n ( fillProps ) => {\n return (\n <ContentVisibilityUserRoleControl props={ fillProps } />\n )\n }\n }\n </Fill>\n );\n\n}\n\n// Add our component to the Slot provided by BlockVisibilityControls\nregisterPlugin( 'content-visibility-02-user-role-fill', { render: ContentVisibilityUserRoleFill } );\n\n\n// Register our visibility rule with the main plugin\naddFilter( 'contentVisibility.defaultContentVisibilityRules', 'content-visibility-user-role/block-visibility-rules', registerContentVisibilityRule );\n\nfunction registerContentVisibilityRule( defaultRules ) {\n\n defaultRules.userRole = {};\n\n return defaultRules;\n\n}\n","// extracted by mini-css-extract-plugin","import './editor.scss';\nimport './style.scss';\n\nimport ContentVisibilityUserRoleControl from './controls/content-visibility-user-role';","(function() { module.exports = this[\"wp\"][\"components\"]; }());","(function() { module.exports = this[\"wp\"][\"compose\"]; }());","(function() { module.exports = this[\"wp\"][\"element\"]; }());","(function() { module.exports = this[\"wp\"][\"hooks\"]; }());","(function() { module.exports = this[\"wp\"][\"i18n\"]; }());","(function() { module.exports = this[\"wp\"][\"plugins\"]; }());"],"sourceRoot":""}1 {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/controls/content-visibility-role-checkbox.js","webpack:///./src/controls/content-visibility-user-role-panel-body.js","webpack:///./src/controls/content-visibility-user-role.js","webpack:///./src/editor.scss","webpack:///./src/helpers/has-rules.js","webpack:///./src/index.js","webpack:///external {\"this\":[\"wp\",\"components\"]}","webpack:///external {\"this\":[\"wp\",\"compose\"]}","webpack:///external {\"this\":[\"wp\",\"element\"]}","webpack:///external {\"this\":[\"wp\",\"hooks\"]}","webpack:///external {\"this\":[\"wp\",\"i18n\"]}","webpack:///external {\"this\":[\"wp\",\"plugins\"]}"],"names":["CheckboxGroupCheckbox","data","props","role","roleSlug","value","persistedData","attributes","contentVisibilityRules","thisChecked","hasOwnProperty","userRole","label","isChecked","setAttributes","ContentVisibilityUserRolePanelBodyControl","instanceId","userRoles","BlockVisibilityUserRole","roles","id","hasRulesClass","hasRules","__","map","clientId","contentVisibility","withInstanceId","ContentVisibilityUserRoleControl","rulesEnabled","contentVisibilityRulesEnabled","ContentVisibilityUserRoleFill","fillProps","registerPlugin","render","addFilter","registerContentVisibilityRule","defaultRules","type","Object","keys","length","applyFilters"],"mappings":";;;;;;;;;;;;;;;;QAAA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;QACA,QAAQ,oBAAoB;QAC5B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA,iBAAiB,4BAA4B;QAC7C;QACA;QACA,kBAAkB,2BAA2B;QAC7C;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;;QAEA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;QAEA;QACA;QACA;QACA;QACA,gBAAgB,uBAAuB;QACvC;;;QAGA;QACA;QACA;QACA;;;;;;;;;;;;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA;;AAEA,iC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfA;AAEO,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAAEC,IAAF,EAAY;AAAA,gCAClBA,IADkB;AAAA,MACvCC,KADuC,SACvCA,KADuC;AAAA,MAChCC,IADgC,SAChCA,IADgC,EAG7C;;;AACA,MAAIC,QAAQ,GAAGD,IAAI,CAACE,KAApB,CAJ6C,CAM7C;;AACA,MAAIC,aAAa,GAAGJ,KAAK,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ACA;;;;;;;;;;;;ACDA,aAAa,2CAA2C,EAAE,I;;;;;;;;;;;ACA1D,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,sCAAsC,EAAE,I;;;;;;;;;;;ACArD,aAAa,qCAAqC,EAAE,I;;;;;;;;;;;ACApD,aAAa,wCAAwC,EAAE,I","file":"index.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t\"index\": 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// add entry module to deferred list\n \tdeferredModules.push([\"./src/index.js\",\"style-index\"]);\n \t// run deferred modules when ready\n \treturn checkDeferredModules();\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;","import { CheckboxControl } from '@wordpress/components';\n\nexport const CheckboxGroupCheckbox = ( data ) => {\n let { props, role } = { ...data };\n\n // Which role is this for?\n let roleSlug = role.value;\n\n // What data has been persisted in the db?\n let persistedData = props.attributes.contentVisibilityRules;\n\n // If we have persisted data for this role, and it is set to \"1\" then the checkbox should be checked\n // otherwise we fall back to whatever isChecked is which will change when someone alters the value of the checkbox\n let thisChecked = persistedData.hasOwnProperty( 'userRole' ) && persistedData.userRole.hasOwnProperty( roleSlug ) && '1' === props.attributes.contentVisibilityRules.userRole[ roleSlug ];\n\n return (\n <CheckboxControl\n label={ role.label }\n checked={ thisChecked }\n onChange={ ( isChecked ) => {\n props.setAttributes( {\n contentVisibilityRules: {\n ...props.attributes.contentVisibilityRules,\n userRole: {\n ...props.attributes.contentVisibilityRules.userRole,\n [roleSlug]: isChecked ? '1' : '0'\n }\n },\n } );\n }}\n />\n );\n\n};","import { PanelBody, PanelRow } from '@wordpress/components';\nimport { withInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\nimport { CheckboxGroupCheckbox } from './content-visibility-role-checkbox';\nimport hasRules from '../helpers/has-rules';\n\nfunction ContentVisibilityUserRolePanelBodyControl( { instanceId, props } ) {\n\n // Fetch the roles from PHP\n const userRoles = BlockVisibilityUserRole.roles;\n\n // userRoles is an array of objects, for each registered user role.\n // Each role object looks like: {label: \"Administrator\", value: \"administrator\"}\n\n const id = `bv-roles-${ instanceId }`;\n let hasRulesClass = ( hasRules( props, 'userRole' ) ) ? ' has-active-rules' : '';\n\n return (\n <PanelBody\n title={ __( 'User Role', 'content-visibility-user-role' ) }\n initialOpen={ false }\n className={\"content-visibility-control-panel content-visibility-user-role-controls\" + hasRulesClass}\n >\n <PanelRow>\n <ul>\n {\n userRoles.map( role => (\n <CheckboxGroupCheckbox name={ id } id={ id } props={ props } role={ role } key={ props.clientId + role.value } />\n ) )\n }\n </ul>\n </PanelRow>\n\n { props.attributes.contentVisibility && (\n <p className=\"user-role-help-intro content-visibility-help-text\">{ __( 'Select one more more roles to whom this block will be ' + props.attributes.contentVisibility + '. If no roles are selected, this block will be ' + props.attributes.contentVisibility + ' regardless of a user\\'s role.', 'content-visibility-user-role' ) }</p>\n ) }\n </PanelBody>\n );\n\n}\n\nexport default withInstanceId( ContentVisibilityUserRolePanelBodyControl );","import { Fill, Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\nimport ContentVisibilityUserRolePanelBodyControl from './content-visibility-user-role-panel-body';\n\nexport function ContentVisibilityUserRoleControl( data ) {\n\n let { props } = { ...data };\n\n let rulesEnabled = props.attributes.contentVisibilityRules.contentVisibilityRulesEnabled;\n let contentVisibility = props.attributes.hasOwnProperty( 'contentVisibility' );\n\n if ( ! rulesEnabled || ! contentVisibility ) {\n return (\n <Disabled><ContentVisibilityUserRolePanelBodyControl props={ props } /></Disabled>\n );\n }\n\n return (\n <ContentVisibilityUserRolePanelBodyControl props={ props } />\n );\n\n}\n\n/**\n * Render the <ContentVisibilityUserRoleControl> component by adding\n * it to the block-visibility-extra-controls Fill.\n *\n * @return {Object} A Fill component wrapping the ContentVisibilityUserRoleControl component.\n */\nfunction ContentVisibilityUserRoleFill() {\n return (\n <Fill name=\"content-visibility-extra-controls\">\n {\n ( fillProps ) => {\n return (\n <ContentVisibilityUserRoleControl props={ fillProps } />\n )\n }\n }\n </Fill>\n );\n\n}\n\n// Add our component to the Slot provided by BlockVisibilityControls\nregisterPlugin( 'content-visibility-02-user-role-fill', { render: ContentVisibilityUserRoleFill } );\n\n\n// Register our visibility rule with the main plugin\naddFilter( 'contentVisibility.defaultContentVisibilityRules', 'content-visibility-user-role/block-visibility-rules', registerContentVisibilityRule );\n\nfunction registerContentVisibilityRule( defaultRules ) {\n\n defaultRules.userRole = {};\n\n return defaultRules;\n\n}\n","// extracted by mini-css-extract-plugin","import { applyFilters } from '@wordpress/hooks';\n\n/**\n * Determine if the passed block props contain rules of the passed type.\n *\n * @param {object} props The currently selected block's props.\n * @param {string} type The type of the rules i.e. userAuthenticated or specialPage (or ones from add-ons).\n *\n * @return {bool} true if the passed props contain non-empty rules of the passed type. False otherwise.\n */\n function hasRules( props, type ) {\n\n if ( ! props.attributes.contentVisibilityRules ) {\n return false;\n }\n\n if ( ! props.attributes.contentVisibilityRules[type] ) {\n return false;\n }\n\n // Default to false. Passed through a filter later.\n let hasRules = false;\n\n switch ( type ) {\n \n case 'userRole':\n\n if ( props.attributes.contentVisibilityRules[type] && Object.keys( props.attributes.contentVisibilityRules[type] ).length !== 0 ) {\n hasRules = true;\n }\n\n break;\n\n default:\n break;\n }\n\n return applyFilters( 'content-visibility-has-rules', hasRules, props, type );\n\n}// end hasRules()\n\nexport default hasRules;","import './editor.scss';\nimport './style.scss';\n\nimport ContentVisibilityUserRoleControl from './controls/content-visibility-user-role';","(function() { module.exports = this[\"wp\"][\"components\"]; }());","(function() { module.exports = this[\"wp\"][\"compose\"]; }());","(function() { module.exports = this[\"wp\"][\"element\"]; }());","(function() { module.exports = this[\"wp\"][\"hooks\"]; }());","(function() { module.exports = this[\"wp\"][\"i18n\"]; }());","(function() { module.exports = this[\"wp\"][\"plugins\"]; }());"],"sourceRoot":""} -
content-visibility-user-role/tags/0.1.3/content-visibility-user-role.php
r2510975 r2568522 12 12 * Plugin URI: https://richardtape.com/content-visibility/ 13 13 * Description: [Content Visibility Add-On] Determine which user role(s) can see the content blocks of your choosing. 14 * Version: 0.1. 214 * Version: 0.1.3 15 15 * Author: Richard Tape 16 16 * Author URI: https://richardtape.com -
content-visibility-user-role/tags/0.1.3/readme.txt
r2510975 r2568522 4 4 Tags: block, content, visibility, user, users, role, roles, contentvisibility 5 5 Requires at least: 5.0 6 Tested up to: 5. 7.07 Stable tag: 0.1. 26 Tested up to: 5.8.0 7 Stable tag: 0.1.3 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 40 40 == Changelog == 41 41 42 = 0.1.3 = 43 * Added the icon to show when a rule is selected for a block to make it easier to see which rules are active for a block. 44 * WP 5.8.0 compatibility 45 42 46 = 0.1.2 = 43 47 * WP 5.7.0 compatibility. -
content-visibility-user-role/trunk/build/index.asset.php
r2482514 r2568522 1 <?php return array('dependencies' => array('wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => ' da884aee0f44795cd9ea17d8eb90ece2');1 <?php return array('dependencies' => array('wp-components', 'wp-compose', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => 'b5de980f7d4611856321d65d747faa6b'); -
content-visibility-user-role/trunk/build/index.js
r2482514 r2568522 266 266 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); 267 267 /* harmony import */ var _content_visibility_role_checkbox__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./content-visibility-role-checkbox */ "./src/controls/content-visibility-role-checkbox.js"); 268 /* harmony import */ var _helpers_has_rules__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../helpers/has-rules */ "./src/helpers/has-rules.js"); 269 268 270 269 271 … … 280 282 281 283 var id = "bv-roles-".concat(instanceId); 284 var hasRulesClass = Object(_helpers_has_rules__WEBPACK_IMPORTED_MODULE_5__["default"])(props, 'userRole') ? ' has-active-rules' : ''; 282 285 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["PanelBody"], { 283 286 title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('User Role', 'content-visibility-user-role'), 284 287 initialOpen: false, 285 className: "content-visibility-control-panel content-visibility-user-role-controls" 288 className: "content-visibility-control-panel content-visibility-user-role-controls" + hasRulesClass 286 289 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__["PanelRow"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])("ul", null, userRoles.map(function (role) { 287 290 return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_content_visibility_role_checkbox__WEBPACK_IMPORTED_MODULE_4__["CheckboxGroupCheckbox"], { … … 395 398 /***/ }), 396 399 400 /***/ "./src/helpers/has-rules.js": 401 /*!**********************************!*\ 402 !*** ./src/helpers/has-rules.js ***! 403 \**********************************/ 404 /*! exports provided: default */ 405 /***/ (function(module, __webpack_exports__, __webpack_require__) { 406 407 "use strict"; 408 __webpack_require__.r(__webpack_exports__); 409 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 410 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__); 411 412 /** 413 * Determine if the passed block props contain rules of the passed type. 414 * 415 * @param {object} props The currently selected block's props. 416 * @param {string} type The type of the rules i.e. userAuthenticated or specialPage (or ones from add-ons). 417 * 418 * @return {bool} true if the passed props contain non-empty rules of the passed type. False otherwise. 419 */ 420 421 function hasRules(props, type) { 422 if (!props.attributes.contentVisibilityRules) { 423 return false; 424 } 425 426 if (!props.attributes.contentVisibilityRules[type]) { 427 return false; 428 } // Default to false. Passed through a filter later. 429 430 431 var hasRules = false; 432 433 switch (type) { 434 case 'userRole': 435 if (props.attributes.contentVisibilityRules[type] && Object.keys(props.attributes.contentVisibilityRules[type]).length !== 0) { 436 hasRules = true; 437 } 438 439 break; 440 441 default: 442 break; 443 } 444 445 return Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__["applyFilters"])('content-visibility-has-rules', hasRules, props, type); 446 } // end hasRules() 447 448 449 /* harmony default export */ __webpack_exports__["default"] = (hasRules); 450 451 /***/ }), 452 397 453 /***/ "./src/index.js": 398 454 /*!**********************!*\ -
content-visibility-user-role/trunk/build/index.js.map
r2482514 r2568522 1 {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/controls/content-visibility-role-checkbox.js","webpack:///./src/controls/content-visibility-user-role-panel-body.js","webpack:///./src/controls/content-visibility-user-role.js","webpack:///./src/editor.scss","webpack:///./src/ index.js","webpack:///external {\"this\":[\"wp\",\"components\"]}","webpack:///external {\"this\":[\"wp\",\"compose\"]}","webpack:///external {\"this\":[\"wp\",\"element\"]}","webpack:///external {\"this\":[\"wp\",\"hooks\"]}","webpack:///external {\"this\":[\"wp\",\"i18n\"]}","webpack:///external {\"this\":[\"wp\",\"plugins\"]}"],"names":["CheckboxGroupCheckbox","data","props","role","roleSlug","value","persistedData","attributes","contentVisibilityRules","thisChecked","hasOwnProperty","userRole","label","isChecked","setAttributes","ContentVisibilityUserRolePanelBodyControl","instanceId","userRoles","BlockVisibilityUserRole","roles","id","__","map","clientId","contentVisibility","withInstanceId","ContentVisibilityUserRoleControl","rulesEnabled","contentVisibilityRulesEnabled","ContentVisibilityUserRoleFill","fillProps","registerPlugin","render","addFilter","registerContentVisibilityRule","defaultRules"],"mappings":";;;;;;;;;;;;;;;;QAAA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;QACA,QAAQ,oBAAoB;QAC5B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA,iBAAiB,4BAA4B;QAC7C;QACA;QACA,kBAAkB,2BAA2B;QAC7C;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;;QAEA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,k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;;;;;;;;;;;ACArD,aAAa,qCAAqC,EAAE,I;;;;;;;;;;;ACApD,aAAa,wCAAwC,EAAE,I","file":"index.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t\"index\": 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// add entry module to deferred list\n \tdeferredModules.push([\"./src/index.js\",\"style-index\"]);\n \t// run deferred modules when ready\n \treturn checkDeferredModules();\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;","import { CheckboxControl } from '@wordpress/components';\n\nexport const CheckboxGroupCheckbox = ( data ) => {\n let { props, role } = { ...data };\n\n // Which role is this for?\n let roleSlug = role.value;\n\n // What data has been persisted in the db?\n let persistedData = props.attributes.contentVisibilityRules;\n\n // If we have persisted data for this role, and it is set to \"1\" then the checkbox should be checked\n // otherwise we fall back to whatever isChecked is which will change when someone alters the value of the checkbox\n let thisChecked = persistedData.hasOwnProperty( 'userRole' ) && persistedData.userRole.hasOwnProperty( roleSlug ) && '1' === props.attributes.contentVisibilityRules.userRole[ roleSlug ];\n\n return (\n <CheckboxControl\n label={ role.label }\n checked={ thisChecked }\n onChange={ ( isChecked ) => {\n props.setAttributes( {\n contentVisibilityRules: {\n ...props.attributes.contentVisibilityRules,\n userRole: {\n ...props.attributes.contentVisibilityRules.userRole,\n [roleSlug]: isChecked ? '1' : '0'\n }\n },\n } );\n }}\n />\n );\n\n};","import { PanelBody, PanelRow } from '@wordpress/components';\nimport { withInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\nimport { CheckboxGroupCheckbox } from './content-visibility-role-checkbox';\n\nfunction ContentVisibilityUserRolePanelBodyControl( { instanceId, props } ) {\n\n // Fetch the roles from PHP\n const userRoles = BlockVisibilityUserRole.roles;\n\n // userRoles is an array of objects, for each registered user role.\n // Each role object looks like: {label: \"Administrator\", value: \"administrator\"}\n\n const id = `bv-roles-${ instanceId }`;\n\n return (\n <PanelBody\n title={ __( 'User Role', 'content-visibility-user-role' ) }\n initialOpen={ false }\n className=\"content-visibility-control-panel content-visibility-user-role-controls\"\n >\n <PanelRow>\n <ul>\n {\n userRoles.map( role => (\n <CheckboxGroupCheckbox name={ id } id={ id } props={ props } role={ role } key={ props.clientId + role.value } />\n ) )\n }\n </ul>\n </PanelRow>\n\n { props.attributes.contentVisibility && (\n <p className=\"user-role-help-intro content-visibility-help-text\">{ __( 'Select one more more roles to whom this block will be ' + props.attributes.contentVisibility + '. If no roles are selected, this block will be ' + props.attributes.contentVisibility + ' regardless of a user\\'s role.', 'content-visibility-user-role' ) }</p>\n ) }\n </PanelBody>\n );\n\n}\n\nexport default withInstanceId( ContentVisibilityUserRolePanelBodyControl );","import { Fill, Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\nimport ContentVisibilityUserRolePanelBodyControl from './content-visibility-user-role-panel-body';\n\nexport function ContentVisibilityUserRoleControl( data ) {\n\n let { props } = { ...data };\n\n let rulesEnabled = props.attributes.contentVisibilityRules.contentVisibilityRulesEnabled;\n let contentVisibility = props.attributes.hasOwnProperty( 'contentVisibility' );\n\n if ( ! rulesEnabled || ! contentVisibility ) {\n return (\n <Disabled><ContentVisibilityUserRolePanelBodyControl props={ props } /></Disabled>\n );\n }\n\n return (\n <ContentVisibilityUserRolePanelBodyControl props={ props } />\n );\n\n}\n\n/**\n * Render the <ContentVisibilityUserRoleControl> component by adding\n * it to the block-visibility-extra-controls Fill.\n *\n * @return {Object} A Fill component wrapping the ContentVisibilityUserRoleControl component.\n */\nfunction ContentVisibilityUserRoleFill() {\n return (\n <Fill name=\"content-visibility-extra-controls\">\n {\n ( fillProps ) => {\n return (\n <ContentVisibilityUserRoleControl props={ fillProps } />\n )\n }\n }\n </Fill>\n );\n\n}\n\n// Add our component to the Slot provided by BlockVisibilityControls\nregisterPlugin( 'content-visibility-02-user-role-fill', { render: ContentVisibilityUserRoleFill } );\n\n\n// Register our visibility rule with the main plugin\naddFilter( 'contentVisibility.defaultContentVisibilityRules', 'content-visibility-user-role/block-visibility-rules', registerContentVisibilityRule );\n\nfunction registerContentVisibilityRule( defaultRules ) {\n\n defaultRules.userRole = {};\n\n return defaultRules;\n\n}\n","// extracted by mini-css-extract-plugin","import './editor.scss';\nimport './style.scss';\n\nimport ContentVisibilityUserRoleControl from './controls/content-visibility-user-role';","(function() { module.exports = this[\"wp\"][\"components\"]; }());","(function() { module.exports = this[\"wp\"][\"compose\"]; }());","(function() { module.exports = this[\"wp\"][\"element\"]; }());","(function() { module.exports = this[\"wp\"][\"hooks\"]; }());","(function() { module.exports = this[\"wp\"][\"i18n\"]; }());","(function() { module.exports = this[\"wp\"][\"plugins\"]; }());"],"sourceRoot":""}1 {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/controls/content-visibility-role-checkbox.js","webpack:///./src/controls/content-visibility-user-role-panel-body.js","webpack:///./src/controls/content-visibility-user-role.js","webpack:///./src/editor.scss","webpack:///./src/helpers/has-rules.js","webpack:///./src/index.js","webpack:///external {\"this\":[\"wp\",\"components\"]}","webpack:///external {\"this\":[\"wp\",\"compose\"]}","webpack:///external {\"this\":[\"wp\",\"element\"]}","webpack:///external {\"this\":[\"wp\",\"hooks\"]}","webpack:///external {\"this\":[\"wp\",\"i18n\"]}","webpack:///external {\"this\":[\"wp\",\"plugins\"]}"],"names":["CheckboxGroupCheckbox","data","props","role","roleSlug","value","persistedData","attributes","contentVisibilityRules","thisChecked","hasOwnProperty","userRole","label","isChecked","setAttributes","ContentVisibilityUserRolePanelBodyControl","instanceId","userRoles","BlockVisibilityUserRole","roles","id","hasRulesClass","hasRules","__","map","clientId","contentVisibility","withInstanceId","ContentVisibilityUserRoleControl","rulesEnabled","contentVisibilityRulesEnabled","ContentVisibilityUserRoleFill","fillProps","registerPlugin","render","addFilter","registerContentVisibilityRule","defaultRules","type","Object","keys","length","applyFilters"],"mappings":";;;;;;;;;;;;;;;;QAAA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;QACA,QAAQ,oBAAoB;QAC5B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA,iBAAiB,4BAA4B;QAC7C;QACA;QACA,kBAAkB,2BAA2B;QAC7C;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;;QAEA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAE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AAK,CAACK,UAAN,CAAiBC,sBAAxB,EAAiD;AAC7C,WAAO,KAAP;AACH;;AAED,MAAK,CAAEN,KAAK,CAACK,UAAN,CAAiBC,sBAAjB,CAAwC8B,IAAxC,CAAP,EAAuD;AACnD,WAAO,KAAP;AACH,GAR6B,CAU9B;;;AACA,MAAIhB,QAAQ,GAAG,KAAf;;AAEA,UAASgB,IAAT;AAEI,SAAK,UAAL;AAEI,UAAKpC,KAAK,CAACK,UAAN,CAAiBC,sBAAjB,CAAwC8B,IAAxC,KAAiDC,MAAM,CAACC,IAAP,CAAatC,KAAK,CAACK,UAAN,CAAiBC,sBAAjB,CAAwC8B,IAAxC,CAAb,EAA6DG,MAA7D,KAAwE,CAA9H,EAAkI;AAC9HnB,gBAAQ,GAAG,IAAX;AACH;;AAED;;AAEJ;AACI;AAXR;;AAcA,SAAOoB,qEAAY,CAAE,8BAAF,EAAkCpB,QAAlC,EAA4CpB,KAA5C,EAAmDoC,IAAnD,CAAnB;AAEH,C,CAAA;;;AAEchB,uEAAf,E;;;;;;;;;;;;ACzCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;;;;;;;;;;;;ACDA,aAAa,2CAA2C,EAAE,I;;;;;;;;;;;ACA1D,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,sCAAsC,EAAE,I;;;;;;;;;;;ACArD,aAAa,qCAAqC,EAAE,I;;;;;;;;;;;ACApD,aAAa,wCAAwC,EAAE,I","file":"index.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t\"index\": 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// add entry module to deferred list\n \tdeferredModules.push([\"./src/index.js\",\"style-index\"]);\n \t// run deferred modules when ready\n \treturn checkDeferredModules();\n","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;","import { CheckboxControl } from '@wordpress/components';\n\nexport const CheckboxGroupCheckbox = ( data ) => {\n let { props, role } = { ...data };\n\n // Which role is this for?\n let roleSlug = role.value;\n\n // What data has been persisted in the db?\n let persistedData = props.attributes.contentVisibilityRules;\n\n // If we have persisted data for this role, and it is set to \"1\" then the checkbox should be checked\n // otherwise we fall back to whatever isChecked is which will change when someone alters the value of the checkbox\n let thisChecked = persistedData.hasOwnProperty( 'userRole' ) && persistedData.userRole.hasOwnProperty( roleSlug ) && '1' === props.attributes.contentVisibilityRules.userRole[ roleSlug ];\n\n return (\n <CheckboxControl\n label={ role.label }\n checked={ thisChecked }\n onChange={ ( isChecked ) => {\n props.setAttributes( {\n contentVisibilityRules: {\n ...props.attributes.contentVisibilityRules,\n userRole: {\n ...props.attributes.contentVisibilityRules.userRole,\n [roleSlug]: isChecked ? '1' : '0'\n }\n },\n } );\n }}\n />\n );\n\n};","import { PanelBody, PanelRow } from '@wordpress/components';\nimport { withInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\nimport { CheckboxGroupCheckbox } from './content-visibility-role-checkbox';\nimport hasRules from '../helpers/has-rules';\n\nfunction ContentVisibilityUserRolePanelBodyControl( { instanceId, props } ) {\n\n // Fetch the roles from PHP\n const userRoles = BlockVisibilityUserRole.roles;\n\n // userRoles is an array of objects, for each registered user role.\n // Each role object looks like: {label: \"Administrator\", value: \"administrator\"}\n\n const id = `bv-roles-${ instanceId }`;\n let hasRulesClass = ( hasRules( props, 'userRole' ) ) ? ' has-active-rules' : '';\n\n return (\n <PanelBody\n title={ __( 'User Role', 'content-visibility-user-role' ) }\n initialOpen={ false }\n className={\"content-visibility-control-panel content-visibility-user-role-controls\" + hasRulesClass}\n >\n <PanelRow>\n <ul>\n {\n userRoles.map( role => (\n <CheckboxGroupCheckbox name={ id } id={ id } props={ props } role={ role } key={ props.clientId + role.value } />\n ) )\n }\n </ul>\n </PanelRow>\n\n { props.attributes.contentVisibility && (\n <p className=\"user-role-help-intro content-visibility-help-text\">{ __( 'Select one more more roles to whom this block will be ' + props.attributes.contentVisibility + '. If no roles are selected, this block will be ' + props.attributes.contentVisibility + ' regardless of a user\\'s role.', 'content-visibility-user-role' ) }</p>\n ) }\n </PanelBody>\n );\n\n}\n\nexport default withInstanceId( ContentVisibilityUserRolePanelBodyControl );","import { Fill, Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\nimport ContentVisibilityUserRolePanelBodyControl from './content-visibility-user-role-panel-body';\n\nexport function ContentVisibilityUserRoleControl( data ) {\n\n let { props } = { ...data };\n\n let rulesEnabled = props.attributes.contentVisibilityRules.contentVisibilityRulesEnabled;\n let contentVisibility = props.attributes.hasOwnProperty( 'contentVisibility' );\n\n if ( ! rulesEnabled || ! contentVisibility ) {\n return (\n <Disabled><ContentVisibilityUserRolePanelBodyControl props={ props } /></Disabled>\n );\n }\n\n return (\n <ContentVisibilityUserRolePanelBodyControl props={ props } />\n );\n\n}\n\n/**\n * Render the <ContentVisibilityUserRoleControl> component by adding\n * it to the block-visibility-extra-controls Fill.\n *\n * @return {Object} A Fill component wrapping the ContentVisibilityUserRoleControl component.\n */\nfunction ContentVisibilityUserRoleFill() {\n return (\n <Fill name=\"content-visibility-extra-controls\">\n {\n ( fillProps ) => {\n return (\n <ContentVisibilityUserRoleControl props={ fillProps } />\n )\n }\n }\n </Fill>\n );\n\n}\n\n// Add our component to the Slot provided by BlockVisibilityControls\nregisterPlugin( 'content-visibility-02-user-role-fill', { render: ContentVisibilityUserRoleFill } );\n\n\n// Register our visibility rule with the main plugin\naddFilter( 'contentVisibility.defaultContentVisibilityRules', 'content-visibility-user-role/block-visibility-rules', registerContentVisibilityRule );\n\nfunction registerContentVisibilityRule( defaultRules ) {\n\n defaultRules.userRole = {};\n\n return defaultRules;\n\n}\n","// extracted by mini-css-extract-plugin","import { applyFilters } from '@wordpress/hooks';\n\n/**\n * Determine if the passed block props contain rules of the passed type.\n *\n * @param {object} props The currently selected block's props.\n * @param {string} type The type of the rules i.e. userAuthenticated or specialPage (or ones from add-ons).\n *\n * @return {bool} true if the passed props contain non-empty rules of the passed type. False otherwise.\n */\n function hasRules( props, type ) {\n\n if ( ! props.attributes.contentVisibilityRules ) {\n return false;\n }\n\n if ( ! props.attributes.contentVisibilityRules[type] ) {\n return false;\n }\n\n // Default to false. Passed through a filter later.\n let hasRules = false;\n\n switch ( type ) {\n \n case 'userRole':\n\n if ( props.attributes.contentVisibilityRules[type] && Object.keys( props.attributes.contentVisibilityRules[type] ).length !== 0 ) {\n hasRules = true;\n }\n\n break;\n\n default:\n break;\n }\n\n return applyFilters( 'content-visibility-has-rules', hasRules, props, type );\n\n}// end hasRules()\n\nexport default hasRules;","import './editor.scss';\nimport './style.scss';\n\nimport ContentVisibilityUserRoleControl from './controls/content-visibility-user-role';","(function() { module.exports = this[\"wp\"][\"components\"]; }());","(function() { module.exports = this[\"wp\"][\"compose\"]; }());","(function() { module.exports = this[\"wp\"][\"element\"]; }());","(function() { module.exports = this[\"wp\"][\"hooks\"]; }());","(function() { module.exports = this[\"wp\"][\"i18n\"]; }());","(function() { module.exports = this[\"wp\"][\"plugins\"]; }());"],"sourceRoot":""} -
content-visibility-user-role/trunk/content-visibility-user-role.php
r2510975 r2568522 12 12 * Plugin URI: https://richardtape.com/content-visibility/ 13 13 * Description: [Content Visibility Add-On] Determine which user role(s) can see the content blocks of your choosing. 14 * Version: 0.1. 214 * Version: 0.1.3 15 15 * Author: Richard Tape 16 16 * Author URI: https://richardtape.com -
content-visibility-user-role/trunk/readme.txt
r2510975 r2568522 4 4 Tags: block, content, visibility, user, users, role, roles, contentvisibility 5 5 Requires at least: 5.0 6 Tested up to: 5. 7.07 Stable tag: 0.1. 26 Tested up to: 5.8.0 7 Stable tag: 0.1.3 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 40 40 == Changelog == 41 41 42 = 0.1.3 = 43 * Added the icon to show when a rule is selected for a block to make it easier to see which rules are active for a block. 44 * WP 5.8.0 compatibility 45 42 46 = 0.1.2 = 43 47 * WP 5.7.0 compatibility.
Note: See TracChangeset
for help on using the changeset viewer.