WP_List_Table::__construct()publicWP 3.1.0

Constructor.

The child class should call this constructor from its own constructor to override the default $args.

Метод класса: WP_List_Table{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_List_Table = new WP_List_Table();
$WP_List_Table->__construct( $args );
$args(массив|строка)

Array or string of arguments.

По умолчанию: array()

  • plural(строка)
    Plural value used for labels and the objects being listed. This affects things such as CSS class-names and nonces used in the list table, e.g. 'posts'.
    По умолчанию: ''

  • singular(строка)
    Singular label for an object being listed, e.g. 'post'. Default empty

  • ajax(true|false)
    Whether the list table supports Ajax. This includes loading and sorting data, for example. If true, the class will call the _js_vars() method in the footer to provide variables to any scripts handling Ajax events.
    По умолчанию: false

  • screen(строка)
    String containing the hook name used to determine the current screen. If left null, the current screen will be automatically set.
    По умолчанию: null

Список изменений

С версии 3.1.0 Введена.

Код WP_List_Table::__construct() WP 6.5.2

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;

	if ( $args['ajax'] ) {
		// wp_enqueue_script( 'list-table' );
		add_action( 'admin_footer', array( $this, '_js_vars' ) );
	}

	if ( empty( $this->modes ) ) {
		$this->modes = array(
			'list'    => __( 'Compact view' ),
			'excerpt' => __( 'Extended view' ),
		);
	}
}