post_type && 'edit' === $screen->base ) { add_filter( 'get_edit_post_link', [ $this, 'redirect_edit_link_to_global_injector' ], 10, 2 ); } } /** * Redirect edit post links to Global Injector page. * * This filter is only added on the copy-to-clipboard list table screen, * so we don't need to check post type here. * * Remove this method once the legacy post type editor is fully deprecated. * * @since 5.1.0 * * @param string $link The edit link. * @param int $post_id Post ID. * @return string Modified URL. */ public function redirect_edit_link_to_global_injector( $link, $post_id ) { return admin_url( 'options-general.php?page=ctc-global-injector&rule=' . $post_id ); } /** * Register custom post types. * * @since 5.1.0 */ public function register() { $labels = [ 'name' => __( 'Copy to Clipboard', 'ctc' ), 'singular_name' => __( 'Copy to Clipboard', 'ctc' ), 'add_new' => _x( 'Add New', 'ctc', 'ctc' ), 'add_new_item' => __( 'Add New', 'ctc' ), 'edit_item' => __( 'Edit Copy to Clipboard', 'ctc' ), 'new_item' => __( 'New Copy to Clipboard', 'ctc' ), 'view_item' => __( 'View Copy to Clipboard', 'ctc' ), 'search_items' => __( 'Search Copy to Clipboard', 'ctc' ), 'not_found' => __( 'No Copy to Clipboard found', 'ctc' ), 'not_found_in_trash' => __( 'No Copy to Clipboard found in Trash', 'ctc' ), 'parent_item_colon' => __( 'Parent Copy to Clipboard:', 'ctc' ), 'menu_name' => __( 'Copy to Clipboard', 'ctc' ), ]; $args = [ 'labels' => $labels, 'hierarchical' => false, 'description' => 'description', 'taxonomies' => [], 'public' => false, 'show_ui' => true, 'show_in_menu' => false, 'show_in_admin_bar' => false, 'menu_position' => null, 'menu_icon' => 'dashicons-clipboard', 'show_in_nav_menus' => true, 'publicly_queryable' => false, 'exclude_from_search' => false, 'has_archive' => false, 'query_var' => false, 'can_export' => true, 'rewrite' => false, 'capability_type' => 'post', 'supports' => [ 'title', ], ]; register_post_type( 'copy-to-clipboard', $args ); } }