Changeset 2568523
- Timestamp:
- 07/20/2021 08:01:20 PM (5 years ago)
- Location:
- content-visibility-rss-feed
- Files:
-
- 6 added
- 2 deleted
- 14 edited
- 1 copied
-
tags/0.1.2 (copied) (copied from content-visibility-rss-feed/trunk)
-
tags/0.1.2/build/index.asset.php (modified) (1 diff)
-
tags/0.1.2/build/index.js (modified) (7 diffs)
-
tags/0.1.2/build/index.js.map (modified) (1 diff)
-
tags/0.1.2/content-visibility-rss-feed.php (modified) (1 diff)
-
tags/0.1.2/package.json (modified) (1 diff)
-
tags/0.1.2/readme.txt (modified) (2 diffs)
-
tags/0.1.2/src/controls/content-visibility-addon-starter.js (deleted)
-
tags/0.1.2/src/controls/content-visibility-rss-feed.js (added)
-
tags/0.1.2/src/helpers (added)
-
tags/0.1.2/src/helpers/has-rules.js (added)
-
tags/0.1.2/src/index.js (modified) (1 diff)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (7 diffs)
-
trunk/build/index.js.map (modified) (1 diff)
-
trunk/content-visibility-rss-feed.php (modified) (1 diff)
-
trunk/package.json (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/controls/content-visibility-addon-starter.js (deleted)
-
trunk/src/controls/content-visibility-rss-feed.js (added)
-
trunk/src/helpers (added)
-
trunk/src/helpers/has-rules.js (added)
-
trunk/src/index.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
content-visibility-rss-feed/tags/0.1.2/build/index.asset.php
r2506375 r2568523 1 <?php return array('dependencies' => array('wp-components', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => ' af637487a4a72b3410b8a80c2b413dc2');1 <?php return array('dependencies' => array('wp-components', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => '626ef743ed60288421c2f52626471bb4'); -
content-visibility-rss-feed/tags/0.1.2/build/index.js
r2506375 r2568523 114 114 /***/ }), 115 115 116 /***/ "./src/controls/content-visibility- addon-starter.js":117 /*!***************************************************** *****!*\118 !*** ./src/controls/content-visibility- addon-starter.js ***!119 \***************************************************** *****/116 /***/ "./src/controls/content-visibility-rss-feed.js": 117 /*!*****************************************************!*\ 118 !*** ./src/controls/content-visibility-rss-feed.js ***! 119 \*****************************************************/ 120 120 /*! exports provided: ContentVisibilityRSSFeedControl */ 121 121 /***/ (function(module, __webpack_exports__, __webpack_require__) { … … 136 136 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 137 137 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_5__); 138 /* harmony import */ var _helpers_has_rules__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../helpers/has-rules */ "./src/helpers/has-rules.js"); 138 139 139 140 … … 172 173 173 174 175 174 176 /* 175 177 * For brevity, this add-ons controls are in this file, but it may be more ideal to load them … … 190 192 191 193 var thisChecked = persistedData.hasOwnProperty('rssFeed') && persistedData.rssFeed.hasOwnProperty(dataKey) && '1' === props.attributes.contentVisibilityRules.rssFeed[dataKey]; 194 var hasRulesClass = Object(_helpers_has_rules__WEBPACK_IMPORTED_MODULE_6__["default"])(props, 'rssFeed') ? ' has-active-rules' : ''; 192 195 /** 193 196 * As it stands, this checkbox will add data to the database such as this, if the content visibility rules … … 203 206 title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('RSS Feed', 'content-visibility-rss-feed'), 204 207 initialOpen: false, 205 className: "content-visibility-control-panel content-visibility-rss-feed-controls" 208 className: "content-visibility-control-panel content-visibility-rss-feed-controls" + hasRulesClass 206 209 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__["PanelRow"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__["CheckboxControl"], { 207 210 label: "RSS Feed", … … 285 288 /***/ }), 286 289 290 /***/ "./src/helpers/has-rules.js": 291 /*!**********************************!*\ 292 !*** ./src/helpers/has-rules.js ***! 293 \**********************************/ 294 /*! exports provided: default */ 295 /***/ (function(module, __webpack_exports__, __webpack_require__) { 296 297 "use strict"; 298 __webpack_require__.r(__webpack_exports__); 299 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 300 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__); 301 302 /** 303 * Determine if the passed block props contain rules of the passed type. 304 * 305 * @param {object} props The currently selected block's props. 306 * @param {string} type The type of the rules i.e. userAuthenticated or specialPage (or ones from add-ons). 307 * 308 * @return {bool} true if the passed props contain non-empty rules of the passed type. False otherwise. 309 */ 310 311 function hasRules(props, type) { 312 if (!props.attributes.contentVisibilityRules) { 313 return false; 314 } 315 316 if (!props.attributes.contentVisibilityRules[type]) { 317 return false; 318 } // Default to false. Passed through a filter later. 319 320 321 var hasRules = false; 322 323 switch (type) { 324 case 'rssFeed': 325 if (props.attributes.contentVisibilityRules[type] && props.attributes.contentVisibilityRules[type]['rss'] === "1") { 326 hasRules = true; 327 } 328 329 break; 330 331 default: 332 break; 333 } 334 335 return Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__["applyFilters"])('content-visibility-has-rules', hasRules, props, type); 336 } // end hasRules() 337 338 339 /* harmony default export */ __webpack_exports__["default"] = (hasRules); 340 341 /***/ }), 342 287 343 /***/ "./src/index.js": 288 344 /*!**********************!*\ … … 296 352 /* harmony import */ var _styles_editor_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./styles/editor.css */ "./src/styles/editor.css"); 297 353 /* harmony import */ var _styles_editor_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styles_editor_css__WEBPACK_IMPORTED_MODULE_0__); 298 /* harmony import */ var _controls_content_visibility_ addon_starter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/content-visibility-addon-starter */ "./src/controls/content-visibility-addon-starter.js");354 /* harmony import */ var _controls_content_visibility_rss_feed__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/content-visibility-rss-feed */ "./src/controls/content-visibility-rss-feed.js"); 299 355 // Import CSS from the src directory. This will be built into /build/index.css by default. 300 356 -
content-visibility-rss-feed/tags/0.1.2/build/index.js.map
r2506375 r2568523 1 {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/controls/content-visibility- addon-starter.js","webpack:///./src/index.js","webpack:///./src/styles/editor.css","webpack:///external [\"wp\",\"components\"]","webpack:///external [\"wp\",\"element\"]","webpack:///external [\"wp\",\"hooks\"]","webpack:///external [\"wp\",\"i18n\"]","webpack:///external [\"wp\",\"plugins\"]"],"names":["ContentVisibilityRSSFeedPanelBodyControl","props","phpData","BlockVisibilityRSSFeed","persistedData","attributes","contentVisibilityRules","dataKey","thisChecked","hasOwnProperty","rssFeed","__","isChecked","setAttributes","contentVisibility","ContentVisibilityRSSFeedControl","data","rulesEnabled","contentVisibilityRulesEnabled","ContentVisibilityRSSFeedFill","fillProps","registerPlugin","render","addFilter","registerContentVisibilityRule","defaultRules"],"mappings":";QAAA;QACA;;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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,UAAEC,SAAF,EAAiB;AACb,WACI,yEAAC,+BAAD;AAAiC,WAAK,EAAGA;AAAzC,MADJ;AAGH,GANT,CADJ;AAYH,C,CAAA;AAED;AACA;;;AACAC,yEAAc,CAAE,oCAAF,EAAwC;AAAEC,QAAM,EAAEH;AAAV,CAAxC,CAAd,C,CAGA;;AACAI,kEAAS,CAAE,iDAAF,EAAqD,oDAArD,EAA2GC,6BAA3G,CAAT;AAEA;AACA;AACA;AACA;;AACA,SAASA,6BAAT,CAAwCC,YAAxC,EAAuD;AAEnDA,cAAY,CAACf,OAAb,GAAuB,EAAvB;AAEA,SAAOe,YAAP;AAEH,C,CAAA,qC;;;;;;;;;;;;ACrKD;AAAA;AAAA;AAAA;AAAA;AACA;;;;;;;;;;;;ACDA,uC;;;;;;;;;;;ACAA,aAAa,6CAA6C,EAAE,I;;;;;;;;;;;ACA5D,aAAa,0CAA0C,EAAE,I;;;;;;;;;;;ACAzD,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,uCAAuC,EAAE,I;;;;;;;;;;;ACAtD,aAAa,0CAA0C,EAAE,I","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\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\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\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;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","/**\n * Load WordPress dependencies.\n *\n * Fill is used as add-ons register their components into a slot provided by the core Content\n * Visibility Plugin.\n * \n * Disabled allows the add-ons controls to be uncontrollable by the user until the prerequisites\n * have been set. Prereqs are to enable Content Visibility Rules and to choose shown or\n * hidden.\n * \n * __ is the way to internationalize text.\n * \n * registerPlugin is used to integrate this add-on with cContent Visibility\n * addFilter registers the key for our data\n */ \nimport { Fill, Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Load this add-on's dependencies.\n *\n * PanelBody is how all content visibility add-ons are added.\n * PanelRow fits within PanelBody - is a place to put controls.\n * CheckboxControl is the block editor provided Checkbox input.\n */\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { CheckboxControl } from '@wordpress/components';\n\n\n/*\n* For brevity, this add-ons controls are in this file, but it may be more ideal to load them\n* in a separate file and import`ing them here.\n*/\nfunction ContentVisibilityRSSFeedPanelBodyControl( { props } ) {\n\n // Fetch the data from PHP\n const phpData = BlockVisibilityRSSFeed;\n\n // You may want to check your data is sent from PHP to JS correctly.\n // console.log( phpData );\n\n // What data has been persisted in the db?\n let persistedData = props.attributes.contentVisibilityRules;\n\n // This variable is merely an example. It is used to store data.\n let dataKey = 'rss';\n\n // If we have persisted data, 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( 'rssFeed' ) && persistedData.rssFeed.hasOwnProperty( dataKey ) && '1' === props.attributes.contentVisibilityRules.rssFeed[ dataKey ];\n\n /**\n * As it stands, this checkbox will add data to the database such as this, if the content visibility rules\n * are added to a paragraph block (truncated a little for brevity)\n * \n *\n <!-- wp:paragraph {\"contentVisibility\":\"shown\",\"contentVisibilityRules\":{\"contentVisibilityRulesEnabled\":true,\"rssFeed\":{\"yourDataKey\":\"1\"}}} -->\n <p contentvisibility=\"shown\">This paragraph has the addon starter checkbox checked.</p>\n <!-- /wp:paragraph -->\n */\n return (\n <PanelBody\n title={ __( 'RSS Feed', 'content-visibility-rss-feed' ) }\n initialOpen={ false }\n className=\"content-visibility-control-panel content-visibility-rss-feed-controls\"\n >\n <PanelRow>\n <CheckboxControl\n label='RSS Feed'\n checked={ thisChecked }\n onChange={ ( isChecked ) => {\n props.setAttributes( {\n contentVisibilityRules: {\n ...props.attributes.contentVisibilityRules,\n rssFeed: {\n ...props.attributes.contentVisibilityRules.rssFeed,\n [dataKey]: isChecked ? '1' : '0'\n }\n },\n } );\n }}\n />\n\n { props.attributes.contentVisibility && (\n <p className=\"rss-feed-help-intro content-visibility-help-text\">{ __( 'Checking this box means that for those using RSS Feed readers this block will be ' + props.attributes.contentVisibility + '.', 'content-visibility-rss-feed' ) }</p>\n ) }\n </PanelRow>\n\n </PanelBody>\n );\n\n}//end ContentVisibilityRSSFeedPanelBodyControl()\n\n\n/**\n * The component that is exported and loaded and what is displayed to the user.\n * This should be a PanelBodyControl component which contains your controls.\n * @param {object} data The block data \n */\nexport function ContentVisibilityRSSFeedControl( data ) {\n\n let { props } = { ...data };\n\n // Does this block have rules enabled and have we selected shown or hidden?\n let rulesEnabled = props.attributes.contentVisibilityRules.contentVisibilityRulesEnabled;\n let contentVisibility = props.attributes.hasOwnProperty( 'contentVisibility' );\n\n // Both need to be set, if not, the controls for this add-on should be disabled.\n // This is done by wrapping our controls in a <Disabled> component.\n if ( ! rulesEnabled || ! contentVisibility ) {\n return (\n <Disabled><ContentVisibilityRSSFeedPanelBodyControl props={ props } /></Disabled>\n );\n }\n\n // This block has rules enabled and the user has selected 'shown' or 'hidden'. Load our controls.\n return (\n <ContentVisibilityRSSFeedPanelBodyControl props={ props } />\n );\n\n}//end ContentVisibilityRSSFeedControl()\n\n/**\n * Render the <ContentVisibilityRSSFeedControl> component by adding\n * it to the block-visibility-extra-controls Fill.\n *\n * @return {Object} A Fill component wrapping the ContentVisibilityRSSFeedControl component.\n */\nfunction ContentVisibilityRSSFeedFill() {\n\n // Do not change the name attribute of this Fill. It is the name provided by the Content Visibility plugin.\n return (\n <Fill name=\"content-visibility-extra-controls\">\n {\n ( fillProps ) => {\n return (\n <ContentVisibilityRSSFeedControl props={ fillProps } />\n )\n }\n }\n </Fill>\n );\n\n}//end ContentVisibilityRSSFeedFill()\n\n// Add our component to the Slot provided by BlockVisibilityControls\n// The integer is an attempt to control the order of display of add-ons in the block sidebar. Higher = lower.\nregisterPlugin( 'content-visibility-6-rss-feed-fill', { render: ContentVisibilityRSSFeedFill } );\n\n\n// Register our visibility rule with the main plugin\naddFilter( 'contentVisibility.defaultContentVisibilityRules', 'content-visibility-rss-feed/block-visibility-rules', registerContentVisibilityRule );\n\n/**\n * Register our data key so that controls for this add-on have a place to store their data.\n * @param {*} defaultRules \n */\nfunction registerContentVisibilityRule( defaultRules ) {\n\n defaultRules.rssFeed = {};\n\n return defaultRules;\n\n}//end registerContentVisibilityRule()\n","// Import CSS from the src directory. This will be built into /build/index.css by default.\nimport './styles/editor.css';\n\nimport ContentVisibilityRSSFeedControl from './controls/content-visibility-addon-starter';","// extracted by mini-css-extract-plugin","(function() { module.exports = window[\"wp\"][\"components\"]; }());","(function() { module.exports = window[\"wp\"][\"element\"]; }());","(function() { module.exports = window[\"wp\"][\"hooks\"]; }());","(function() { module.exports = window[\"wp\"][\"i18n\"]; }());","(function() { module.exports = window[\"wp\"][\"plugins\"]; }());"],"sourceRoot":""}1 {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/controls/content-visibility-rss-feed.js","webpack:///./src/helpers/has-rules.js","webpack:///./src/index.js","webpack:///./src/styles/editor.css","webpack:///external [\"wp\",\"components\"]","webpack:///external [\"wp\",\"element\"]","webpack:///external [\"wp\",\"hooks\"]","webpack:///external [\"wp\",\"i18n\"]","webpack:///external [\"wp\",\"plugins\"]"],"names":["ContentVisibilityRSSFeedPanelBodyControl","props","phpData","BlockVisibilityRSSFeed","persistedData","attributes","contentVisibilityRules","dataKey","thisChecked","hasOwnProperty","rssFeed","hasRulesClass","hasRules","__","isChecked","setAttributes","contentVisibility","ContentVisibilityRSSFeedControl","data","rulesEnabled","contentVisibilityRulesEnabled","ContentVisibilityRSSFeedFill","fillProps","registerPlugin","render","addFilter","registerContentVisibilityRule","defaultRules","type","applyFilters"],"mappings":";QAAA;QACA;;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;;;QAGA;QACA;;;;;;;;;;;;AClFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA,6E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;;AACA,SAASA,wCAAT,OAA+D;AAAA,MAAVC,KAAU,QAAVA,KAAU;AAE3D;AACA,MAAMC,OAAO,GAAGC,sBAAhB,CAH2D,CAK3D;AACA;AAEA;;AACA,MAA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AAiBC,sBAAxB,EAAiD;AAC7C,WAAO,KAAP;AACH;;AAED,MAAK,CAAEL,KAAK,CAACI,UAAN,CAAiBC,sBAAjB,CAAwCsB,IAAxC,CAAP,EAAuD;AACnD,WAAO,KAAP;AACH,GAR6B,CAU9B;;;AACA,MAAIhB,QAAQ,GAAG,KAAf;;AAEA,UAASgB,IAAT;AAEI,SAAK,SAAL;AAEI,UAAK3B,KAAK,CAACI,UAAN,CAAiBC,sBAAjB,CAAwCsB,IAAxC,KAAiD3B,KAAK,CAACI,UAAN,CAAiBC,sBAAjB,CAAwCsB,IAAxC,EAA8C,KAA9C,MAAyD,GAA/G,EAAqH;AACjHhB,gBAAQ,GAAG,IAAX;AACH;;AAED;;AAEJ;AACI;AAXR;;AAcA,SAAOiB,qEAAY,CAAE,8BAAF,EAAkCjB,QAAlC,EAA4CX,KAA5C,EAAmD2B,IAAnD,CAAnB;AAEH,C,CAAA;;;AAEchB,uEAAf,E;;;;;;;;;;;;ACzCA;AAAA;AAAA;AAAA;AAAA;AACA;;;;;;;;;;;;ACDA,uC;;;;;;;;;;;ACAA,aAAa,6CAA6C,EAAE,I;;;;;;;;;;;ACA5D,aAAa,0CAA0C,EAAE,I;;;;;;;;;;;ACAzD,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,uCAAuC,EAAE,I;;;;;;;;;;;ACAtD,aAAa,0CAA0C,EAAE,I","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\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\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\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;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","/**\n * Load WordPress dependencies.\n *\n * Fill is used as add-ons register their components into a slot provided by the core Content\n * Visibility Plugin.\n * \n * Disabled allows the add-ons controls to be uncontrollable by the user until the prerequisites\n * have been set. Prereqs are to enable Content Visibility Rules and to choose shown or\n * hidden.\n * \n * __ is the way to internationalize text.\n * \n * registerPlugin is used to integrate this add-on with cContent Visibility\n * addFilter registers the key for our data\n */ \nimport { Fill, Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Load this add-on's dependencies.\n *\n * PanelBody is how all content visibility add-ons are added.\n * PanelRow fits within PanelBody - is a place to put controls.\n * CheckboxControl is the block editor provided Checkbox input.\n */\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { CheckboxControl } from '@wordpress/components';\nimport hasRules from '../helpers/has-rules';\n\n/*\n* For brevity, this add-ons controls are in this file, but it may be more ideal to load them\n* in a separate file and import`ing them here.\n*/\nfunction ContentVisibilityRSSFeedPanelBodyControl( { props } ) {\n\n // Fetch the data from PHP\n const phpData = BlockVisibilityRSSFeed;\n\n // You may want to check your data is sent from PHP to JS correctly.\n // console.log( phpData );\n\n // What data has been persisted in the db?\n let persistedData = props.attributes.contentVisibilityRules;\n\n // This variable is merely an example. It is used to store data.\n let dataKey = 'rss';\n\n // If we have persisted data, 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( 'rssFeed' ) && persistedData.rssFeed.hasOwnProperty( dataKey ) && '1' === props.attributes.contentVisibilityRules.rssFeed[ dataKey ];\n\n let hasRulesClass = ( hasRules( props, 'rssFeed' ) ) ? ' has-active-rules' : '';\n\n /**\n * As it stands, this checkbox will add data to the database such as this, if the content visibility rules\n * are added to a paragraph block (truncated a little for brevity)\n * \n *\n <!-- wp:paragraph {\"contentVisibility\":\"shown\",\"contentVisibilityRules\":{\"contentVisibilityRulesEnabled\":true,\"rssFeed\":{\"yourDataKey\":\"1\"}}} -->\n <p contentvisibility=\"shown\">This paragraph has the addon starter checkbox checked.</p>\n <!-- /wp:paragraph -->\n */\n return (\n <PanelBody\n title={ __( 'RSS Feed', 'content-visibility-rss-feed' ) }\n initialOpen={ false }\n className={\"content-visibility-control-panel content-visibility-rss-feed-controls\" + hasRulesClass}\n >\n <PanelRow>\n <CheckboxControl\n label='RSS Feed'\n checked={ thisChecked }\n onChange={ ( isChecked ) => {\n props.setAttributes( {\n contentVisibilityRules: {\n ...props.attributes.contentVisibilityRules,\n rssFeed: {\n ...props.attributes.contentVisibilityRules.rssFeed,\n [dataKey]: isChecked ? '1' : '0'\n }\n },\n } );\n }}\n />\n\n { props.attributes.contentVisibility && (\n <p className=\"rss-feed-help-intro content-visibility-help-text\">{ __( 'Checking this box means that for those using RSS Feed readers this block will be ' + props.attributes.contentVisibility + '.', 'content-visibility-rss-feed' ) }</p>\n ) }\n </PanelRow>\n\n </PanelBody>\n );\n\n}//end ContentVisibilityRSSFeedPanelBodyControl()\n\n\n/**\n * The component that is exported and loaded and what is displayed to the user.\n * This should be a PanelBodyControl component which contains your controls.\n * @param {object} data The block data \n */\nexport function ContentVisibilityRSSFeedControl( data ) {\n\n let { props } = { ...data };\n\n // Does this block have rules enabled and have we selected shown or hidden?\n let rulesEnabled = props.attributes.contentVisibilityRules.contentVisibilityRulesEnabled;\n let contentVisibility = props.attributes.hasOwnProperty( 'contentVisibility' );\n\n // Both need to be set, if not, the controls for this add-on should be disabled.\n // This is done by wrapping our controls in a <Disabled> component.\n if ( ! rulesEnabled || ! contentVisibility ) {\n return (\n <Disabled><ContentVisibilityRSSFeedPanelBodyControl props={ props } /></Disabled>\n );\n }\n\n // This block has rules enabled and the user has selected 'shown' or 'hidden'. Load our controls.\n return (\n <ContentVisibilityRSSFeedPanelBodyControl props={ props } />\n );\n\n}//end ContentVisibilityRSSFeedControl()\n\n/**\n * Render the <ContentVisibilityRSSFeedControl> component by adding\n * it to the block-visibility-extra-controls Fill.\n *\n * @return {Object} A Fill component wrapping the ContentVisibilityRSSFeedControl component.\n */\nfunction ContentVisibilityRSSFeedFill() {\n\n // Do not change the name attribute of this Fill. It is the name provided by the Content Visibility plugin.\n return (\n <Fill name=\"content-visibility-extra-controls\">\n {\n ( fillProps ) => {\n return (\n <ContentVisibilityRSSFeedControl props={ fillProps } />\n )\n }\n }\n </Fill>\n );\n\n}//end ContentVisibilityRSSFeedFill()\n\n// Add our component to the Slot provided by BlockVisibilityControls\n// The integer is an attempt to control the order of display of add-ons in the block sidebar. Higher = lower.\nregisterPlugin( 'content-visibility-6-rss-feed-fill', { render: ContentVisibilityRSSFeedFill } );\n\n\n// Register our visibility rule with the main plugin\naddFilter( 'contentVisibility.defaultContentVisibilityRules', 'content-visibility-rss-feed/block-visibility-rules', registerContentVisibilityRule );\n\n/**\n * Register our data key so that controls for this add-on have a place to store their data.\n * @param {*} defaultRules \n */\nfunction registerContentVisibilityRule( defaultRules ) {\n\n defaultRules.rssFeed = {};\n\n return defaultRules;\n\n}//end registerContentVisibilityRule()\n","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 'rssFeed':\n\n if ( props.attributes.contentVisibilityRules[type] && props.attributes.contentVisibilityRules[type]['rss'] === \"1\" ) {\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 CSS from the src directory. This will be built into /build/index.css by default.\nimport './styles/editor.css';\n\nimport ContentVisibilityRSSFeedControl from './controls/content-visibility-rss-feed';","// extracted by mini-css-extract-plugin","(function() { module.exports = window[\"wp\"][\"components\"]; }());","(function() { module.exports = window[\"wp\"][\"element\"]; }());","(function() { module.exports = window[\"wp\"][\"hooks\"]; }());","(function() { module.exports = window[\"wp\"][\"i18n\"]; }());","(function() { module.exports = window[\"wp\"][\"plugins\"]; }());"],"sourceRoot":""} -
content-visibility-rss-feed/tags/0.1.2/content-visibility-rss-feed.php
r2506375 r2568523 12 12 * Plugin URI: https://richardtape.com/content-visibility/ 13 13 * Description: [Content Visibility Add-On] Show or hide your content for those folks consuming your content with RSS. 14 * Version: 0.1. 014 * Version: 0.1.2 15 15 * Author: Richard Tape 16 16 * Author URI: https://richardtape.com -
content-visibility-rss-feed/tags/0.1.2/package.json
r2506375 r2568523 1 1 { 2 2 "name": "content-visibility-rss-feed", 3 "version": "0.1. 1",3 "version": "0.1.2", 4 4 "description": "As RSS Feed add-on for Content Visibility", 5 5 "main": "build/index.js", -
content-visibility-rss-feed/tags/0.1.2/readme.txt
r2506375 r2568523 2 2 Contributors: iamfriendly 3 3 Donate link: https://girlswhocode.com/ 4 Tags: block, content, visibility, rss, feed, contentvisibility4 Tags: contentvisibility, block, content, visibility, rss, feed 5 5 Requires at least: 5.0 6 Tested up to: 5. 7.07 Stable tag: 0.1. 16 Tested up to: 5.8.0 7 Stable tag: 0.1.2 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 35 35 == Changelog == 36 36 37 = 0.1.2 = 38 * Added small icon to indicate when a block has RSS Feed rules. 39 * WP 5.8.0 compatibility. 40 37 41 = 0.1.1 = 38 42 * First public release. -
content-visibility-rss-feed/tags/0.1.2/src/index.js
r2506375 r2568523 2 2 import './styles/editor.css'; 3 3 4 import ContentVisibilityRSSFeedControl from './controls/content-visibility- addon-starter';4 import ContentVisibilityRSSFeedControl from './controls/content-visibility-rss-feed'; -
content-visibility-rss-feed/trunk/build/index.asset.php
r2506375 r2568523 1 <?php return array('dependencies' => array('wp-components', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => ' af637487a4a72b3410b8a80c2b413dc2');1 <?php return array('dependencies' => array('wp-components', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => '626ef743ed60288421c2f52626471bb4'); -
content-visibility-rss-feed/trunk/build/index.js
r2506375 r2568523 114 114 /***/ }), 115 115 116 /***/ "./src/controls/content-visibility- addon-starter.js":117 /*!***************************************************** *****!*\118 !*** ./src/controls/content-visibility- addon-starter.js ***!119 \***************************************************** *****/116 /***/ "./src/controls/content-visibility-rss-feed.js": 117 /*!*****************************************************!*\ 118 !*** ./src/controls/content-visibility-rss-feed.js ***! 119 \*****************************************************/ 120 120 /*! exports provided: ContentVisibilityRSSFeedControl */ 121 121 /***/ (function(module, __webpack_exports__, __webpack_require__) { … … 136 136 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 137 137 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_5__); 138 /* harmony import */ var _helpers_has_rules__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../helpers/has-rules */ "./src/helpers/has-rules.js"); 138 139 139 140 … … 172 173 173 174 175 174 176 /* 175 177 * For brevity, this add-ons controls are in this file, but it may be more ideal to load them … … 190 192 191 193 var thisChecked = persistedData.hasOwnProperty('rssFeed') && persistedData.rssFeed.hasOwnProperty(dataKey) && '1' === props.attributes.contentVisibilityRules.rssFeed[dataKey]; 194 var hasRulesClass = Object(_helpers_has_rules__WEBPACK_IMPORTED_MODULE_6__["default"])(props, 'rssFeed') ? ' has-active-rules' : ''; 192 195 /** 193 196 * As it stands, this checkbox will add data to the database such as this, if the content visibility rules … … 203 206 title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('RSS Feed', 'content-visibility-rss-feed'), 204 207 initialOpen: false, 205 className: "content-visibility-control-panel content-visibility-rss-feed-controls" 208 className: "content-visibility-control-panel content-visibility-rss-feed-controls" + hasRulesClass 206 209 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__["PanelRow"], null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__["CheckboxControl"], { 207 210 label: "RSS Feed", … … 285 288 /***/ }), 286 289 290 /***/ "./src/helpers/has-rules.js": 291 /*!**********************************!*\ 292 !*** ./src/helpers/has-rules.js ***! 293 \**********************************/ 294 /*! exports provided: default */ 295 /***/ (function(module, __webpack_exports__, __webpack_require__) { 296 297 "use strict"; 298 __webpack_require__.r(__webpack_exports__); 299 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); 300 /* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__); 301 302 /** 303 * Determine if the passed block props contain rules of the passed type. 304 * 305 * @param {object} props The currently selected block's props. 306 * @param {string} type The type of the rules i.e. userAuthenticated or specialPage (or ones from add-ons). 307 * 308 * @return {bool} true if the passed props contain non-empty rules of the passed type. False otherwise. 309 */ 310 311 function hasRules(props, type) { 312 if (!props.attributes.contentVisibilityRules) { 313 return false; 314 } 315 316 if (!props.attributes.contentVisibilityRules[type]) { 317 return false; 318 } // Default to false. Passed through a filter later. 319 320 321 var hasRules = false; 322 323 switch (type) { 324 case 'rssFeed': 325 if (props.attributes.contentVisibilityRules[type] && props.attributes.contentVisibilityRules[type]['rss'] === "1") { 326 hasRules = true; 327 } 328 329 break; 330 331 default: 332 break; 333 } 334 335 return Object(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__["applyFilters"])('content-visibility-has-rules', hasRules, props, type); 336 } // end hasRules() 337 338 339 /* harmony default export */ __webpack_exports__["default"] = (hasRules); 340 341 /***/ }), 342 287 343 /***/ "./src/index.js": 288 344 /*!**********************!*\ … … 296 352 /* harmony import */ var _styles_editor_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./styles/editor.css */ "./src/styles/editor.css"); 297 353 /* harmony import */ var _styles_editor_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styles_editor_css__WEBPACK_IMPORTED_MODULE_0__); 298 /* harmony import */ var _controls_content_visibility_ addon_starter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/content-visibility-addon-starter */ "./src/controls/content-visibility-addon-starter.js");354 /* harmony import */ var _controls_content_visibility_rss_feed__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/content-visibility-rss-feed */ "./src/controls/content-visibility-rss-feed.js"); 299 355 // Import CSS from the src directory. This will be built into /build/index.css by default. 300 356 -
content-visibility-rss-feed/trunk/build/index.js.map
r2506375 r2568523 1 {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/controls/content-visibility- addon-starter.js","webpack:///./src/index.js","webpack:///./src/styles/editor.css","webpack:///external [\"wp\",\"components\"]","webpack:///external [\"wp\",\"element\"]","webpack:///external [\"wp\",\"hooks\"]","webpack:///external [\"wp\",\"i18n\"]","webpack:///external [\"wp\",\"plugins\"]"],"names":["ContentVisibilityRSSFeedPanelBodyControl","props","phpData","BlockVisibilityRSSFeed","persistedData","attributes","contentVisibilityRules","dataKey","thisChecked","hasOwnProperty","rssFeed","__","isChecked","setAttributes","contentVisibility","ContentVisibilityRSSFeedControl","data","rulesEnabled","contentVisibilityRulesEnabled","ContentVisibilityRSSFeedFill","fillProps","registerPlugin","render","addFilter","registerContentVisibilityRule","defaultRules"],"mappings":";QAAA;QACA;;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;;;QAGA;QACA;;;;;;;;;;;;AClFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA,6E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AAGA;AACA;AACA;AACA;;AACA,SAASA,wCAAT,OAA+D;AAAA,MAAVC,KAAU,QAAVA,KAAU;AAE3D;AACA,MAAMC,OAAO,GAAGC,sBAAhB,CAH2D,CAK3D;AACA;AAEA;;AACA,MAAIC,aAA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cesContent":[" \t// The module cache\n \tvar installedModules = {};\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\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\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;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","/**\n * Load WordPress dependencies.\n *\n * Fill is used as add-ons register their components into a slot provided by the core Content\n * Visibility Plugin.\n * \n * Disabled allows the add-ons controls to be uncontrollable by the user until the prerequisites\n * have been set. Prereqs are to enable Content Visibility Rules and to choose shown or\n * hidden.\n * \n * __ is the way to internationalize text.\n * \n * registerPlugin is used to integrate this add-on with cContent Visibility\n * addFilter registers the key for our data\n */ \nimport { Fill, Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Load this add-on's dependencies.\n *\n * PanelBody is how all content visibility add-ons are added.\n * PanelRow fits within PanelBody - is a place to put controls.\n * CheckboxControl is the block editor provided Checkbox input.\n */\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { CheckboxControl } from '@wordpress/components';\n\n\n/*\n* For brevity, this add-ons controls are in this file, but it may be more ideal to load them\n* in a separate file and import`ing them here.\n*/\nfunction ContentVisibilityRSSFeedPanelBodyControl( { props } ) {\n\n // Fetch the data from PHP\n const phpData = BlockVisibilityRSSFeed;\n\n // You may want to check your data is sent from PHP to JS correctly.\n // console.log( phpData );\n\n // What data has been persisted in the db?\n let persistedData = props.attributes.contentVisibilityRules;\n\n // This variable is merely an example. It is used to store data.\n let dataKey = 'rss';\n\n // If we have persisted data, 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( 'rssFeed' ) && persistedData.rssFeed.hasOwnProperty( dataKey ) && '1' === props.attributes.contentVisibilityRules.rssFeed[ dataKey ];\n\n /**\n * As it stands, this checkbox will add data to the database such as this, if the content visibility rules\n * are added to a paragraph block (truncated a little for brevity)\n * \n *\n <!-- wp:paragraph {\"contentVisibility\":\"shown\",\"contentVisibilityRules\":{\"contentVisibilityRulesEnabled\":true,\"rssFeed\":{\"yourDataKey\":\"1\"}}} -->\n <p contentvisibility=\"shown\">This paragraph has the addon starter checkbox checked.</p>\n <!-- /wp:paragraph -->\n */\n return (\n <PanelBody\n title={ __( 'RSS Feed', 'content-visibility-rss-feed' ) }\n initialOpen={ false }\n className=\"content-visibility-control-panel content-visibility-rss-feed-controls\"\n >\n <PanelRow>\n <CheckboxControl\n label='RSS Feed'\n checked={ thisChecked }\n onChange={ ( isChecked ) => {\n props.setAttributes( {\n contentVisibilityRules: {\n ...props.attributes.contentVisibilityRules,\n rssFeed: {\n ...props.attributes.contentVisibilityRules.rssFeed,\n [dataKey]: isChecked ? '1' : '0'\n }\n },\n } );\n }}\n />\n\n { props.attributes.contentVisibility && (\n <p className=\"rss-feed-help-intro content-visibility-help-text\">{ __( 'Checking this box means that for those using RSS Feed readers this block will be ' + props.attributes.contentVisibility + '.', 'content-visibility-rss-feed' ) }</p>\n ) }\n </PanelRow>\n\n </PanelBody>\n );\n\n}//end ContentVisibilityRSSFeedPanelBodyControl()\n\n\n/**\n * The component that is exported and loaded and what is displayed to the user.\n * This should be a PanelBodyControl component which contains your controls.\n * @param {object} data The block data \n */\nexport function ContentVisibilityRSSFeedControl( data ) {\n\n let { props } = { ...data };\n\n // Does this block have rules enabled and have we selected shown or hidden?\n let rulesEnabled = props.attributes.contentVisibilityRules.contentVisibilityRulesEnabled;\n let contentVisibility = props.attributes.hasOwnProperty( 'contentVisibility' );\n\n // Both need to be set, if not, the controls for this add-on should be disabled.\n // This is done by wrapping our controls in a <Disabled> component.\n if ( ! rulesEnabled || ! contentVisibility ) {\n return (\n <Disabled><ContentVisibilityRSSFeedPanelBodyControl props={ props } /></Disabled>\n );\n }\n\n // This block has rules enabled and the user has selected 'shown' or 'hidden'. Load our controls.\n return (\n <ContentVisibilityRSSFeedPanelBodyControl props={ props } />\n );\n\n}//end ContentVisibilityRSSFeedControl()\n\n/**\n * Render the <ContentVisibilityRSSFeedControl> component by adding\n * it to the block-visibility-extra-controls Fill.\n *\n * @return {Object} A Fill component wrapping the ContentVisibilityRSSFeedControl component.\n */\nfunction ContentVisibilityRSSFeedFill() {\n\n // Do not change the name attribute of this Fill. It is the name provided by the Content Visibility plugin.\n return (\n <Fill name=\"content-visibility-extra-controls\">\n {\n ( fillProps ) => {\n return (\n <ContentVisibilityRSSFeedControl props={ fillProps } />\n )\n }\n }\n </Fill>\n );\n\n}//end ContentVisibilityRSSFeedFill()\n\n// Add our component to the Slot provided by BlockVisibilityControls\n// The integer is an attempt to control the order of display of add-ons in the block sidebar. Higher = lower.\nregisterPlugin( 'content-visibility-6-rss-feed-fill', { render: ContentVisibilityRSSFeedFill } );\n\n\n// Register our visibility rule with the main plugin\naddFilter( 'contentVisibility.defaultContentVisibilityRules', 'content-visibility-rss-feed/block-visibility-rules', registerContentVisibilityRule );\n\n/**\n * Register our data key so that controls for this add-on have a place to store their data.\n * @param {*} defaultRules \n */\nfunction registerContentVisibilityRule( defaultRules ) {\n\n defaultRules.rssFeed = {};\n\n return defaultRules;\n\n}//end registerContentVisibilityRule()\n","// Import CSS from the src directory. This will be built into /build/index.css by default.\nimport './styles/editor.css';\n\nimport ContentVisibilityRSSFeedControl from './controls/content-visibility-addon-starter';","// extracted by mini-css-extract-plugin","(function() { module.exports = window[\"wp\"][\"components\"]; }());","(function() { module.exports = window[\"wp\"][\"element\"]; }());","(function() { module.exports = window[\"wp\"][\"hooks\"]; }());","(function() { module.exports = window[\"wp\"][\"i18n\"]; }());","(function() { module.exports = window[\"wp\"][\"plugins\"]; }());"],"sourceRoot":""}1 {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./src/controls/content-visibility-rss-feed.js","webpack:///./src/helpers/has-rules.js","webpack:///./src/index.js","webpack:///./src/styles/editor.css","webpack:///external [\"wp\",\"components\"]","webpack:///external [\"wp\",\"element\"]","webpack:///external [\"wp\",\"hooks\"]","webpack:///external [\"wp\",\"i18n\"]","webpack:///external [\"wp\",\"plugins\"]"],"names":["ContentVisibilityRSSFeedPanelBodyControl","props","phpData","BlockVisibilityRSSFeed","persistedData","attributes","contentVisibilityRules","dataKey","thisChecked","hasOwnProperty","rssFeed","hasRulesClass","hasRules","__","isChecked","setAttributes","contentVisibility","ContentVisibilityRSSFeedControl","data","rulesEnabled","contentVisibilityRulesEnabled","ContentVisibilityRSSFeedFill","fillProps","registerPlugin","render","addFilter","registerContentVisibilityRule","defaultRules","type","applyFilters"],"mappings":";QAAA;QACA;;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,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;;;;;;;;;;;ACA5D,aAAa,0CAA0C,EAAE,I;;;;;;;;;;;ACAzD,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,uCAAuC,EAAE,I;;;;;;;;;;;ACAtD,aAAa,0CAA0C,EAAE,I","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\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\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\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;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","/**\n * Load WordPress dependencies.\n *\n * Fill is used as add-ons register their components into a slot provided by the core Content\n * Visibility Plugin.\n * \n * Disabled allows the add-ons controls to be uncontrollable by the user until the prerequisites\n * have been set. Prereqs are to enable Content Visibility Rules and to choose shown or\n * hidden.\n * \n * __ is the way to internationalize text.\n * \n * registerPlugin is used to integrate this add-on with cContent Visibility\n * addFilter registers the key for our data\n */ \nimport { Fill, Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Load this add-on's dependencies.\n *\n * PanelBody is how all content visibility add-ons are added.\n * PanelRow fits within PanelBody - is a place to put controls.\n * CheckboxControl is the block editor provided Checkbox input.\n */\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { CheckboxControl } from '@wordpress/components';\nimport hasRules from '../helpers/has-rules';\n\n/*\n* For brevity, this add-ons controls are in this file, but it may be more ideal to load them\n* in a separate file and import`ing them here.\n*/\nfunction ContentVisibilityRSSFeedPanelBodyControl( { props } ) {\n\n // Fetch the data from PHP\n const phpData = BlockVisibilityRSSFeed;\n\n // You may want to check your data is sent from PHP to JS correctly.\n // console.log( phpData );\n\n // What data has been persisted in the db?\n let persistedData = props.attributes.contentVisibilityRules;\n\n // This variable is merely an example. It is used to store data.\n let dataKey = 'rss';\n\n // If we have persisted data, 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( 'rssFeed' ) && persistedData.rssFeed.hasOwnProperty( dataKey ) && '1' === props.attributes.contentVisibilityRules.rssFeed[ dataKey ];\n\n let hasRulesClass = ( hasRules( props, 'rssFeed' ) ) ? ' has-active-rules' : '';\n\n /**\n * As it stands, this checkbox will add data to the database such as this, if the content visibility rules\n * are added to a paragraph block (truncated a little for brevity)\n * \n *\n <!-- wp:paragraph {\"contentVisibility\":\"shown\",\"contentVisibilityRules\":{\"contentVisibilityRulesEnabled\":true,\"rssFeed\":{\"yourDataKey\":\"1\"}}} -->\n <p contentvisibility=\"shown\">This paragraph has the addon starter checkbox checked.</p>\n <!-- /wp:paragraph -->\n */\n return (\n <PanelBody\n title={ __( 'RSS Feed', 'content-visibility-rss-feed' ) }\n initialOpen={ false }\n className={\"content-visibility-control-panel content-visibility-rss-feed-controls\" + hasRulesClass}\n >\n <PanelRow>\n <CheckboxControl\n label='RSS Feed'\n checked={ thisChecked }\n onChange={ ( isChecked ) => {\n props.setAttributes( {\n contentVisibilityRules: {\n ...props.attributes.contentVisibilityRules,\n rssFeed: {\n ...props.attributes.contentVisibilityRules.rssFeed,\n [dataKey]: isChecked ? '1' : '0'\n }\n },\n } );\n }}\n />\n\n { props.attributes.contentVisibility && (\n <p className=\"rss-feed-help-intro content-visibility-help-text\">{ __( 'Checking this box means that for those using RSS Feed readers this block will be ' + props.attributes.contentVisibility + '.', 'content-visibility-rss-feed' ) }</p>\n ) }\n </PanelRow>\n\n </PanelBody>\n );\n\n}//end ContentVisibilityRSSFeedPanelBodyControl()\n\n\n/**\n * The component that is exported and loaded and what is displayed to the user.\n * This should be a PanelBodyControl component which contains your controls.\n * @param {object} data The block data \n */\nexport function ContentVisibilityRSSFeedControl( data ) {\n\n let { props } = { ...data };\n\n // Does this block have rules enabled and have we selected shown or hidden?\n let rulesEnabled = props.attributes.contentVisibilityRules.contentVisibilityRulesEnabled;\n let contentVisibility = props.attributes.hasOwnProperty( 'contentVisibility' );\n\n // Both need to be set, if not, the controls for this add-on should be disabled.\n // This is done by wrapping our controls in a <Disabled> component.\n if ( ! rulesEnabled || ! contentVisibility ) {\n return (\n <Disabled><ContentVisibilityRSSFeedPanelBodyControl props={ props } /></Disabled>\n );\n }\n\n // This block has rules enabled and the user has selected 'shown' or 'hidden'. Load our controls.\n return (\n <ContentVisibilityRSSFeedPanelBodyControl props={ props } />\n );\n\n}//end ContentVisibilityRSSFeedControl()\n\n/**\n * Render the <ContentVisibilityRSSFeedControl> component by adding\n * it to the block-visibility-extra-controls Fill.\n *\n * @return {Object} A Fill component wrapping the ContentVisibilityRSSFeedControl component.\n */\nfunction ContentVisibilityRSSFeedFill() {\n\n // Do not change the name attribute of this Fill. It is the name provided by the Content Visibility plugin.\n return (\n <Fill name=\"content-visibility-extra-controls\">\n {\n ( fillProps ) => {\n return (\n <ContentVisibilityRSSFeedControl props={ fillProps } />\n )\n }\n }\n </Fill>\n );\n\n}//end ContentVisibilityRSSFeedFill()\n\n// Add our component to the Slot provided by BlockVisibilityControls\n// The integer is an attempt to control the order of display of add-ons in the block sidebar. Higher = lower.\nregisterPlugin( 'content-visibility-6-rss-feed-fill', { render: ContentVisibilityRSSFeedFill } );\n\n\n// Register our visibility rule with the main plugin\naddFilter( 'contentVisibility.defaultContentVisibilityRules', 'content-visibility-rss-feed/block-visibility-rules', registerContentVisibilityRule );\n\n/**\n * Register our data key so that controls for this add-on have a place to store their data.\n * @param {*} defaultRules \n */\nfunction registerContentVisibilityRule( defaultRules ) {\n\n defaultRules.rssFeed = {};\n\n return defaultRules;\n\n}//end registerContentVisibilityRule()\n","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 'rssFeed':\n\n if ( props.attributes.contentVisibilityRules[type] && props.attributes.contentVisibilityRules[type]['rss'] === \"1\" ) {\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 CSS from the src directory. This will be built into /build/index.css by default.\nimport './styles/editor.css';\n\nimport ContentVisibilityRSSFeedControl from './controls/content-visibility-rss-feed';","// extracted by mini-css-extract-plugin","(function() { module.exports = window[\"wp\"][\"components\"]; }());","(function() { module.exports = window[\"wp\"][\"element\"]; }());","(function() { module.exports = window[\"wp\"][\"hooks\"]; }());","(function() { module.exports = window[\"wp\"][\"i18n\"]; }());","(function() { module.exports = window[\"wp\"][\"plugins\"]; }());"],"sourceRoot":""} -
content-visibility-rss-feed/trunk/content-visibility-rss-feed.php
r2506375 r2568523 12 12 * Plugin URI: https://richardtape.com/content-visibility/ 13 13 * Description: [Content Visibility Add-On] Show or hide your content for those folks consuming your content with RSS. 14 * Version: 0.1. 014 * Version: 0.1.2 15 15 * Author: Richard Tape 16 16 * Author URI: https://richardtape.com -
content-visibility-rss-feed/trunk/package.json
r2506375 r2568523 1 1 { 2 2 "name": "content-visibility-rss-feed", 3 "version": "0.1. 1",3 "version": "0.1.2", 4 4 "description": "As RSS Feed add-on for Content Visibility", 5 5 "main": "build/index.js", -
content-visibility-rss-feed/trunk/readme.txt
r2506375 r2568523 2 2 Contributors: iamfriendly 3 3 Donate link: https://girlswhocode.com/ 4 Tags: block, content, visibility, rss, feed, contentvisibility4 Tags: contentvisibility, block, content, visibility, rss, feed 5 5 Requires at least: 5.0 6 Tested up to: 5. 7.07 Stable tag: 0.1. 16 Tested up to: 5.8.0 7 Stable tag: 0.1.2 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 35 35 == Changelog == 36 36 37 = 0.1.2 = 38 * Added small icon to indicate when a block has RSS Feed rules. 39 * WP 5.8.0 compatibility. 40 37 41 = 0.1.1 = 38 42 * First public release. -
content-visibility-rss-feed/trunk/src/index.js
r2506375 r2568523 2 2 import './styles/editor.css'; 3 3 4 import ContentVisibilityRSSFeedControl from './controls/content-visibility- addon-starter';4 import ContentVisibilityRSSFeedControl from './controls/content-visibility-rss-feed';
Note: See TracChangeset
for help on using the changeset viewer.