WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wp_xmlrpc_server::_toggle_sticky() WP 4.3.0

Encapsulate the logic for sticking a post and determining if the user has permission to do so

Это метод класса: wp_xmlrpc_server

Хуков нет.

Возвращает

null/IXR_Error.

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

$wp_xmlrpc_server = new wp_xmlrpc_server();
$var = $wp_xmlrpc_server->_toggle_sticky( $post_data, $update );
$post_data(массив) (обязательный)
$update(true/false)

По умолчанию: false

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

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

Код wp xmlrpc server:: toggle sticky: wp-includes/class-wp-xmlrpc-server.php WP 5.4.2

<?php
private function _toggle_sticky( $post_data, $update = false ) {
	$post_type = get_post_type_object( $post_data['post_type'] );

	// Private and password-protected posts cannot be stickied.
	if ( 'private' === $post_data['post_status'] || ! empty( $post_data['post_password'] ) ) {
		// Error if the client tried to stick the post, otherwise, silently unstick.
		if ( ! empty( $post_data['sticky'] ) ) {
			return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) );
		}

		if ( $update ) {
			unstick_post( $post_data['ID'] );
		}
	} elseif ( isset( $post_data['sticky'] ) ) {
		if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to make posts sticky.' ) );
		}

		$sticky = wp_validate_boolean( $post_data['sticky'] );
		if ( $sticky ) {
			stick_post( $post_data['ID'] );
		} else {
			unstick_post( $post_data['ID'] );
		}
	}
}