Need SPF
Cheers, Paul
Paul Barthmaier WordPress Developer +1.215.326.9063 pbrocks.com
On Sat, May 9, 2020 at 9:15 AM <file@pbrocks.work> wrote:
> > -TDlWFF*-yvS > >
Category: Reference
Categories
JavaScript Explained – Gitbook
Categories
Metabox js
/gutenberg/packages/edit-post/build/utils/meta-boxes.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getMetaBoxContainer = void 0;
/**
* Function returning the current Meta Boxes DOM Node in the editor
* whether the meta box area is opened or not.
* If the MetaBox Area is visible returns it, and returns the original container instead.
*
* @param {string} location Meta Box location.
* @return {string} HTML content.
*/
var getMetaBoxContainer = function getMetaBoxContainer(location) {
var area = document.querySelector(".edit-post-meta-boxes-area.is-".concat(location, " .metabox-location-").concat(location));
if (area) {
return area;
}
return document.querySelector('#metaboxes .metabox-location-' + location);
};
exports.getMetaBoxContainer = getMetaBoxContainer;
//# sourceMappingURL=meta-boxes.js.map
Categories
Grab Metaboxes
/gutenberg/packages/edit-post/build/store/selectors.js
exports.getActiveMetaBoxLocations = getActiveMetaBoxLocations;
function isMetaBoxLocationVisible(state, location) {
return isMetaBoxLocationActive(state, location) && (0, _lodash.some)(getMetaBoxesPerLocation(state, location), function (_ref) {
var id = _ref.id;
return isEditorPanelEnabled(state, "meta-box-".concat(id));
});
}
/**
* Returns true if there is an active meta box in the given location, or false
* otherwise.
*
* @param {Object} state Post editor state.
* @param {string} location Meta box location to test.
*
* @return {boolean} Whether the meta box location is active.
*/
function isMetaBoxLocationActive(state, location) {
var metaBoxes = getMetaBoxesPerLocation(state, location);
return !!metaBoxes && metaBoxes.length !== 0;
}
/**
* Returns the list of all the available meta boxes for a given location.
*
* @param {Object} state Global application state.
* @param {string} location Meta box location to test.
*
* @return {?Array} List of meta boxes.
*/
function getMetaBoxesPerLocation(state, location) {
return state.metaBoxes.locations[location];
}
/**
* Returns the list of all the available meta boxes.
*
* @param {Object} state Global application state.
*
* @return {Array} List of meta boxes.
*/
var getAllMetaBoxes = (0, _rememo.default)(function (state) {
return (0, _lodash.flatten)((0, _lodash.values)(state.metaBoxes.locations));
}, function (state) {
return [state.metaBoxes.locations];
});
/**
* Returns true if the post is using Meta Boxes
*
* @param {Object} state Global application state
*
* @return {boolean} Whether there are metaboxes or not.
*/
exports.getAllMetaBoxes = getAllMetaBoxes;
function hasMetaBoxes(state) {
return getActiveMetaBoxLocations(state).length > 0;
}
/**
* Returns true if the Meta Boxes are being saved.
*
* @param {Object} state Global application state.
*
* @return {boolean} Whether the metaboxes are being saved.
*/
function isSavingMetaBoxes(state) {
return state.metaBoxes.isSaving;
}
/**
* Reducer keeping track of the meta boxes isSaving state.
* A "true" value means the meta boxes saving request is in-flight.
*
*
* @param {boolean} state Previous state.
* @param {Object} action Action Object.
*
* @return {Object} Updated state.
*/
export function isSavingMetaBoxes( state = false, action ) {
switch ( action.type ) {
case 'REQUEST_META_BOX_UPDATES':
return true;
case 'META_BOX_UPDATES_SUCCESS':
return false;
default:
return state;
}
}
Categories
Make link grab post title
Categories
Hello world!
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!