Astra_Polylang_Compatibility::block_polylang_meta_updates( mixed $check, int $object_id, string $meta_key, mixed $meta_value, mixed $prev_value )

Block Polylang from updating display condition metas during sync operations.


Description

This prevents Polylang’s PLL_Sync class from updating display conditions


Parameters

$check

(mixed) (Required) Whether to allow the meta update.

$object_id

(int) (Required) Post ID.

$meta_key

(string) (Required) Meta key.

$meta_value

(mixed) (Required) Meta value.

$prev_value

(mixed) (Required) Previous meta value.


Return

(mixed) True to block the update, null to allow.


Source

File: compatibility/class-astra-polylang-compatibility.php

		public function block_polylang_meta_updates( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
			// Early return for non-Advanced Hooks.
			if ( 'astra-advanced-hook' !== get_post_type( $object_id ) ) {
				return $check;
			}

			if ( ! in_array( $meta_key, array( 'ast-advanced-hook-location', 'ast-advanced-hook-exclusion' ), true ) ) {
				return $check;
			}

			$backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 8 );
			foreach ( $backtrace as $trace ) {
				if ( isset( $trace['class'] ) && false !== strpos( $trace['class'], 'PLL_Sync' ) ) {
					return true;
				}
			}

			return $check;
		}

Changelog

Changelog
Version Description
4.12.0 Introduced.

User Contributed Notes

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