Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: editor.js
*/
[3000] Fix | Delete
const isEditedPostEmpty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
[3001] Fix | Delete
// While the condition of truthy content string is sufficient to determine
[3002] Fix | Delete
// emptiness, testing saveable blocks length is a trivial operation. Since
[3003] Fix | Delete
// this function can be called frequently, optimize for the fast case as a
[3004] Fix | Delete
// condition of the mere existence of blocks. Note that the value of edited
[3005] Fix | Delete
// content takes precedent over block content, and must fall through to the
[3006] Fix | Delete
// default logic.
[3007] Fix | Delete
const postId = getCurrentPostId(state);
[3008] Fix | Delete
const postType = getCurrentPostType(state);
[3009] Fix | Delete
const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
[3010] Fix | Delete
if (typeof record.content !== 'function') {
[3011] Fix | Delete
return !record.content;
[3012] Fix | Delete
}
[3013] Fix | Delete
const blocks = getEditedPostAttribute(state, 'blocks');
[3014] Fix | Delete
if (blocks.length === 0) {
[3015] Fix | Delete
return true;
[3016] Fix | Delete
}
[3017] Fix | Delete
[3018] Fix | Delete
// Pierce the abstraction of the serializer in knowing that blocks are
[3019] Fix | Delete
// joined with newlines such that even if every individual block
[3020] Fix | Delete
// produces an empty save result, the serialized content is non-empty.
[3021] Fix | Delete
if (blocks.length > 1) {
[3022] Fix | Delete
return false;
[3023] Fix | Delete
}
[3024] Fix | Delete
[3025] Fix | Delete
// There are two conditions under which the optimization cannot be
[3026] Fix | Delete
// assumed, and a fallthrough to getEditedPostContent must occur:
[3027] Fix | Delete
//
[3028] Fix | Delete
// 1. getBlocksForSerialization has special treatment in omitting a
[3029] Fix | Delete
// single unmodified default block.
[3030] Fix | Delete
// 2. Comment delimiters are omitted for a freeform or unregistered
[3031] Fix | Delete
// block in its serialization. The freeform block specifically may
[3032] Fix | Delete
// produce an empty string in its saved output.
[3033] Fix | Delete
//
[3034] Fix | Delete
// For all other content, the single block is assumed to make a post
[3035] Fix | Delete
// non-empty, if only by virtue of its own comment delimiters.
[3036] Fix | Delete
const blockName = blocks[0].name;
[3037] Fix | Delete
if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) {
[3038] Fix | Delete
return false;
[3039] Fix | Delete
}
[3040] Fix | Delete
return !getEditedPostContent(state);
[3041] Fix | Delete
});
[3042] Fix | Delete
[3043] Fix | Delete
/**
[3044] Fix | Delete
* Returns true if the post can be autosaved, or false otherwise.
[3045] Fix | Delete
*
[3046] Fix | Delete
* @param {Object} state Global application state.
[3047] Fix | Delete
* @param {Object} autosave A raw autosave object from the REST API.
[3048] Fix | Delete
*
[3049] Fix | Delete
* @return {boolean} Whether the post can be autosaved.
[3050] Fix | Delete
*/
[3051] Fix | Delete
const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
[3052] Fix | Delete
// A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
[3053] Fix | Delete
if (!isEditedPostSaveable(state)) {
[3054] Fix | Delete
return false;
[3055] Fix | Delete
}
[3056] Fix | Delete
[3057] Fix | Delete
// A post is not autosavable when there is a post autosave lock.
[3058] Fix | Delete
if (isPostAutosavingLocked(state)) {
[3059] Fix | Delete
return false;
[3060] Fix | Delete
}
[3061] Fix | Delete
const postType = getCurrentPostType(state);
[3062] Fix | Delete
[3063] Fix | Delete
// Currently template autosaving is not supported.
[3064] Fix | Delete
if (postType === 'wp_template') {
[3065] Fix | Delete
return false;
[3066] Fix | Delete
}
[3067] Fix | Delete
const postId = getCurrentPostId(state);
[3068] Fix | Delete
const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId);
[3069] Fix | Delete
const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
[3070] Fix | Delete
[3071] Fix | Delete
// Disable reason - this line causes the side-effect of fetching the autosave
[3072] Fix | Delete
// via a resolver, moving below the return would result in the autosave never
[3073] Fix | Delete
// being fetched.
[3074] Fix | Delete
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
[3075] Fix | Delete
const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
[3076] Fix | Delete
[3077] Fix | Delete
// If any existing autosaves have not yet been fetched, this function is
[3078] Fix | Delete
// unable to determine if the post is autosaveable, so return false.
[3079] Fix | Delete
if (!hasFetchedAutosave) {
[3080] Fix | Delete
return false;
[3081] Fix | Delete
}
[3082] Fix | Delete
[3083] Fix | Delete
// If we don't already have an autosave, the post is autosaveable.
[3084] Fix | Delete
if (!autosave) {
[3085] Fix | Delete
return true;
[3086] Fix | Delete
}
[3087] Fix | Delete
[3088] Fix | Delete
// To avoid an expensive content serialization, use the content dirtiness
[3089] Fix | Delete
// flag in place of content field comparison against the known autosave.
[3090] Fix | Delete
// This is not strictly accurate, and relies on a tolerance toward autosave
[3091] Fix | Delete
// request failures for unnecessary saves.
[3092] Fix | Delete
if (hasChangedContent(state)) {
[3093] Fix | Delete
return true;
[3094] Fix | Delete
}
[3095] Fix | Delete
[3096] Fix | Delete
// If title, excerpt, or meta have changed, the post is autosaveable.
[3097] Fix | Delete
return ['title', 'excerpt', 'meta'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field));
[3098] Fix | Delete
});
[3099] Fix | Delete
[3100] Fix | Delete
/**
[3101] Fix | Delete
* Return true if the post being edited is being scheduled. Preferring the
[3102] Fix | Delete
* unsaved status values.
[3103] Fix | Delete
*
[3104] Fix | Delete
* @param {Object} state Global application state.
[3105] Fix | Delete
*
[3106] Fix | Delete
* @return {boolean} Whether the post has been published.
[3107] Fix | Delete
*/
[3108] Fix | Delete
function isEditedPostBeingScheduled(state) {
[3109] Fix | Delete
const date = getEditedPostAttribute(state, 'date');
[3110] Fix | Delete
// Offset the date by one minute (network latency).
[3111] Fix | Delete
const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS);
[3112] Fix | Delete
return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate);
[3113] Fix | Delete
}
[3114] Fix | Delete
[3115] Fix | Delete
/**
[3116] Fix | Delete
* Returns whether the current post should be considered to have a "floating"
[3117] Fix | Delete
* date (i.e. that it would publish "Immediately" rather than at a set time).
[3118] Fix | Delete
*
[3119] Fix | Delete
* Unlike in the PHP backend, the REST API returns a full date string for posts
[3120] Fix | Delete
* where the 0000-00-00T00:00:00 placeholder is present in the database. To
[3121] Fix | Delete
* infer that a post is set to publish "Immediately" we check whether the date
[3122] Fix | Delete
* and modified date are the same.
[3123] Fix | Delete
*
[3124] Fix | Delete
* @param {Object} state Editor state.
[3125] Fix | Delete
*
[3126] Fix | Delete
* @return {boolean} Whether the edited post has a floating date value.
[3127] Fix | Delete
*/
[3128] Fix | Delete
function isEditedPostDateFloating(state) {
[3129] Fix | Delete
const date = getEditedPostAttribute(state, 'date');
[3130] Fix | Delete
const modified = getEditedPostAttribute(state, 'modified');
[3131] Fix | Delete
[3132] Fix | Delete
// This should be the status of the persisted post
[3133] Fix | Delete
// It shouldn't use the "edited" status otherwise it breaks the
[3134] Fix | Delete
// inferred post data floating status
[3135] Fix | Delete
// See https://github.com/WordPress/gutenberg/issues/28083.
[3136] Fix | Delete
const status = getCurrentPost(state).status;
[3137] Fix | Delete
if (status === 'draft' || status === 'auto-draft' || status === 'pending') {
[3138] Fix | Delete
return date === modified || date === null;
[3139] Fix | Delete
}
[3140] Fix | Delete
return false;
[3141] Fix | Delete
}
[3142] Fix | Delete
[3143] Fix | Delete
/**
[3144] Fix | Delete
* Returns true if the post is currently being deleted, or false otherwise.
[3145] Fix | Delete
*
[3146] Fix | Delete
* @param {Object} state Editor state.
[3147] Fix | Delete
*
[3148] Fix | Delete
* @return {boolean} Whether post is being deleted.
[3149] Fix | Delete
*/
[3150] Fix | Delete
function isDeletingPost(state) {
[3151] Fix | Delete
return !!state.deleting.pending;
[3152] Fix | Delete
}
[3153] Fix | Delete
[3154] Fix | Delete
/**
[3155] Fix | Delete
* Returns true if the post is currently being saved, or false otherwise.
[3156] Fix | Delete
*
[3157] Fix | Delete
* @param {Object} state Global application state.
[3158] Fix | Delete
*
[3159] Fix | Delete
* @return {boolean} Whether post is being saved.
[3160] Fix | Delete
*/
[3161] Fix | Delete
function isSavingPost(state) {
[3162] Fix | Delete
return !!state.saving.pending;
[3163] Fix | Delete
}
[3164] Fix | Delete
[3165] Fix | Delete
/**
[3166] Fix | Delete
* Returns true if non-post entities are currently being saved, or false otherwise.
[3167] Fix | Delete
*
[3168] Fix | Delete
* @param {Object} state Global application state.
[3169] Fix | Delete
*
[3170] Fix | Delete
* @return {boolean} Whether non-post entities are being saved.
[3171] Fix | Delete
*/
[3172] Fix | Delete
const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
[3173] Fix | Delete
const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved();
[3174] Fix | Delete
const {
[3175] Fix | Delete
type,
[3176] Fix | Delete
id
[3177] Fix | Delete
} = getCurrentPost(state);
[3178] Fix | Delete
return entitiesBeingSaved.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
[3179] Fix | Delete
});
[3180] Fix | Delete
[3181] Fix | Delete
/**
[3182] Fix | Delete
* Returns true if a previous post save was attempted successfully, or false
[3183] Fix | Delete
* otherwise.
[3184] Fix | Delete
*
[3185] Fix | Delete
* @param {Object} state Global application state.
[3186] Fix | Delete
*
[3187] Fix | Delete
* @return {boolean} Whether the post was saved successfully.
[3188] Fix | Delete
*/
[3189] Fix | Delete
const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
[3190] Fix | Delete
const postType = getCurrentPostType(state);
[3191] Fix | Delete
const postId = getCurrentPostId(state);
[3192] Fix | Delete
return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
[3193] Fix | Delete
});
[3194] Fix | Delete
[3195] Fix | Delete
/**
[3196] Fix | Delete
* Returns true if a previous post save was attempted but failed, or false
[3197] Fix | Delete
* otherwise.
[3198] Fix | Delete
*
[3199] Fix | Delete
* @param {Object} state Global application state.
[3200] Fix | Delete
*
[3201] Fix | Delete
* @return {boolean} Whether the post save failed.
[3202] Fix | Delete
*/
[3203] Fix | Delete
const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
[3204] Fix | Delete
const postType = getCurrentPostType(state);
[3205] Fix | Delete
const postId = getCurrentPostId(state);
[3206] Fix | Delete
return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
[3207] Fix | Delete
});
[3208] Fix | Delete
[3209] Fix | Delete
/**
[3210] Fix | Delete
* Returns true if the post is autosaving, or false otherwise.
[3211] Fix | Delete
*
[3212] Fix | Delete
* @param {Object} state Global application state.
[3213] Fix | Delete
*
[3214] Fix | Delete
* @return {boolean} Whether the post is autosaving.
[3215] Fix | Delete
*/
[3216] Fix | Delete
function isAutosavingPost(state) {
[3217] Fix | Delete
return isSavingPost(state) && Boolean(state.saving.options?.isAutosave);
[3218] Fix | Delete
}
[3219] Fix | Delete
[3220] Fix | Delete
/**
[3221] Fix | Delete
* Returns true if the post is being previewed, or false otherwise.
[3222] Fix | Delete
*
[3223] Fix | Delete
* @param {Object} state Global application state.
[3224] Fix | Delete
*
[3225] Fix | Delete
* @return {boolean} Whether the post is being previewed.
[3226] Fix | Delete
*/
[3227] Fix | Delete
function isPreviewingPost(state) {
[3228] Fix | Delete
return isSavingPost(state) && Boolean(state.saving.options?.isPreview);
[3229] Fix | Delete
}
[3230] Fix | Delete
[3231] Fix | Delete
/**
[3232] Fix | Delete
* Returns the post preview link
[3233] Fix | Delete
*
[3234] Fix | Delete
* @param {Object} state Global application state.
[3235] Fix | Delete
*
[3236] Fix | Delete
* @return {string | undefined} Preview Link.
[3237] Fix | Delete
*/
[3238] Fix | Delete
function getEditedPostPreviewLink(state) {
[3239] Fix | Delete
if (state.saving.pending || isSavingPost(state)) {
[3240] Fix | Delete
return;
[3241] Fix | Delete
}
[3242] Fix | Delete
let previewLink = getAutosaveAttribute(state, 'preview_link');
[3243] Fix | Delete
// Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
[3244] Fix | Delete
// If the post is draft, ignore the preview link from the autosave record,
[3245] Fix | Delete
// because the preview could be a stale autosave if the post was switched from
[3246] Fix | Delete
// published to draft.
[3247] Fix | Delete
// See: https://github.com/WordPress/gutenberg/pull/37952.
[3248] Fix | Delete
if (!previewLink || 'draft' === getCurrentPost(state).status) {
[3249] Fix | Delete
previewLink = getEditedPostAttribute(state, 'link');
[3250] Fix | Delete
if (previewLink) {
[3251] Fix | Delete
previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
[3252] Fix | Delete
preview: true
[3253] Fix | Delete
});
[3254] Fix | Delete
}
[3255] Fix | Delete
}
[3256] Fix | Delete
const featuredImageId = getEditedPostAttribute(state, 'featured_media');
[3257] Fix | Delete
if (previewLink && featuredImageId) {
[3258] Fix | Delete
return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
[3259] Fix | Delete
_thumbnail_id: featuredImageId
[3260] Fix | Delete
});
[3261] Fix | Delete
}
[3262] Fix | Delete
return previewLink;
[3263] Fix | Delete
}
[3264] Fix | Delete
[3265] Fix | Delete
/**
[3266] Fix | Delete
* Returns a suggested post format for the current post, inferred only if there
[3267] Fix | Delete
* is a single block within the post and it is of a type known to match a
[3268] Fix | Delete
* default post format. Returns null if the format cannot be determined.
[3269] Fix | Delete
*
[3270] Fix | Delete
* @return {?string} Suggested post format.
[3271] Fix | Delete
*/
[3272] Fix | Delete
const getSuggestedPostFormat = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
[3273] Fix | Delete
const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
[3274] Fix | Delete
if (blocks.length > 2) {
[3275] Fix | Delete
return null;
[3276] Fix | Delete
}
[3277] Fix | Delete
let name;
[3278] Fix | Delete
// If there is only one block in the content of the post grab its name
[3279] Fix | Delete
// so we can derive a suitable post format from it.
[3280] Fix | Delete
if (blocks.length === 1) {
[3281] Fix | Delete
name = blocks[0].name;
[3282] Fix | Delete
// Check for core/embed `video` and `audio` eligible suggestions.
[3283] Fix | Delete
if (name === 'core/embed') {
[3284] Fix | Delete
const provider = blocks[0].attributes?.providerNameSlug;
[3285] Fix | Delete
if (['youtube', 'vimeo'].includes(provider)) {
[3286] Fix | Delete
name = 'core/video';
[3287] Fix | Delete
} else if (['spotify', 'soundcloud'].includes(provider)) {
[3288] Fix | Delete
name = 'core/audio';
[3289] Fix | Delete
}
[3290] Fix | Delete
}
[3291] Fix | Delete
}
[3292] Fix | Delete
[3293] Fix | Delete
// If there are two blocks in the content and the last one is a text blocks
[3294] Fix | Delete
// grab the name of the first one to also suggest a post format from it.
[3295] Fix | Delete
if (blocks.length === 2 && blocks[1].name === 'core/paragraph') {
[3296] Fix | Delete
name = blocks[0].name;
[3297] Fix | Delete
}
[3298] Fix | Delete
[3299] Fix | Delete
// We only convert to default post formats in core.
[3300] Fix | Delete
switch (name) {
[3301] Fix | Delete
case 'core/image':
[3302] Fix | Delete
return 'image';
[3303] Fix | Delete
case 'core/quote':
[3304] Fix | Delete
case 'core/pullquote':
[3305] Fix | Delete
return 'quote';
[3306] Fix | Delete
case 'core/gallery':
[3307] Fix | Delete
return 'gallery';
[3308] Fix | Delete
case 'core/video':
[3309] Fix | Delete
return 'video';
[3310] Fix | Delete
case 'core/audio':
[3311] Fix | Delete
return 'audio';
[3312] Fix | Delete
default:
[3313] Fix | Delete
return null;
[3314] Fix | Delete
}
[3315] Fix | Delete
});
[3316] Fix | Delete
[3317] Fix | Delete
/**
[3318] Fix | Delete
* Returns the content of the post being edited.
[3319] Fix | Delete
*
[3320] Fix | Delete
* @param {Object} state Global application state.
[3321] Fix | Delete
*
[3322] Fix | Delete
* @return {string} Post content.
[3323] Fix | Delete
*/
[3324] Fix | Delete
const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
[3325] Fix | Delete
const postId = getCurrentPostId(state);
[3326] Fix | Delete
const postType = getCurrentPostType(state);
[3327] Fix | Delete
const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
[3328] Fix | Delete
if (record) {
[3329] Fix | Delete
if (typeof record.content === 'function') {
[3330] Fix | Delete
return record.content(record);
[3331] Fix | Delete
} else if (record.blocks) {
[3332] Fix | Delete
return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
[3333] Fix | Delete
} else if (record.content) {
[3334] Fix | Delete
return record.content;
[3335] Fix | Delete
}
[3336] Fix | Delete
}
[3337] Fix | Delete
return '';
[3338] Fix | Delete
});
[3339] Fix | Delete
[3340] Fix | Delete
/**
[3341] Fix | Delete
* Returns true if the post is being published, or false otherwise.
[3342] Fix | Delete
*
[3343] Fix | Delete
* @param {Object} state Global application state.
[3344] Fix | Delete
*
[3345] Fix | Delete
* @return {boolean} Whether post is being published.
[3346] Fix | Delete
*/
[3347] Fix | Delete
function isPublishingPost(state) {
[3348] Fix | Delete
return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish';
[3349] Fix | Delete
}
[3350] Fix | Delete
[3351] Fix | Delete
/**
[3352] Fix | Delete
* Returns whether the permalink is editable or not.
[3353] Fix | Delete
*
[3354] Fix | Delete
* @param {Object} state Editor state.
[3355] Fix | Delete
*
[3356] Fix | Delete
* @return {boolean} Whether or not the permalink is editable.
[3357] Fix | Delete
*/
[3358] Fix | Delete
function isPermalinkEditable(state) {
[3359] Fix | Delete
const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
[3360] Fix | Delete
return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
[3361] Fix | Delete
}
[3362] Fix | Delete
[3363] Fix | Delete
/**
[3364] Fix | Delete
* Returns the permalink for the post.
[3365] Fix | Delete
*
[3366] Fix | Delete
* @param {Object} state Editor state.
[3367] Fix | Delete
*
[3368] Fix | Delete
* @return {?string} The permalink, or null if the post is not viewable.
[3369] Fix | Delete
*/
[3370] Fix | Delete
function getPermalink(state) {
[3371] Fix | Delete
const permalinkParts = getPermalinkParts(state);
[3372] Fix | Delete
if (!permalinkParts) {
[3373] Fix | Delete
return null;
[3374] Fix | Delete
}
[3375] Fix | Delete
const {
[3376] Fix | Delete
prefix,
[3377] Fix | Delete
postName,
[3378] Fix | Delete
suffix
[3379] Fix | Delete
} = permalinkParts;
[3380] Fix | Delete
if (isPermalinkEditable(state)) {
[3381] Fix | Delete
return prefix + postName + suffix;
[3382] Fix | Delete
}
[3383] Fix | Delete
return prefix;
[3384] Fix | Delete
}
[3385] Fix | Delete
[3386] Fix | Delete
/**
[3387] Fix | Delete
* Returns the slug for the post being edited, preferring a manually edited
[3388] Fix | Delete
* value if one exists, then a sanitized version of the current post title, and
[3389] Fix | Delete
* finally the post ID.
[3390] Fix | Delete
*
[3391] Fix | Delete
* @param {Object} state Editor state.
[3392] Fix | Delete
*
[3393] Fix | Delete
* @return {string} The current slug to be displayed in the editor
[3394] Fix | Delete
*/
[3395] Fix | Delete
function getEditedPostSlug(state) {
[3396] Fix | Delete
return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state);
[3397] Fix | Delete
}
[3398] Fix | Delete
[3399] Fix | Delete
/**
[3400] Fix | Delete
* Returns the permalink for a post, split into its three parts: the prefix,
[3401] Fix | Delete
* the postName, and the suffix.
[3402] Fix | Delete
*
[3403] Fix | Delete
* @param {Object} state Editor state.
[3404] Fix | Delete
*
[3405] Fix | Delete
* @return {Object} An object containing the prefix, postName, and suffix for
[3406] Fix | Delete
* the permalink, or null if the post is not viewable.
[3407] Fix | Delete
*/
[3408] Fix | Delete
function getPermalinkParts(state) {
[3409] Fix | Delete
const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
[3410] Fix | Delete
if (!permalinkTemplate) {
[3411] Fix | Delete
return null;
[3412] Fix | Delete
}
[3413] Fix | Delete
const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug');
[3414] Fix | Delete
const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
[3415] Fix | Delete
return {
[3416] Fix | Delete
prefix,
[3417] Fix | Delete
postName,
[3418] Fix | Delete
suffix
[3419] Fix | Delete
};
[3420] Fix | Delete
}
[3421] Fix | Delete
[3422] Fix | Delete
/**
[3423] Fix | Delete
* Returns whether the post is locked.
[3424] Fix | Delete
*
[3425] Fix | Delete
* @param {Object} state Global application state.
[3426] Fix | Delete
*
[3427] Fix | Delete
* @return {boolean} Is locked.
[3428] Fix | Delete
*/
[3429] Fix | Delete
function isPostLocked(state) {
[3430] Fix | Delete
return state.postLock.isLocked;
[3431] Fix | Delete
}
[3432] Fix | Delete
[3433] Fix | Delete
/**
[3434] Fix | Delete
* Returns whether post saving is locked.
[3435] Fix | Delete
*
[3436] Fix | Delete
* @param {Object} state Global application state.
[3437] Fix | Delete
*
[3438] Fix | Delete
* @return {boolean} Is locked.
[3439] Fix | Delete
*/
[3440] Fix | Delete
function isPostSavingLocked(state) {
[3441] Fix | Delete
return Object.keys(state.postSavingLock).length > 0;
[3442] Fix | Delete
}
[3443] Fix | Delete
[3444] Fix | Delete
/**
[3445] Fix | Delete
* Returns whether post autosaving is locked.
[3446] Fix | Delete
*
[3447] Fix | Delete
* @param {Object} state Global application state.
[3448] Fix | Delete
*
[3449] Fix | Delete
* @return {boolean} Is locked.
[3450] Fix | Delete
*/
[3451] Fix | Delete
function isPostAutosavingLocked(state) {
[3452] Fix | Delete
return Object.keys(state.postAutosavingLock).length > 0;
[3453] Fix | Delete
}
[3454] Fix | Delete
[3455] Fix | Delete
/**
[3456] Fix | Delete
* Returns whether the edition of the post has been taken over.
[3457] Fix | Delete
*
[3458] Fix | Delete
* @param {Object} state Global application state.
[3459] Fix | Delete
*
[3460] Fix | Delete
* @return {boolean} Is post lock takeover.
[3461] Fix | Delete
*/
[3462] Fix | Delete
function isPostLockTakeover(state) {
[3463] Fix | Delete
return state.postLock.isTakeover;
[3464] Fix | Delete
}
[3465] Fix | Delete
[3466] Fix | Delete
/**
[3467] Fix | Delete
* Returns details about the post lock user.
[3468] Fix | Delete
*
[3469] Fix | Delete
* @param {Object} state Global application state.
[3470] Fix | Delete
*
[3471] Fix | Delete
* @return {Object} A user object.
[3472] Fix | Delete
*/
[3473] Fix | Delete
function getPostLockUser(state) {
[3474] Fix | Delete
return state.postLock.user;
[3475] Fix | Delete
}
[3476] Fix | Delete
[3477] Fix | Delete
/**
[3478] Fix | Delete
* Returns the active post lock.
[3479] Fix | Delete
*
[3480] Fix | Delete
* @param {Object} state Global application state.
[3481] Fix | Delete
*
[3482] Fix | Delete
* @return {Object} The lock object.
[3483] Fix | Delete
*/
[3484] Fix | Delete
function getActivePostLock(state) {
[3485] Fix | Delete
return state.postLock.activePostLock;
[3486] Fix | Delete
}
[3487] Fix | Delete
[3488] Fix | Delete
/**
[3489] Fix | Delete
* Returns whether or not the user has the unfiltered_html capability.
[3490] Fix | Delete
*
[3491] Fix | Delete
* @param {Object} state Editor state.
[3492] Fix | Delete
*
[3493] Fix | Delete
* @return {boolean} Whether the user can or can't post unfiltered HTML.
[3494] Fix | Delete
*/
[3495] Fix | Delete
function canUserUseUnfilteredHTML(state) {
[3496] Fix | Delete
return Boolean(getCurrentPost(state)._links?.hasOwnProperty('wp:action-unfiltered-html'));
[3497] Fix | Delete
}
[3498] Fix | Delete
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function