Tribe__Events__Main::render_notice_archive_slug_conflict()
Displays the Archive conflict notice using Tribe__Admin__Notices code
Return
(string)
Source
File: src/Tribe/Main.php
public function render_notice_archive_slug_conflict() {
// translators: For compatibility with WPML and other multilingual plugins, not to be translated directly on .mo files.
$archive_slug = _x( Tribe__Settings_Manager::get_option( 'eventsSlug', 'events' ), 'Archive Events Slug', 'the-events-calendar' );
$conflict_query = new WP_Query( array(
'name' => $archive_slug,
'post_type' => 'any',
'post_status' => array( 'publish', 'private', 'inherit' ),
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'posts_per_page' => 1,
'post_parent' => 0,
) );
if ( ! $conflict_query->have_posts() ) {
return false;
}
// Set the Conflicted Post
$conflict = $conflict_query->post;
// Fetch the Post Type and Post Name
$post_type = get_post_type_object( $conflict->post_type );
$name = empty( $post_type->labels->singular_name ) ? ucfirst( $conflict->post_type ) : $post_type->labels->singular_name;
// What's happening?
$page_title = apply_filters( 'the_title', $conflict->post_title, $conflict->ID );
$line_1 = sprintf( __( 'The %3$s "%1$s" uses the "/%2$s" slug: the Events Calendar plugin will show its calendar in place of the page.', 'the-events-calendar' ), $page_title, $archive_slug, $name );
// What the user can do
$edit_post_link = sprintf( __( 'Ask the site administrator to edit the %s slug', 'the-events-calendar' ), $name );
if ( isset( $post_type->cap->edit_posts ) && current_user_can( $post_type->cap->edit_posts ) ) {
$edit_post_link = sprintf( '<a href="%1$s">%2$s</a>', get_edit_post_link( $conflict->ID ), sprintf( __( 'Edit the %s slug', 'the-events-calendar' ), $name ) );
}
$settings_cap = apply_filters( 'tribe_settings_req_cap', 'manage_options' );
$edit_settings_link = __( ' ask the site administrator set a different Events URL slug.', 'the-events-calendar' );
if ( current_user_can( $settings_cap ) ) {
$admin_slug = apply_filters( 'tribe_settings_admin_slug', 'tribe-common' );
$setting_page_link = apply_filters( 'tribe_settings_url', admin_url( 'edit.php?page=' . $admin_slug . '#tribe-field-eventsSlug' ) );
$edit_settings_link = sprintf( '<a href="%1$s">%2$s</a>', $setting_page_link, __( 'edit Events settings.', 'the-events-calendar' ) );
}
$line_2 = sprintf( __( '%1$s or %2$s', 'the-events-calendar' ), $edit_post_link, $edit_settings_link );
return Tribe__Admin__Notices::instance()->render( 'archive-slug-conflict', sprintf( '<p>%s</p><p>%s</p>', $line_1, $line_2 ) );
}