Astra_Ext_Advanced_Hooks_Meta::rows_from_selection( mixed $predefined, string $custom_names )

Build placement rows from a multi-select submission.


Description

The editors post the predefined hook slugs as a list and the custom hook names as one comma separated string; this turns both into the stored { action, custom } row shape.


Parameters

$predefined

(Required) Selected predefined hook slugs (may include custom_hook).

$custom_names

(Required) Comma separated custom hook names.


Return

(array) Unsanitized rows.


Source

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

		public static function rows_from_selection( $predefined, $custom_names ) {
			$rows = array();

			foreach ( (array) $predefined as $slug ) {
				if ( 'custom_hook' !== $slug ) {
					$rows[] = array(
						'action' => $slug,
						'custom' => '',
					);
				}
			}

			if ( in_array( 'custom_hook', (array) $predefined, true ) ) {
				foreach ( preg_split( '/[\s,]+/', (string) $custom_names ) as $name ) {
					if ( '' !== $name ) {
						$rows[] = array(
							'action' => 'custom_hook',
							'custom' => $name,
						);
					}
				}
			}

			return $rows;
		}

Changelog

Changelog
Version Description
4.13.11 Introduced.


User Contributed Notes

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