<?php
/* Prohibit direct script loading */
defined('ABSPATH') || die('No direct script access allowed!');
if (!class_exists('WpmsProBrokenLinkTable')) {
    require_once(WPMETASEO_ADDON_PLUGIN_DIR . '/inc/class.metaseo-broken-link-table.php');
}

wp_enqueue_script('wplink');
wp_enqueue_style('editor-buttons');
wp_enqueue_style('metaseo-google-icon');
wp_enqueue_style('wpms-tippy-style');
wp_enqueue_script('wpms-tippy-core');
wp_enqueue_script('wpms-tippy');

$metaseo_list_table = new WpmsProBrokenLinkTable();
$metaseo_list_table->processAction();
$metaseo_list_table->prepare_items();
$a = json_encode($metaseo_list_table->items);

// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No action, nonce is not required
if (!empty($_REQUEST['_wp_http_referer'])) {
    wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
    exit;
}
?>

    <div class="wrap broken_link_table seo_extended_table_page">
        <div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
        <div class="wpms-popup-overlay"></div>
        <form id="wp-seo-meta-form" class="wpms-form-table" action="" method="post">
            <?php
            echo '<div class="table-heading flex" style="column-gap:10px;">';
            echo '<h3 style class="wpms-top-h1 wpms_left ju-inline-block">' . esc_html__('404 & Redirects', 'wpmsPro') . '
                <i class="material-icons intro-topic-tooltip" data-tippy="'.esc_html__('Search engines hates to index pages that returns a 404 error. The 404 and redirect manager index all your internal and external errors in order to make redirect. You can also make custom redirects for whatever the reason is', 'wpmsPro').'">help_outline</i>
            </h3>';
            ?>
            <button type="button" class="ju-button orange-button waves-effect waves-light wpms-small-btn wpms_add_custom_redirect m-tb-20 wpms-"
data-type="add_custom"><?php esc_html_e('Add custom url or rule', 'wpmsPro') ?></button>
            <?php
            $metaseo_list_table->btnFilter('m-tb-20');
            $metaseo_list_table->flushFilter('sl_flush', 'm-tb-20');
            echo '</div>';
            $metaseo_list_table->searchBox1(array('no_add_button' => true));
            $metaseo_list_table->brokenFilter('sl_broken[]');
            $metaseo_list_table->display(array('no_index'=>true, 'no_flush'=>true));
            ?>
        </form>

    </div>
<?php
wp_enqueue_script('wpms-broken-link');
?>