Astra_Ext_Advanced_Hooks_Loader::column_content( array $column, int $post_id )

Adds the custom list table column content.


Description


Parameters

$column

(array) (Required) Name of column.

$post_id

(int) (Required) Post id.


Return

(void)


Source

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

		public function column_content( $column, $post_id ) {

			$icon_style = 'font-size:17px;';

			if ( 'advanced_hook_action' == $column ) {
				$layout = get_post_meta( $post_id, 'ast-advanced-hook-layout', true );

				if ( 'hooks' === $layout ) {
					$action = get_post_meta( $post_id, 'ast-advanced-hook-action', true );
				} else {
					$action = $layout;
				}

				echo apply_filters( 'astra_advanced_hooks_list_action_column', $action ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
			} elseif ( 'advanced_hook_display_rules' == $column ) {

				$locations = get_post_meta( $post_id, 'ast-advanced-hook-location', true );
				if ( ! empty( $locations ) ) {
					echo '<div class="ast-advanced-hook-location-wrap ast-advanced-hook-wrap">';
					echo '<strong>' . esc_attr( __( 'Display', 'astra-addon' ) ) . ': </strong>';
					$this->column_display_location_rules( $locations );
					echo '</div>';
				}

				$locations = get_post_meta( $post_id, 'ast-advanced-hook-exclusion', true );
				if ( ! empty( $locations ) ) {
					echo '<div class="ast-advanced-hook-exclusion-wrap ast-advanced-hook-wrap">';
					echo '<strong>' . esc_attr( __( 'Exclusion', 'astra-addon' ) ) . ': </strong>';
					$this->column_display_location_rules( $locations );
					echo '</div>';
				}

				$users = get_post_meta( $post_id, 'ast-advanced-hook-users', true );
				if ( isset( $users ) && is_array( $users ) ) {
					$user_label = array();
					foreach ( $users as $user ) {
						$user_label[] = Astra_Target_Rules_Fields::get_user_by_key( $user );
					}
					echo '<div class="ast-advanced-hook-users-wrap ast-advanced-hook-wrap">';
					echo '<strong>' . esc_attr( __( 'Users', 'astra-addon' ) ) . ': </strong>';
					echo esc_html( join( ', ', $user_label ) );
					echo '</div>';
				}

				$display_devices = get_post_meta( $post_id, 'ast-advanced-display-device', true );
				if ( is_array( $display_devices ) ) {
					echo '<div class="ast-advanced-hook-display-devices-wrap ast-advanced-hook-wrap">';
					echo '<strong>' . esc_attr( __( 'Devices', 'astra-addon' ) ) . ': </strong>';
					foreach ( $display_devices as $display_device ) {
						switch ( $display_device ) {
							case 'desktop':
								echo '<span style=' . esc_attr( $icon_style ) . ' class="dashicons dashicons-desktop"></span>';
								break;
							case 'tablet':
								echo '<span style=' . esc_attr( $icon_style ) . ' class="dashicons dashicons-tablet"></span>';
								break;
							case 'mobile':
								echo '<span style=' . esc_attr( $icon_style ) . ' class="dashicons dashicons-smartphone"></span>';
								break;
						}
					}
					echo '</div>';
				}

				$time_duration = get_post_meta( $post_id, 'ast-advanced-time-duration', true );
				if ( isset( $time_duration ) && is_array( $time_duration ) && isset( $time_duration['enabled'] ) ) {
					echo '<div class="ast-advanced-hook-time-duration-wrap ast-advanced-hook-wrap">';
					echo '<strong>' . esc_attr( __( 'Time Duration Eligible', 'astra-addon' ) ) . ': </strong>';

					if ( ! Astra_Ext_Advanced_Hooks_Markup::get_time_duration_eligibility( $post_id ) ) {
						echo '<span style=' . esc_attr( $icon_style ) . ' class="dashicons dashicons-no"></span>';
					} else {
						echo '<span style=' . esc_attr( $icon_style ) . ' class="dashicons dashicons-yes-alt"></span>';
					}

					echo '</div>';
				}
			}
		}

Changelog

Changelog
Version Description
1.0 Introduced.

User Contributed Notes

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