@@ -591,17 +591,9 @@ public function get_wc_tags( $current_values ) {
591591 * @return array
592592 */
593593 public function get_db_field ( $ ppom_field_id ) {
594- global $ wpdb ;
595- $ ppom_table = $ wpdb ->prefix . PPOM_TABLE_META ;
596- $ rows = $ wpdb ->get_results (
597- $ wpdb ->prepare (
598- "SELECT productmeta_categories, productmeta_tags FROM $ ppom_table WHERE productmeta_id = %d " ,
599- $ ppom_field_id
600- ),
601- ARRAY_A
602- );
594+ $ rows = ppom_meta_repository ()->get_categories_and_tags_columns ( (int ) $ ppom_field_id );
603595
604- return 0 < count ( $ rows ) && ! empty ( $ rows[ 0 ] ) ? $ rows[ 0 ] : array ();
596+ return ! empty ( $ rows ) ? $ rows : array ();
605597 }
606598
607599 /**
@@ -720,25 +712,7 @@ public function ppom_attach_ppoms() {
720712 * @return void
721713 */
722714 public static function save_categories_and_tags ( $ ppom_id , $ categories , $ tags ) {
723- global $ wpdb ;
724- $ ppom_table = $ wpdb ->prefix . PPOM_TABLE_META ;
725-
726- $ data_to_update = array (
727- 'productmeta_categories ' => implode ( "\r\n" , $ categories ), // NOTE: Keep the backward compatible format.
728- );
729-
730- // false = caller chose not to change tags (e.g. E2E partial update); omit column from UPDATE.
731- if ( is_array ( $ tags ) ) {
732- $ data_to_update ['productmeta_tags ' ] = empty ( $ tags ) ? '' : serialize ( $ tags );
733- }
734-
735- $ wpdb ->update (
736- $ ppom_table ,
737- $ data_to_update ,
738- array ( 'productmeta_id ' => $ ppom_id ), // Where clause
739- array ( '%s ' ), // Data format
740- array ( '%d ' ) // Where format
741- );
715+ ppom_meta_repository ()->save_categories_and_tags ( (int ) $ ppom_id , $ categories , $ tags );
742716 }
743717
744718 // Legacy settings bridge and setup.
@@ -955,10 +929,7 @@ public function set_legacy_user() {
955929 return ;
956930 }
957931
958- global $ wpdb ;
959- $ ppom_meta_table = $ wpdb ->prefix . PPOM_TABLE_META ;
960- // phpcs:ignore WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
961- $ res = $ wpdb ->get_results ( "SELECT * FROM ` $ ppom_meta_table` WHERE `productmeta_js` != '' OR `productmeta_style` != '' " );
932+ $ res = ppom_meta_repository ()->get_rows_with_non_empty_style_or_js ();
962933 update_option ( 'ppom_legacy_user ' , ! empty ( $ res ) ? 'yes ' : 'no ' );
963934 }
964935
0 commit comments