Adds check for permalinks structure before loading the Tainacan Admin.

This commit is contained in:
mateuswetah 2024-06-26 15:57:56 -03:00
parent 479976e399
commit fdaf1cf9a3
4 changed files with 88 additions and 52 deletions

View File

@ -5,6 +5,7 @@
:class="{
'tainacan-admin-mobile-app-mode': $adminOptions.mobileAppMode
}">
<template v-if="hasPermalinksStructure">
<template v-if="activeRoute == 'HomePage'">
<tainacan-header v-if="!$adminOptions.hideTainacanHeader" />
<router-view />
@ -46,6 +47,7 @@
<router-view />
</div>
</template>
</template>
</div>
</template>
@ -70,7 +72,8 @@
return {
isMenuCompressed: false,
isRepositoryLevel : true,
activeRoute: '/collections'
activeRoute: '/collections',
hasPermalinksStructure: false
}
},
computed: {
@ -105,6 +108,10 @@
}
},
created() {
this.hasPermalinksStructure = tainacan_plugin.has_permalinks_structure;
if ( this.hasPermalinksStructure ) {
this.$statusHelper.loadStatuses();
this.$userPrefs.init();
this.isMenuCompressed = (this.$route.params.collectionId != undefined);
@ -114,10 +121,31 @@
if (jQuery && jQuery( document )) {
jQuery( document ).ajaxError(this.onHeartBitError);
}
} else {
this.onPermalinksError();
}
},
methods: {
onPermalinksError() {
this.$buefy.modal.open({
component: CustomDialog,
props: {
title: this.$i18n.get('error_permalinks_label'),
message: this.$i18n.getWithVariables('error_permalinks_detail', [ '<a href="' + tainacan_plugin.admin_url + 'options-permalink.php">', '</a>' ]),
hideCancel: true,
confirmText: this.$i18n.get('label_go_to_permalinks'),
onConfirm: () => {
window.location.href = tainacan_plugin.admin_url + 'options-permalink.php';
}
},
ariaRole: 'alertdialog',
ariaModal: true,
customClass: 'tainacan-modal',
canCancel: false,
});
},
onHeartBitError(event, jqxhr, settings) {
if (settings && settings.url == '/wp-admin/admin-ajax.php') {
if (settings && settings.url == tainacan_plugin.admin_url + 'admin-ajax.php') {
this.$buefy.snackbar.open({
message: this.$i18n.get('error_connectivity'),
type: 'is-danger',

View File

@ -51,7 +51,7 @@
type="submit"
class="button is-success"
@click="onConfirm(); $emit('close');">
{{ $i18n.get('continue') }}
{{ confirmText ? confirmText : $i18n.get('continue') }}
</button>
</footer>
</div>
@ -66,6 +66,10 @@
title: String,
message: String,
icon: String,
confirmText: {
type: String,
default: ''
},
onConfirm: {
type: Function,
default: () => {}

View File

@ -354,7 +354,8 @@ class Admin {
'wp_elasticpress' => \Tainacan\Elastic_Press::get_instance()->is_active(),
'item_submission_captcha_site_key' => get_option("tnc_option_recaptch_site_key"),
'tainacan_enable_core_metadata_on_advanced_search' => ( !defined('TAINACAN_DISABLE_CORE_METADATA_ON_ADVANCED_SEARCH') || false === TAINACAN_DISABLE_CORE_METADATA_ON_ADVANCED_SEARCH ),
'tainacan_enable_relationship_metaquery' => ( defined('TAINACAN_ENABLE_RELATIONSHIP_METAQUERY') && true === TAINACAN_ENABLE_RELATIONSHIP_METAQUERY )
'tainacan_enable_relationship_metaquery' => ( defined('TAINACAN_ENABLE_RELATIONSHIP_METAQUERY') && true === TAINACAN_ENABLE_RELATIONSHIP_METAQUERY ),
'has_permalinks_structure' => get_option('permalink_structure') !== ''
];
$maps = [

View File

@ -709,6 +709,7 @@ return apply_filters( 'tainacan-i18n', [
'label_item_submission_options' => __( 'Item submission options', 'tainacan' ),
'label_metadata_related_features' => __( 'Metadata related features', 'tainacan' ),
'label_preview' => __( 'Preview', 'tainacan' ),
'label_go_to_permalinks' => __( 'Go to permalinks', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
@ -1118,6 +1119,7 @@ return apply_filters( 'tainacan-i18n', [
/* Errors displayed on the interface bottom notifications */
'error_connectivity_label' => __('Connectivity issue', 'tainacan'),
'error_connectivity' => __('It is possible that you are disconnected or the server is not working properly.', 'tainacan'),
'error_permalinks_label' => __('Permalinks issue', 'tainacan'),
'error_400' => __('Some request went wrong due to invalid syntax.', 'tainacan'),
'error_401' => __('You must authenticate to access this information. Try logging in again on the WordPress Admin panel.', 'tainacan'),
'error_403' => __('It seems that you are not allowed to access this content.', 'tainacan'),
@ -1130,6 +1132,7 @@ return apply_filters( 'tainacan-i18n', [
'error_511' => __('You must authenticate to get access this information. Try logging in again on the WordPress Admin panel.', 'tainacan'),
'error_other' => __('Something went wrong here. You may want to try again or contact the Administrator.', 'tainacan'),
'error_connectivity_detail' => __('The WordPress Heartbit API sends requests periodically to the server to update some information. The latest request failed for some reason. It can be the case of a lost connection or bad communication between the browser and the server.', 'tainacan'),
'error_permalinks_detail' => __( 'Tainacan requires your Permalink settings to be configured. Please visit %sPermalink settings%s and define it to an option such as "postname".', 'tainacan' ),
'error_400_detail' => __('The server could not understand the request due to invalid syntax. This is possibly an issue with Tainacan and should be reported to its developers.', 'tainacan'),
'error_401_detail' => __('You must authenticate to get access this information. Even if you have access to the Tainacan admin panel, it may be the case that your session cookies were lost. Try reloading the page or logging again on the WordPress Admin panel.', 'tainacan'),
'error_403_detail' => __('It seems that you are not allowed to access this content. Your user might have a role with insufficient capabilities. If that is not the case, check if you are correctly logged in on the WordPress Admin panel.', 'tainacan'),