@@ -212,8 +212,159 @@ private function render_db_changes( $changes ) {
212
212
return ;
213
213
}
214
214
215
- // First render content groups (posts and related content)
216
- if ( isset ( $ changes ['content_groups ' ] ) && ! empty ( $ changes ['content_groups ' ] ) ) {
215
+ // First render content groups organized by post type
216
+ if ( isset ( $ changes ['post_type_groups ' ] ) && ! empty ( $ changes ['post_type_groups ' ] ) ) {
217
+ ?>
218
+ <h3><?php esc_html_e ( 'Content Changes ' , 'staging2live ' ); ?> </h3>
219
+ <div class="stl-post-type-groups">
220
+ <?php foreach ( $ changes ['post_type_groups ' ] as $ post_type => $ groups ) : ?>
221
+ <div class="stl-post-type-group">
222
+ <h3 class="stl-post-type-header">
223
+ <?php echo esc_html ( ucfirst ( $ post_type ) ); ?>
224
+ </h3>
225
+ <div class="stl-content-groups">
226
+ <?php foreach ( $ groups as $ group ) : ?>
227
+ <div class="stl-content-group">
228
+ <div class="stl-group-header">
229
+ <input type="checkbox" class="stl-select-group" data-group-id="<?php echo esc_attr ( $ group ['group_id ' ] ); ?> ">
230
+ <h4>
231
+ <?php echo esc_html ( $ group ['title ' ] ); ?>
232
+ <span class="stl-change-type stl-type-<?php echo esc_attr ( $ group ['type ' ] ); ?> ">
233
+ <?php echo esc_html ( $ this ->get_status_label ( $ group ['type ' ] ) ); ?>
234
+ </span>
235
+ </h4>
236
+ <button class="button stl-toggle-group" data-group-id="<?php echo esc_attr ( $ group ['group_id ' ] ); ?> ">
237
+ <?php esc_html_e ( 'Show Details ' , 'staging2live ' ); ?>
238
+ </button>
239
+ </div>
240
+ <div class="stl-group-content" id="group-content-<?php echo esc_attr ( $ group ['group_id ' ] ); ?> " style="display:none;">
241
+ <?php foreach ( $ group ['changes ' ] as $ table => $ table_changes ) : ?>
242
+ <?php
243
+ // Special handling for attachments to make them more visual
244
+ if ($ table === 'attachments ' ) :
245
+ ?>
246
+ <h5><?php esc_html_e ( 'Media Attachments ' , 'staging2live ' ); ?> (<?php echo count ( $ table_changes ); ?> )</h5>
247
+ <div class="stl-attachments-grid">
248
+ <?php foreach ( $ table_changes as $ change ) :
249
+ $ attachment_title = isset ($ change ['details ' ]['post_title ' ]) ? $ change ['details ' ]['post_title ' ] : '' ;
250
+ $ attachment_mime = isset ($ change ['details ' ]['post_mime_type ' ]) ? $ change ['details ' ]['post_mime_type ' ] : '' ;
251
+ $ is_image = strpos ($ attachment_mime , 'image/ ' ) === 0 ;
252
+
253
+ // Try to get the attachment URL from guid
254
+ $ attachment_url = isset ($ change ['details ' ]['guid ' ]) ? $ change ['details ' ]['guid ' ] : '' ;
255
+ ?>
256
+ <div class="stl-attachment-item">
257
+ <div class="stl-attachment-preview">
258
+ <?php if ($ is_image && $ attachment_url ) : ?>
259
+ <img src="<?php echo esc_url ($ attachment_url ); ?> " alt="<?php echo esc_attr ($ attachment_title ); ?> ">
260
+ <?php else : ?>
261
+ <div class="stl-attachment-icon dashicons dashicons-media-default"></div>
262
+ <?php endif ; ?>
263
+ </div>
264
+ <div class="stl-attachment-details">
265
+ <label>
266
+ <input
267
+ type="checkbox"
268
+ class="stl-select-db stl-group-item"
269
+ data-group="<?php echo esc_attr ( $ group ['group_id ' ] ); ?> "
270
+ data-table="posts"
271
+ value="<?php echo esc_attr ( json_encode ( array ( 'table ' => 'posts ' , 'id ' => $ change ['id ' ] ) ) ); ?> "
272
+ >
273
+ <?php echo $ attachment_title ? esc_html ($ attachment_title ) : sprintf (esc_html__ ('Attachment ID: %s ' , 'staging2live ' ), $ change ['id ' ]); ?>
274
+ </label>
275
+ <span class="stl-change-type stl-type-<?php echo esc_attr ( $ change ['type ' ] ); ?> ">
276
+ <?php echo esc_html ( $ this ->get_status_label ( $ change ['type ' ] ) ); ?>
277
+ </span>
278
+ <button class="button stl-view-db-diff" data-table="posts" data-id="<?php echo esc_attr ( $ change ['id ' ] ); ?> ">
279
+ <?php esc_html_e ( 'View Details ' , 'staging2live ' ); ?>
280
+ </button>
281
+ </div>
282
+ </div>
283
+ <?php endforeach ; ?>
284
+ </div>
285
+ <?php
286
+ // Special handling for child posts
287
+ elseif ($ table === 'child_posts ' ) :
288
+ ?>
289
+ <h5><?php esc_html_e ( 'Child Posts ' , 'staging2live ' ); ?> (<?php echo count ( $ table_changes ); ?> )</h5>
290
+ <div class="stl-child-posts">
291
+ <?php foreach ( $ table_changes as $ change ) :
292
+ $ post_title = isset ($ change ['details ' ]['post_title ' ]) ? $ change ['details ' ]['post_title ' ] : '' ;
293
+ $ post_type = isset ($ change ['details ' ]['post_type ' ]) ? $ change ['details ' ]['post_type ' ] : 'post ' ;
294
+ ?>
295
+ <div class="stl-child-post-item">
296
+ <div class="stl-child-post-header">
297
+ <label>
298
+ <input
299
+ type="checkbox"
300
+ class="stl-select-db stl-group-item"
301
+ data-group="<?php echo esc_attr ( $ group ['group_id ' ] ); ?> "
302
+ data-table="posts"
303
+ value="<?php echo esc_attr ( json_encode ( array ( 'table ' => 'posts ' , 'id ' => $ change ['id ' ] ) ) ); ?> "
304
+ >
305
+ <span class="stl-child-post-title">
306
+ <?php echo $ post_title ? esc_html ($ post_title ) : sprintf (esc_html__ ('Post ID: %s ' , 'staging2live ' ), $ change ['id ' ]); ?>
307
+ </span>
308
+ <span class="stl-child-post-type"><?php echo esc_html (ucfirst ($ post_type )); ?> </span>
309
+ </label>
310
+ <span class="stl-change-type stl-type-<?php echo esc_attr ( $ change ['type ' ] ); ?> ">
311
+ <?php echo esc_html ( $ this ->get_status_label ( $ change ['type ' ] ) ); ?>
312
+ </span>
313
+ </div>
314
+ <div class="stl-child-post-actions">
315
+ <button class="button stl-view-db-diff" data-table="posts" data-id="<?php echo esc_attr ( $ change ['id ' ] ); ?> ">
316
+ <?php esc_html_e ( 'View Details ' , 'staging2live ' ); ?>
317
+ </button>
318
+ </div>
319
+ </div>
320
+ <?php endforeach ; ?>
321
+ </div>
322
+ <?php else : ?>
323
+ <h5><?php echo esc_html ( ucfirst ( $ table ) ); ?> (<?php echo count ( $ table_changes ); ?> )</h5>
324
+ <table class="widefat stl-changes-table stl-group-table">
325
+ <thead>
326
+ <tr>
327
+ <th><input type="checkbox" class="stl-select-all-table" data-table="<?php echo esc_attr ( $ table ); ?> " data-group="<?php echo esc_attr ( $ group ['group_id ' ] ); ?> "></th>
328
+ <th><?php esc_html_e ( 'Type ' , 'staging2live ' ); ?> </th>
329
+ <th><?php esc_html_e ( 'Changes ' , 'staging2live ' ); ?> </th>
330
+ <th><?php esc_html_e ( 'Action ' , 'staging2live ' ); ?> </th>
331
+ </tr>
332
+ </thead>
333
+ <tbody>
334
+ <?php foreach ( $ table_changes as $ change ) : ?>
335
+ <tr>
336
+ <td>
337
+ <input
338
+ type="checkbox"
339
+ class="stl-select-db stl-group-item"
340
+ data-group="<?php echo esc_attr ( $ group ['group_id ' ] ); ?> "
341
+ data-table="<?php echo esc_attr ( $ table ); ?> "
342
+ value="<?php echo esc_attr ( json_encode ( array ( 'table ' => $ table , 'id ' => $ change ['id ' ] ) ) ); ?> "
343
+ >
344
+ </td>
345
+ <td><?php echo esc_html ( $ change ['type ' ] ); ?> </td>
346
+ <td><?php echo esc_html ( $ change ['summary ' ] ); ?> </td>
347
+ <td>
348
+ <button class="button stl-view-db-diff" data-table="<?php echo esc_attr ( $ table ); ?> " data-id="<?php echo esc_attr ( $ change ['id ' ] ); ?> ">
349
+ <?php esc_html_e ( 'View Details ' , 'staging2live ' ); ?>
350
+ </button>
351
+ </td>
352
+ </tr>
353
+ <?php endforeach ; ?>
354
+ </tbody>
355
+ </table>
356
+ <?php endif ; ?>
357
+ <?php endforeach ; ?>
358
+ </div>
359
+ </div>
360
+ <?php endforeach ; ?>
361
+ </div>
362
+ </div>
363
+ <?php endforeach ; ?>
364
+ </div>
365
+ <?php
366
+ } else if ( isset ( $ changes ['content_groups ' ] ) && ! empty ( $ changes ['content_groups ' ] ) ) {
367
+ // Fallback to old structure if post_type_groups not available
217
368
?>
218
369
<h3><?php esc_html_e ( 'Content Changes ' , 'staging2live ' ); ?> </h3>
219
370
<div class="stl-content-groups">
@@ -360,7 +511,7 @@ class="stl-select-db stl-group-item"
360
511
$ standalone_changes = false ;
361
512
foreach ( $ changes as $ table => $ table_changes ) {
362
513
// Skip the content groups as we've already rendered them
363
- if ( $ table === 'content_groups ' ) {
514
+ if ( $ table === 'content_groups ' || $ table === ' post_type_groups ' ) {
364
515
continue ;
365
516
}
366
517
@@ -386,8 +537,8 @@ class="stl-select-db stl-group-item"
386
537
<tbody>
387
538
<?php
388
539
foreach ( $ changes as $ table => $ table_changes ) :
389
- // Skip the content groups
390
- if ( $ table === 'content_groups ' ) {
540
+ // Skip the content groups and post type groups
541
+ if ( $ table === 'content_groups ' || $ table === ' post_type_groups ' ) {
391
542
continue ;
392
543
}
393
544
foreach ( $ table_changes as $ change ) :
0 commit comments