@@ -261,7 +261,7 @@ function single_meta_id() {
261261 $ single_meta = ( $ this ->meta_id == 0 || $ this ->meta_id == 'None ' || empty ( $ this ->meta_id ) ) ? null : $ this ->meta_id ;
262262
263263 if ( is_array ( $ single_meta ) && 0 < count ( $ single_meta ) ) {
264- $ single_meta = $ single_meta[ 0 ] ;
264+ $ single_meta = reset ( $ single_meta ) ;
265265 }
266266
267267 return $ single_meta ;
@@ -498,10 +498,10 @@ function inline_css() {
498498 if ( $ this ->has_multiple_meta () ) {
499499 $ rows = ppom_meta_repository ()->get_rows_by_ids ( $ this ->meta_id );
500500 foreach ( $ rows as $ row ) {
501- $ inline_css .= $ this ->generate_inline_css ( $ row ->productmeta_style );
501+ $ inline_css .= $ this ->generate_inline_css ( $ row ->productmeta_id , $ row -> productmeta_style );
502502 }
503503 } elseif ( isset ( $ this ->ppom_settings ->productmeta_style ) ) {
504- $ inline_css = $ this ->generate_inline_css ( $ this ->ppom_settings ->productmeta_style );
504+ $ inline_css = $ this ->generate_inline_css ( $ this ->ppom_settings ->productmeta_id , $ this -> ppom_settings -> productmeta_style );
505505 }
506506
507507 $ inline_css = trim ( $ inline_css );
@@ -678,27 +678,16 @@ static function ( $v ) {
678678 /**
679679 * Generates inline CSS.
680680 *
681+ * @param int|string $meta_id meta field id for selector.
681682 * @param string|null $style meta field css.
682683 * @return string
683684 */
684- private function generate_inline_css ( $ style ) {
685+ private function generate_inline_css ( $ meta_id , $ style ) {
685686 $ inline_css = '' ;
686687 if ( is_string ( $ style ) && '' !== $ style ) {
687688 $ template = stripslashes ( wp_strip_all_tags ( $ style ) );
688689 $ selector = '' ;
689- if ( is_array ( $ this ->meta_id ) ) {
690- $ field_selector = array ();
691- foreach ( $ this ->meta_id as $ field_id ) {
692- if ( $ field_id == 0 || $ field_id == 'None ' ) {
693- continue ;
694- }
695-
696- $ field_selector [] = '.ppom-id- ' . $ field_id ;
697- }
698- $ selector = ':where( ' . implode ( ', ' , $ field_selector ) . ') ' ;
699- } elseif ( is_numeric ( $ this ->meta_id ) ) {
700- $ selector = '.ppom-id- ' . $ this ->meta_id ;
701- }
690+ $ selector = '.ppom-id- ' . $ meta_id ;
702691 $ inline_css .= str_replace ( 'selector ' , $ selector , $ template );
703692 }
704693
0 commit comments