Setseasy_svg_pro_set_screen_redirect

easy_svg_pro_set_screen_redirect

Keep the classic edit screen for icon sets, or send published and new sets to the icon library grid in the Icons panel, per set or for everyone.

Filter · Easy SVG Pro · Status: Stable

When you open a published icon set, or click "Add Icon Set", Easy SVG Pro does not show the classic WordPress edit screen. It sends you to the grid in the Icons panel, where every set and icon lives in one place. This filter decides whether that hand over happens. Return false and the set opens on its own edit screen, with the set editor below the title.

Usage

apply_filters( 'easy_svg_pro_set_screen_redirect', bool $redirect, WP_Post|null $post )

Applied in includes/editor/editor-screen.php, inside set_screen_redirect(), which runs on load-post.php and load-post-new.php.

When to use it

  • Your team is used to the classic set screen and you want to keep it while people get used to the grid.
  • A custom workflow needs the post screen: your own meta boxes on easy_svg_set, an editorial plugin that adds a panel to post screens, or a screenshot based handbook.
  • You want the redirect only for some sets, for example keep the classic screen for one locked brand set.
  • You debug the set editor and want the post screen without the redirect.

Do not use it when:

  • You want to change what happens to drafts. A draft always stays on the set screen and this filter is not even asked (see Pitfalls).
  • You want to hide the grid. Returning false only stops the redirect; the Icons panel and its grid are unchanged.

Parameters

body
$redirectbool
Required

Always true when the filter runs. The filter is only asked when a redirect would actually happen.

body
$postWP_Post|null
Required

The published set being opened, or null when a new set is being created on post-new.php?post_type=easy_svg_set.

Return value

returnbool

true (or any truthy value) sends the browser to the grid. false (or any falsy value) shows the classic set screen.

Default

true: published and new sets open in the grid.

Examples

Keep the classic screen everywhere

add_filter( 'easy_svg_pro_set_screen_redirect', '__return_false' );

Classic screen for new sets, grid for existing ones

/**
 * Create sets on the post screen, edit them in the grid.
 */
function acme_new_sets_on_post_screen( $redirect, $post ) {
	return null === $post ? false : $redirect;
}
add_filter( 'easy_svg_pro_set_screen_redirect', 'acme_new_sets_on_post_screen', 10, 2 );

One locked brand set stays on its own screen

/**
 * The ACME brand set has its own approval meta box, which lives on the post screen.
 */
function acme_keep_brand_set_classic( $redirect, $post ) {
	if ( $post instanceof WP_Post && 'acme-brand' === $post->post_name ) {
		return false;
	}

	return $redirect;
}
add_filter( 'easy_svg_pro_set_screen_redirect', 'acme_keep_brand_set_classic', 10, 2 );

Defensive: a switch you can flip from wp-config.php

/**
 * define( 'ACME_CLASSIC_SET_SCREEN', true ); in wp-config.php keeps the old screen.
 */
function acme_classic_set_screen_switch( $redirect ) {
	if ( defined( 'ACME_CLASSIC_SET_SCREEN' ) && ACME_CLASSIC_SET_SCREEN ) {
		return false;
	}

	return $redirect;
}
add_filter( 'easy_svg_pro_set_screen_redirect', 'acme_classic_set_screen_switch' );

How it works

On load-post.php and load-post-new.php Easy SVG Pro checks, in this order:

  1. The licence is active and Icon set editor is on under Icons → Features, and the current user has manage_options. Otherwise nothing happens.
  2. The request is a GET for the easy_svg_set post type. Saving, trashing and every POST pass through untouched, so post.php keeps working for those.
  3. On post-new.php: the target is the grid, asked to start a new set.
  4. On post.php: the action is edit, the set is published and it has a collection slug. Drafts, pending and private sets stay on the set screen.
  5. Only now this filter is asked, with true. If it returns something truthy, the browser goes to admin.php?page=easy-svg-icons&tab=library plus collection=<slug> for an existing set or new-set=1 for a new one, and the request ends.

The slug in the address is the registered collection slug, which on older sites can end in -x and differ from the post slug.

Pitfalls

  • You cannot force a redirect for drafts. For drafts, POST requests and other post types the filter is never called, so returning true there has no effect. The grid lists published sets only.
  • Your own redirect wins first. If another plugin redirects on load-post.php at an earlier priority, this filter may never run.
  • The grid link in the list stays. The "Open in the library" row action on the set list is added separately and is not affected by this filter.
  • Only for people with manage_options. Other users never reach the set screen anyway: every capability of the easy_svg_set post type maps to manage_options.