@@ -31,6 +31,8 @@ class ParsedContent
31
31
'translated_summary ' ,
32
32
'translated_description ' ,
33
33
'translated_return ' ,
34
+ 'translated_deprecated ' ,
35
+ 'translated_sinces ' ,
34
36
];
35
37
36
38
/**
@@ -178,9 +180,13 @@ public function addParsedMetaBox($post) {
178
180
$ excerpt = $ post ->post_excerpt ;
179
181
$ params = self ::getParams ($ post ->ID );
180
182
$ return = self ::getReturn ($ post ->ID );
183
+ $ deprecated = self ::getDeprecated ($ post ->ID );
184
+ $ sinces = self ::getSinces ($ post ->ID );
181
185
$ translated_summary = (string )get_post_meta ($ post ->ID , 'translated_summary ' , true );
182
186
$ translated_description = (string )get_post_meta ($ post ->ID , 'translated_description ' , true );
183
187
$ translated_return = (string )get_post_meta ($ post ->ID , 'translated_return ' , true );
188
+ $ translated_deprecated = (string )get_post_meta ($ post ->ID , 'translated_deprecated ' , true );
189
+ $ translated_sinces = (array )get_post_meta ($ post ->ID , 'translated_sinces ' , true );
184
190
185
191
wp_nonce_field ('phpdoc-parsed-content ' , 'phpdoc-parsed-content-nonce ' );
186
192
?>
@@ -266,9 +272,9 @@ public function addParsedMetaBox($post) {
266
272
</tr>
267
273
<?php if (current_user_can ('manage_options ' )) : ?>
268
274
<?php
269
- $ clean_name = str_replace ('$ ' , '' , $ name );
270
- $ translated_key = "translated_ {$ clean_name }" ;
271
- $ translated_key_val = (string )get_post_meta ($ post ->ID , $ translated_key , true );
275
+ $ clean_name = str_replace ('$ ' , '' , $ name );
276
+ $ translated_key = "translated_ {$ clean_name }" ;
277
+ $ translated_key_val = (string )get_post_meta ($ post ->ID , $ translated_key , true );
272
278
?>
273
279
<tr valign="top">
274
280
<th scope="row">
@@ -330,6 +336,90 @@ public function addParsedMetaBox($post) {
330
336
</tr>
331
337
<?php endif ; ?>
332
338
<?php endif ; ?>
339
+ <?php if (!empty ($ deprecated ['content ' ])) : ?>
340
+ <tr class="t-section">
341
+ <td colspan="2">
342
+ <h2><?php _e ('Tags (deprecated) ' , 'wp-parser ' ); ?> </h2>
343
+ </td>
344
+ </tr>
345
+ <tr>
346
+ <tr valign="top">
347
+ <th scope="row">
348
+ <div class="parser-tags">
349
+ <label for="phpdoc_parsed_content"><?php printf ($ deprecated ['content ' ]); ?> </label>
350
+ </div>
351
+ </th>
352
+ <td>
353
+ <div class="wporg_parsed_readonly"><?php echo $ deprecated ['description ' ]; ?> </div>
354
+ </td>
355
+ </tr>
356
+ </tr>
357
+ <?php if (current_user_can ('manage_options ' )) : ?>
358
+ <tr valign="top">
359
+ <th scope="row">
360
+ <label for="<?php echo $ deprecated ['content ' ]; ?> ">
361
+ <?php // translators: the arg name ?>
362
+ <?php printf (__ ('%s (Translated) ' , 'wp-parser ' ), $ deprecated ['content ' ]); ?>
363
+ </label>
364
+ </th>
365
+ <td>
366
+ <div class="translated_deprecated">
367
+ <?php
368
+ wp_editor ($ translated_deprecated , 'translated_deprecated ' , [
369
+ 'media_buttons ' => false ,
370
+ 'tinymce ' => false ,
371
+ 'quicktags ' => false ,
372
+ 'textarea_rows ' => 2 ,
373
+ ]);
374
+ ?>
375
+ </div>
376
+ </td>
377
+ </tr>
378
+ <?php endif ; ?>
379
+ <?php endif ; ?>
380
+ <?php if (count ($ sinces )) : ?>
381
+ <tr class="t-section">
382
+ <td colspan="2">
383
+ <h2><?php _e ('Tags (since) ' , 'wp-parser ' ); ?> </h2>
384
+ </td>
385
+ </tr>
386
+ <?php foreach ($ sinces as $ i => $ since ) : ?>
387
+ <tr>
388
+ <tr valign="top">
389
+ <th scope="row">
390
+ <div class="parser-tags">
391
+ <label for="phpdoc_parsed_content"><?php printf ($ since ['content ' ]); ?> </label>
392
+ </div>
393
+ </th>
394
+ <td>
395
+ <div class="wporg_parsed_readonly"><?php echo $ since ['description ' ]; ?> </div>
396
+ </td>
397
+ </tr>
398
+ </tr>
399
+ <?php if (current_user_can ('manage_options ' )) : ?>
400
+ <tr valign="top">
401
+ <th scope="row">
402
+ <label for="<?php echo $ since ['content ' ]; ?> ">
403
+ <?php // translators: the arg name ?>
404
+ <?php printf (__ ('%s (Translated) ' , 'wp-parser ' ), $ since ['content ' ]); ?>
405
+ </label>
406
+ </th>
407
+ <td>
408
+ <div class="<?php echo $ since ['content ' ]; ?> ">
409
+ <?php
410
+ wp_editor ($ translated_sinces [$ i ], 'translated_sinces[] ' , [
411
+ 'media_buttons ' => false ,
412
+ 'tinymce ' => false ,
413
+ 'quicktags ' => false ,
414
+ 'textarea_rows ' => 2 ,
415
+ ]);
416
+ ?>
417
+ </div>
418
+ </td>
419
+ </tr>
420
+ <?php endif ; ?>
421
+ <?php endforeach ; ?>
422
+ <?php endif ; ?>
333
423
</tbody>
334
424
</table>
335
425
<?php
@@ -405,6 +495,76 @@ public static function getReturn($post_id = null) {
405
495
];
406
496
}
407
497
498
+ /**
499
+ * Retrieve deprecated type and description if available.
500
+ *
501
+ * @param int $post_id
502
+ * @return array
503
+ */
504
+ public static function getDeprecated ($ post_id = null ) {
505
+ if (empty ($ post_id )) {
506
+ $ post_id = get_the_ID ();
507
+ }
508
+
509
+ $ deprecated = [];
510
+ $ tags = get_post_meta ($ post_id , '_wp-parser_tags ' , true );
511
+ if (!$ tags ) {
512
+ return $ deprecated ;
513
+ }
514
+
515
+ $ deprecated = wp_filter_object_list ($ tags , ['name ' => 'deprecated ' ]);
516
+
517
+ if (empty ($ deprecated )) {
518
+ return [
519
+ 'content ' => '' ,
520
+ 'description ' => '' ,
521
+ ];
522
+ }
523
+
524
+ $ deprecated = array_shift ($ deprecated );
525
+
526
+ if (!isset ($ deprecated ['content ' ])) {
527
+ return [
528
+ 'content ' => '' ,
529
+ 'description ' => '' ,
530
+ ];
531
+ }
532
+
533
+ return [
534
+ 'content ' => htmlspecialchars ($ deprecated ['content ' ]),
535
+ 'description ' => htmlspecialchars (isset ($ deprecated ['description ' ]) ? $ deprecated ['description ' ] : '' ),
536
+ ];
537
+ }
538
+
539
+ /**
540
+ * Retrieve sinces as a key value array
541
+ *
542
+ * @param int $post_id
543
+ * @return array
544
+ */
545
+ public static function getSinces ($ post_id = null ) {
546
+ if (empty ($ post_id )) {
547
+ $ post_id = get_the_ID ();
548
+ }
549
+
550
+ $ sinces = [];
551
+ $ tags = get_post_meta ($ post_id , '_wp-parser_tags ' , true );
552
+ if (!$ tags ) {
553
+ return $ sinces ;
554
+ }
555
+
556
+ foreach ($ tags as $ tag ) {
557
+ if (!empty ($ tag ['name ' ]) && 'since ' == $ tag ['name ' ] && isset ($ tag ['content ' ])) {
558
+ $ sinces [] = [
559
+ 'content ' => htmlspecialchars ($ tag ['content ' ]),
560
+ 'description ' => htmlspecialchars (isset ($ tag ['description ' ]) ? $ tag ['description ' ] : '' ),
561
+ ];
562
+ }
563
+ }
564
+
565
+ return $ sinces ;
566
+ }
567
+
408
568
/**
409
569
* Returns indexed array of parameter post meta keys
410
570
*
0 commit comments