Astra_Ext_Advanced_Hooks_Meta::sync_legacy_hook_meta( int|WP_Post $post )

Mirror the first multi-hook row into the legacy single-hook meta keys.


Description

Keeps ast-advanced-hook-action / ast-custom-hook in sync for code that still reads them. Runs after both the classic metabox save and a REST (block editor) save.


Parameters

$post

(Required) Post ID or object.


Return

(void)


Source

File: addons/advanced-hooks/classes/class-astra-ext-advanced-hooks-meta.php

		public static function sync_legacy_hook_meta( $post ) {
			$post_id = $post instanceof WP_Post ? $post->ID : (int) $post;
			if ( ! $post_id ) {
				return;
			}

			$rows = get_post_meta( $post_id, 'ast-advanced-hook-actions', true );
			if ( ! is_array( $rows ) || empty( $rows ) || ! isset( $rows[0]['action'] ) ) {
				return;
			}

			update_post_meta( $post_id, 'ast-advanced-hook-action', $rows[0]['action'] );

			if ( 'custom_hook' === $rows[0]['action'] && ! empty( $rows[0]['custom'] ) ) {
				update_post_meta( $post_id, 'ast-custom-hook', $rows[0]['custom'] );
			} else {
				delete_post_meta( $post_id, 'ast-custom-hook' );
			}
		}

Changelog

Changelog
Version Description
4.13.11 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.