Advanced_Ads_Responsive_Amp::$supported_adsense_types ) ); } } /** * Sanitize and save ad options. * * @param arr $options * @return arr $options */ public function save_ad_options( array $options ) { $attributes = isset( $_POST['advanced_ad']['amp']['attributes'] ) ? array_values( $_POST['advanced_ad']['amp']['attributes'] ) : array(); $data = isset( $_POST['advanced_ad']['amp']['data'] ) ? array_values( $_POST['advanced_ad']['amp']['data'] ) : array(); unset( $options['amp']['attributes'], $options['amp']['data'] ); if ( is_array( $attributes ) && is_array( $data ) && count( $attributes ) === count( $data ) ) { foreach ( $attributes as $_i => $_attribute ) { $clear_attribute = sanitize_key( $_attribute ); $clear_data = isset( $data[ $_i ] ) ? $data[ $_i ] : ''; if ( $clear_attribute && $clear_data ) { $options['amp']['attributes'][ $clear_attribute ] = $clear_data; } } } if ( ! empty( $_POST['advanced_ad']['amp']['fallback'] ) ) { $options['amp']['fallback'] = wp_kses_post( $_POST['advanced_ad']['amp']['fallback'] ); } return $options; } /** * callback to display the AMP display condition * * @param arr $options options of the condition * @param int $index index of the condition */ public static function metabox_amp( $options, $index = 0, $form_name = '' ) { if ( ! isset ( $options['type'] ) || '' === $options['type'] ) { return; } $type_options = Advanced_Ads_Display_Conditions::get_instance()->conditions; if ( ! isset( $type_options[ $options['type'] ] ) ) { return; } // form name basis if ( method_exists( 'Advanced_Ads_Display_Conditions', 'get_form_name_with_index' ) ) { $name = Advanced_Ads_Display_Conditions::get_form_name_with_index( $form_name, $index ); } else { $name = Advanced_Ads_Display_Conditions::FORM_NAME . '[' . $index . ']'; } // options $operator = isset( $options['operator'] ) ? $options['operator'] : 'is'; ?>