ACF_Admin_Internal_Post_Type_List::check_activatepublicACF 6.0

Checks for the custom "Activate" bulk action.

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

Хуков нет.

Возвращает

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

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

$ACF_Admin_Internal_Post_Type_List = new ACF_Admin_Internal_Post_Type_List();
$ACF_Admin_Internal_Post_Type_List->check_activate();

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

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

Код ACF_Admin_Internal_Post_Type_List::check_activate() ACF 6.4.2

public function check_activate() {
	// Verify capability.
	if ( ! acf_current_user_can_admin() ) {
		return;
	}

	$args = acf_request_args(
		array(
			'acfactivatecomplete' => '',
			'acfactivate'         => '',
			'post'                => '',
			'action2'             => '',
		)
	);

	if ( ! empty( $args['acfactivatecomplete'] ) ) {
		check_admin_referer( 'bulk-posts' );

		$activated = array_map( 'intval', explode( ',', $args['acfactivatecomplete'] ) );
		$text      = $this->get_action_notice_text( 'acfactivatecomplete', count( $activated ) );
		$links     = array();

		foreach ( $activated as $activated_id ) {
			$links[] = sprintf(
				'<a href="%1$s">%2$s</a>',
				get_edit_post_link( $activated_id ),
				get_the_title( $activated_id )
			);
		}

		$text .= ' ' . implode( ', ', $links );

		// Add notice.
		acf_add_admin_notice( $text, 'success' );
		return;
	}

	// Find items to activate.
	$to_activate = array();
	if ( ! empty( $args['acfactivate'] ) ) {
		$to_activate[] = intval( $args['acfactivate'] );
	} elseif ( ! empty( $args['post'] ) && 'acfactivate' === $args['action2'] ) {
		$to_activate = array_map( 'intval', $args['post'] );
	}

	if ( ! empty( $to_activate ) ) {
		check_admin_referer( 'bulk-posts' );

		$activated_ids = array();
		$nonce         = wp_create_nonce( 'bulk-posts' );

		foreach ( $to_activate as $id ) {
			$post_type = get_post_type( $id );

			if ( $post_type && acf_update_internal_post_type_active_status( $id, true, $post_type ) ) {
				$activated_ids[] = $id;
			}
		}

		wp_safe_redirect( $this->get_admin_url( '&_wpnonce=' . $nonce . '&acfactivatecomplete=' . implode( ',', $activated_ids ) ) );
		exit;
	}
}