AnsPress_Hooks::base_page_update( integer $post_id, object $post )

Description #

Flush rewrite rule if base page is updated.

Parameters #

  • $post_id
    integer (Required) Base page ID.
  • $post
    object (Required) Post object.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: includes/hooks.php

	public static function base_page_update( $post_id, $post ) {
		if ( wp_is_post_revision( $post ) ) {
			return;
		}

		$main_pages = array_keys( ap_main_pages() );
		$page_ids = [];

		foreach ( $main_pages as $slug ) {
			$page_ids[ ap_opt( $slug ) ] = $slug;
		}

		if ( in_array( $post_id, array_keys( $page_ids ) ) ) {
			$current_opt = $page_ids[ $post_id ];

			ap_opt( $current_opt, $post_id );
			ap_opt( $current_opt . '_id', $post->post_name );

			ap_opt( 'ap_flush', 'true' );
		}
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment