public function brokenLinksColumnSorting()
    {
        add_filter('posts_fields', function ($fields, $query) {
            if ($query->get('orderby') !== 'broken-links') {
                return $fields;
            }

            global $wpdb;

            $fields .= ", (
                SELECT COUNT(*)
                FROM " . self::$dbTable . "
                WHERE post_id = {$wpdb->posts}.ID
            ) AS broken_links_count";

            return $fields;
        }, 10, 2);

        add_filter('posts_orderby', function ($orderby, $query) {
            if ($query->get('orderby') !== 'broken-links') {
                return $orderby;
            }

            $orderby = "broken_links_count {$query->get('order')}, " . $orderby;
            return $orderby;
        }, 10, 2);
    }
public function brokenLinksColumnSorting()
    {
        add_filter('posts_fields', function ($fields, $query) {
            if ($query->get('orderby') !== 'broken-links') {
                return $fields;
            }

            global $wpdb;

            $fields .= ", (
                SELECT COUNT(*)
                FROM " . self::$dbTable . "
                WHERE post_id = {$wpdb->posts}.ID
            ) AS broken_links_count";

            return $fields;
        }, 10, 2);

        add_filter('posts_orderby', function ($orderby, $query) {
            if ($query->get('orderby') !== 'broken-links') {
                return $orderby;
            }

            $orderby = "broken_links_count {$query->get('order')}, " . $orderby;
            return $orderby;
        }, 10, 2);
    }
public function brokenLinksColumnSorting ( ) { add_filter ( 'posts_fields' , function ( $ fields , $ query ) { if ( $ query -> get ( 'orderby' ) !== 'broken-links' ) { return $ fields ; } global $ wpdb ; $ fields .= ", (
                SELECT COUNT(*)
                FROM " . self :: $ dbTable . "
                WHERE post_id = {$wpdb->posts}.ID
            ) AS broken_links_count" ; return $ fields ; } , 10 , 2 ) ; add_filter ( 'posts_orderby' , function ( $ orderby , $ query ) { if ( $ query -> get ( 'orderby' ) !== 'broken-links' ) { return $ orderby ; } $ orderby = "broken_links_count {$query->get('order')}, " . $ orderby ; return $ orderby ; } , 10 , 2 ) ; }
Sort post if sorting on broken-links column
@return void
Sort post if sorting on broken - links column