items[ $option_key ] = array( 'selector' => $selector, 'property' => $property, ); } /** * Builds the CSS, based on the passed options, to be used on the frontend. * * @return string The CSS to be used on the frontend. */ public function build() { $options = YoastSEO_AMP_Options::get(); $output = "\n"; $css = array(); $options = array_filter( $options ); $apply = array_intersect_key( $this->items, $options ); if ( is_array( $apply ) ) { foreach ( $apply as $key => $placement ) { if ( ! isset( $css[ $placement['selector'] ] ) ) { $css[ $placement['selector'] ] = array(); } $css[ $placement['selector'] ][ $placement['property'] ] = $options[ $key ]; } } if ( ! empty( $css ) ) { foreach ( $css as $selector => $properties ) { $inner = ''; foreach ( $properties as $property => $value ) { $inner .= sprintf( "%s: %s;\n", $property, $value ); } $output .= sprintf( "%s {\n%s}\n", $selector, $inner ); } } return $output; } } }