rrency, $with_symbol, $with_flag ); } $widget_content .= ''; // Silence XSS warning because we are manually constructing the content and escaping everything above. // nosemgrep: audit.php.wp.security.xss.block-attr -- reason: we are manually constructing the content and escaping everything above. return $widget_content; } /** * Create an '; } /** * Given an array of styling rules, output them as a string containing valid CSS. * * @param array $styles An array of CSS styles. * * @return string */ private function implode_styles_array( array $styles ): string { $return_str = ''; foreach ( $styles as $key => $value ) { $return_str .= $key . ': ' . $value . '; '; } return $return_str; } /** * Generate the styles that need to be applied to the widget based on the block attributes. * * @param array $block_attributes The block attributes. * * @return array */ private function get_widget_styles( array $block_attributes ): array { return [ 'div' => [ 'line-height' => $block_attributes['fontLineHeight'] ?? 1.2, ], 'select' => [ 'padding' => '2px', 'border' => ! empty( $block_attributes['border'] ) ? '1px solid' : '0px solid', 'border-radius' => isset( $block_attributes['borderRadius'] ) ? $block_attributes['borderRadius'] . 'px' : '3px', 'border-color' => $block_attributes['borderColor'] ?? '#000000', 'font-size' => isset( $block_attributes['fontSize'] ) ? $block_attributes['fontSize'] . 'px' : '11px', 'color' => $block_attributes['fontColor'] ?? '#000000', 'background-color' => $block_attributes['backgroundColor'] ?? '#000000', ], ]; } /** * Get hidden inputs for every $_GET param. * This prevents the switcher form to remove them on submit. * * @return string|null */ private function get_get_params() { if ( empty( $_GET ) ) { // phpcs:disable WordPress.Security.NonceVerification return null; } $params = explode( '&', urldecode( http_build_query( $_GET ) ) ); $return = ''; foreach ( $params as $param ) { $name_value = explode( '=', $param ); $name = $name_value[0]; $value = $name_value[1]; if ( 'currency' === $name ) { continue; } $return .= sprintf( '', esc_attr( $name ), esc_attr( $value ) ); } return $return; } }