convert_to_screen example


function add_meta_box( $id$title$callback$screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
    global $wp_meta_boxes;

    if ( empty( $screen ) ) {
        $screen = get_current_screen();
    } elseif ( is_string( $screen ) ) {
        $screen = convert_to_screen( $screen );
    } elseif ( is_array( $screen ) ) {
        foreach ( $screen as $single_screen ) {
            add_meta_box( $id$title$callback$single_screen$context$priority$callback_args );
        }
    }

    if ( ! isset( $screen->id ) ) {
        return;
    }

    $page = $screen->id;

    
public function __construct( $args = array() ) {
        $args = wp_parse_args(
            $args,
            array(
                'plural'   => '',
                'singular' => '',
                'ajax'     => false,
                'screen'   => null,
            )
        );

        $this->screen = convert_to_screen( $args['screen'] );

        add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );

        if ( ! $args['plural'] ) {
            $args['plural'] = $this->screen->base;
        }

        $args['plural']   = sanitize_key( $args['plural'] );
        $args['singular'] = sanitize_key( $args['singular'] );

        $this->_args = $args;

        

function add_contextual_help( $screen$help ) {
    _deprecated_function( __FUNCTION__, '3.3.0', 'get_current_screen()->add_help_tab()' );

    if ( is_string( $screen ) )
        $screen = convert_to_screen( $screen );

    WP_Screen::add_old_compat_help( $screen$help );
}

/** * Get the allowed themes for the current site. * * @since 3.0.0 * @deprecated 3.4.0 Use wp_get_themes() * @see wp_get_themes() * * @return WP_Theme[] Array of WP_Theme objects keyed by their name. */

function get_column_headers( $screen ) {
    static $column_headers = array();

    if ( is_string( $screen ) ) {
        $screen = convert_to_screen( $screen );
    }

    if ( ! isset( $column_headers[ $screen->id ] ) ) {
        /** * Filters the column headers for a list table on a specific screen. * * The dynamic portion of the hook name, `$screen->id`, refers to the * ID of a specific screen. For example, the screen ID for the Posts * list table is edit-post, so the filter for that screen would be * manage_edit-post_columns. * * @since 3.0.0 * * @param string[] $columns The column header labels keyed by column ID. */
// Privacy requests tables.         'WP_Privacy_Data_Export_Requests_List_Table'  => 'privacy-data-export-requests',
        'WP_Privacy_Data_Removal_Requests_List_Table' => 'privacy-data-removal-requests',
    );

    if ( isset( $core_classes[ $class_name ] ) ) {
        foreach ( (array) $core_classes[ $class_name ] as $required ) {
            require_once ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php';
        }

        if ( isset( $args['screen'] ) ) {
            $args['screen'] = convert_to_screen( $args['screen'] );
        } elseif ( isset( $GLOBALS['hook_suffix'] ) ) {
            $args['screen'] = get_current_screen();
        } else {
            $args['screen'] = null;
        }

        /** * Filters the list table class to instantiate. * * @since 6.1.0 * * @param string $class_name The list table class to use. * @param array $args An array containing _get_list_table() arguments. */
/** * Constructor. * * @since 3.1.0 * * @param string|WP_Screen $screen The screen hook name or screen object. * @param string[] $columns An array of columns with column IDs as the keys * and translated column names as the values. */
    public function __construct( $screen$columns = array() ) {
        if ( is_string( $screen ) ) {
            $screen = convert_to_screen( $screen );
        }

        $this->_screen = $screen;

        if ( ! empty( $columns ) ) {
            $this->_columns = $columns;
            add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 );
        }
    }

    /** * Gets a list of all, hidden, and sortable columns. * * @since 3.1.0 * * @return array */
Home | Imprint | This part of the site doesn't use cookies.