Payments_Tab::create_page_with_shortcode( string $page_slug, string $page_name, string $shortcode_name )

Create a page with given properties.


Parameters

$page_slug

(string) (Required) URL slug of the page.

$page_name

(string) (Required) Name for page title.

$shortcode_name

(string) (Required) Shortcode name that needs to be inserted in page content.


Top ↑

Return

(int|bool|WP_Error)


Top ↑

Source

File: src/Tickets/Commerce/Payments_Tab.php

	public function create_page_with_shortcode( $page_slug, $page_name, $shortcode_name ) {

		if ( ! current_user_can( 'edit_pages' ) ) {
			return false;
		};

		$page_data = [
			'post_status'    => 'publish',
			'post_type'      => 'page',
			'post_author'    => get_current_user_id(),
			'post_name'      => $page_slug,
			'post_title'     => $page_name,
			'post_content'   => '<!-- wp:shortcode -->[' . $shortcode_name . ']<!-- /wp:shortcode -->',
			'post_parent'    => 0,
			'comment_status' => 'closed',
			'meta_input'     => [
				static::$option_page_created_meta_key => $shortcode_name,
			],
		];

		return wp_insert_post( $page_data );
	}

Top ↑

Changelog

Changelog
Version Description
5.2.1 Introduced.