Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Tax_Meta_Class often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Tax_Meta_Class, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
41 | class Tax_Meta_Class |
||
42 | { |
||
43 | |||
44 | /** |
||
45 | * Holds meta box object |
||
46 | * |
||
47 | * @var object |
||
48 | * @access protected |
||
49 | */ |
||
50 | protected $_meta_box; |
||
51 | |||
52 | /** |
||
53 | * Holds meta box fields. |
||
54 | * |
||
55 | * @var array |
||
56 | * @access protected |
||
57 | */ |
||
58 | protected $_prefix; |
||
59 | |||
60 | /** |
||
61 | * Holds Prefix for meta box fields. |
||
62 | * |
||
63 | * @var array |
||
64 | * @access protected |
||
65 | */ |
||
66 | protected $_fields; |
||
67 | |||
68 | /** |
||
69 | * Use local images. |
||
70 | * |
||
71 | * @var bool |
||
72 | * @access protected |
||
73 | */ |
||
74 | protected $_Local_images; |
||
75 | |||
76 | /** |
||
77 | * What form is this? edit or new term. |
||
78 | * |
||
79 | * @var string |
||
80 | * @access protected |
||
81 | * $since 1.0 |
||
82 | */ |
||
83 | protected $_form_type; |
||
84 | /** |
||
85 | * SelfPath to allow themes as well as plugins. |
||
86 | * |
||
87 | * @var string |
||
88 | * @access protected |
||
89 | * $since 1.0 |
||
90 | */ |
||
91 | protected $SelfPath; |
||
92 | |||
93 | /** |
||
94 | * Constructor |
||
95 | * |
||
96 | * @since 1.0 |
||
97 | * @access public |
||
98 | * |
||
99 | * @param array $meta_box |
||
100 | */ |
||
101 | public function __construct($meta_box) |
||
141 | |||
142 | /** |
||
143 | * Load all Javascript and CSS |
||
144 | * |
||
145 | * @since 1.0 |
||
146 | * @access public |
||
147 | */ |
||
148 | public function load_scripts_styles() |
||
170 | |||
171 | /** |
||
172 | * Check the Field Upload, Add needed Actions |
||
173 | * |
||
174 | * @since 1.0 |
||
175 | * @access public |
||
176 | */ |
||
177 | public function enqueue_tax_meta_scripts() |
||
188 | |||
189 | public function check_field_upload() |
||
214 | |||
215 | /** |
||
216 | * Add data encoding type for file uploading |
||
217 | * |
||
218 | * @since 1.0 |
||
219 | * @access public |
||
220 | */ |
||
221 | public function add_enctype() |
||
225 | |||
226 | /** |
||
227 | * Process images added to meta field. |
||
228 | * |
||
229 | * Modified from Faster Image Insert plugin. |
||
230 | * |
||
231 | * @return void |
||
232 | * @author Cory Crowley |
||
233 | */ |
||
234 | public function insert_images() |
||
275 | |||
276 | /** |
||
277 | * Delete attachments associated with the post. |
||
278 | * |
||
279 | * @since 1.0 |
||
280 | * @access public |
||
281 | * |
||
282 | * @param int|string $term_id The term ID. |
||
283 | */ |
||
284 | /*public function delete_attachments( $term_id ) { |
||
285 | |||
286 | // Get Attachments |
||
287 | $attachments = get_posts( array( 'numberposts' => -1, 'post_type' => 'attachment', 'post_parent' => $term_id ) ); |
||
288 | |||
289 | // Loop through attachments, if not empty, delete it. |
||
290 | if ( ! empty( $attachments ) ) { |
||
291 | foreach ( $attachments as $att ) { |
||
292 | wp_delete_attachment( $att->ID ); |
||
293 | } |
||
294 | } |
||
295 | |||
296 | }*/ |
||
297 | |||
298 | /** |
||
299 | * Ajax callback for deleting files. |
||
300 | * |
||
301 | * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H ) |
||
302 | * |
||
303 | * @since 1.0 |
||
304 | * @access public |
||
305 | */ |
||
306 | public function delete_file() |
||
324 | |||
325 | /** |
||
326 | * Ajax callback for deleting files. |
||
327 | * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq) |
||
328 | * @since 1.0 |
||
329 | * @access public |
||
330 | */ |
||
331 | public function wp_ajax_delete_image() |
||
368 | |||
369 | /** |
||
370 | * Ajax callback for reordering Images. |
||
371 | * |
||
372 | * @since 1.0 |
||
373 | * @access public |
||
374 | */ |
||
375 | public function reorder_images() |
||
397 | |||
398 | /** |
||
399 | * Check Field Color |
||
400 | * |
||
401 | * @since 1.0 |
||
402 | * @access public |
||
403 | */ |
||
404 | public function check_field_color() |
||
414 | |||
415 | /** |
||
416 | * Check Field Date |
||
417 | * |
||
418 | * @since 1.0 |
||
419 | * @access public |
||
420 | */ |
||
421 | public function check_field_date() |
||
431 | |||
432 | /** |
||
433 | * Check Field Time |
||
434 | * |
||
435 | * @since 1.0 |
||
436 | * @access public |
||
437 | */ |
||
438 | public function check_field_time() |
||
451 | |||
452 | /** |
||
453 | * Add Meta Box for multiple post types. |
||
454 | * |
||
455 | * @since 1.0 |
||
456 | * @access public |
||
457 | */ |
||
458 | public function add() |
||
476 | |||
477 | /** |
||
478 | * Callback function to show fields on add new taxonomy term form. |
||
479 | * |
||
480 | * @since 1.0 |
||
481 | * @access public |
||
482 | */ |
||
483 | public function show_new_form($term_id) |
||
488 | |||
489 | /** |
||
490 | * Callback function to show fields on term edit form. |
||
491 | * |
||
492 | * @since 1.0 |
||
493 | * @access public |
||
494 | */ |
||
495 | public function show_edit_form($term_id) |
||
500 | |||
501 | |||
502 | /** |
||
503 | * Callback function to show fields in meta box. |
||
504 | * |
||
505 | * @since 1.0 |
||
506 | * @access public |
||
507 | */ |
||
508 | public function show($term_id) |
||
531 | |||
532 | /** |
||
533 | * Show Repeater Fields. |
||
534 | * |
||
535 | * @param string $field |
||
536 | * @param string $meta |
||
537 | * @since 1.0 |
||
538 | * @access public |
||
539 | */ |
||
540 | public function show_field_repeater($field, $meta) |
||
663 | |||
664 | /** |
||
665 | * Begin Field. |
||
666 | * |
||
667 | * @param string $field |
||
668 | * @param string $meta |
||
669 | * @since 1.0 |
||
670 | * @access public |
||
671 | */ |
||
672 | public function show_field_begin($field, $meta) |
||
698 | |||
699 | /** |
||
700 | * End Field. |
||
701 | * |
||
702 | * @param string $field |
||
703 | * @param string $meta |
||
704 | * @since 1.0 |
||
705 | * @access public |
||
706 | */ |
||
707 | public function show_field_end($field, $meta = NULL, $group = false) |
||
734 | |||
735 | /** |
||
736 | * Show Field Text. |
||
737 | * |
||
738 | * @param string $field |
||
739 | * @param string $meta |
||
740 | * @since 1.0 |
||
741 | * @access public |
||
742 | */ |
||
743 | public function show_field_text($field, $meta) |
||
749 | |||
750 | /** |
||
751 | * Show Field hidden. |
||
752 | * |
||
753 | * @param string $field |
||
754 | * @param string|mixed $meta |
||
755 | * @since 0.1.3 |
||
756 | * @access public |
||
757 | */ |
||
758 | public function show_field_hidden($field, $meta) |
||
764 | |||
765 | /** |
||
766 | * Show Field Paragraph. |
||
767 | * |
||
768 | * @param string $field |
||
769 | * @since 0.1.3 |
||
770 | * @access public |
||
771 | */ |
||
772 | public function show_field_paragraph($field) |
||
778 | |||
779 | /** |
||
780 | * Show Field Textarea. |
||
781 | * |
||
782 | * @param string $field |
||
783 | * @param string $meta |
||
784 | * @since 1.0 |
||
785 | * @access public |
||
786 | */ |
||
787 | public function show_field_textarea($field, $meta) |
||
793 | |||
794 | /** |
||
795 | * Show Field Select. |
||
796 | * |
||
797 | * @param string $field |
||
798 | * @param string $meta |
||
799 | * @since 1.0 |
||
800 | * @access public |
||
801 | */ |
||
802 | public function show_field_select($field, $meta) |
||
817 | |||
818 | /** |
||
819 | * Show Radio Field. |
||
820 | * |
||
821 | * @param string $field |
||
822 | * @param string $meta |
||
823 | * @since 1.0 |
||
824 | * @access public |
||
825 | */ |
||
826 | public function show_field_radio($field, $meta) |
||
838 | |||
839 | /** |
||
840 | * Show Checkbox Field. |
||
841 | * |
||
842 | * @param string $field |
||
843 | * @param string $meta |
||
844 | * @since 1.0 |
||
845 | * @access public |
||
846 | */ |
||
847 | public function show_field_checkbox($field, $meta) |
||
854 | |||
855 | /** |
||
856 | * Show Wysiwig Field. |
||
857 | * |
||
858 | * @param string $field |
||
859 | * @param string $meta |
||
860 | * @since 1.0 |
||
861 | * @access public |
||
862 | */ |
||
863 | public function show_field_wysiwyg($field, $meta) |
||
877 | |||
878 | /** |
||
879 | * Show File Field. |
||
880 | * |
||
881 | * @global object $post The current post object. |
||
882 | * @param string $field |
||
883 | * @param string $meta |
||
884 | * @since 1.0 |
||
885 | * @access public |
||
886 | */ |
||
887 | public function show_field_file($field, $meta) |
||
923 | |||
924 | /** |
||
925 | * Show Image Field. |
||
926 | * |
||
927 | * @param array $field |
||
928 | * @param array $meta |
||
929 | * @since 1.0 |
||
930 | * @access public |
||
931 | */ |
||
932 | public function show_field_image($field, $meta) |
||
979 | |||
980 | /** |
||
981 | * Show Color Field. |
||
982 | * |
||
983 | * @param string $field |
||
984 | * @param string $meta |
||
985 | * @since 1.0 |
||
986 | * @access public |
||
987 | */ |
||
988 | public function show_field_color($field, $meta) |
||
1003 | |||
1004 | /** |
||
1005 | * Show Checkbox List Field |
||
1006 | * |
||
1007 | * @param string $field |
||
1008 | * @param string $meta |
||
1009 | * @since 1.0 |
||
1010 | * @access public |
||
1011 | */ |
||
1012 | public function show_field_checkbox_list($field, $meta) |
||
1031 | |||
1032 | /** |
||
1033 | * Show Date Field. |
||
1034 | * |
||
1035 | * @param string $field |
||
1036 | * @param string $meta |
||
1037 | * @since 1.0 |
||
1038 | * @access public |
||
1039 | */ |
||
1040 | public function show_field_date($field, $meta) |
||
1046 | |||
1047 | /** |
||
1048 | * Show time field. |
||
1049 | * |
||
1050 | * @param string $field |
||
1051 | * @param string $meta |
||
1052 | * @since 1.0 |
||
1053 | * @access public |
||
1054 | */ |
||
1055 | public function show_field_time($field, $meta) |
||
1061 | |||
1062 | /** |
||
1063 | * Show Posts field. |
||
1064 | * used creating a posts/pages/custom types checkboxlist or a select dropdown |
||
1065 | * |
||
1066 | * @global object $post The current post object. |
||
1067 | * @param string $field |
||
1068 | * @param string $meta |
||
1069 | * @since 1.0 |
||
1070 | * @access public |
||
1071 | */ |
||
1072 | View Code Duplication | public function show_field_posts($field, $meta) |
|
1097 | |||
1098 | /** |
||
1099 | * Show Taxonomy field. |
||
1100 | * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown |
||
1101 | * |
||
1102 | * @global object $post The current post object. |
||
1103 | * @param string $field |
||
1104 | * @param string $meta |
||
1105 | * @since 1.0 |
||
1106 | * @access public |
||
1107 | * |
||
1108 | * @uses get_terms() |
||
1109 | */ |
||
1110 | View Code Duplication | public function show_field_taxonomy($field, $meta) |
|
1135 | |||
1136 | /** |
||
1137 | * Save Data from Metabox |
||
1138 | * |
||
1139 | * @param string $term_id The term ID. |
||
1140 | * @since 1.0 |
||
1141 | * @access public |
||
1142 | * @return string |
||
1143 | */ |
||
1144 | public function save($term_id) |
||
1237 | |||
1238 | /** |
||
1239 | * Common function for saving fields. |
||
1240 | * |
||
1241 | * @param string $term_id The term ID. |
||
1242 | * @param string $field |
||
1243 | * @param string $old |
||
1244 | * @param string|mixed $new |
||
1245 | * @since 1.0 |
||
1246 | * @access public |
||
1247 | */ |
||
1248 | public function save_field($term_id, $field, $old, $new) |
||
1257 | |||
1258 | /** |
||
1259 | * function for saving image field. |
||
1260 | * |
||
1261 | * @param string $term_id The term ID. |
||
1262 | * @param string $field |
||
1263 | * @param string $old |
||
1264 | * @param string|mixed $new |
||
1265 | * @since 1.0 |
||
1266 | * @access public |
||
1267 | */ |
||
1268 | public function save_field_image($term_id, $field, $old, $new) |
||
1278 | |||
1279 | /* |
||
1280 | * Save Wysiwyg Field. |
||
1281 | * |
||
1282 | * @param string $term_id The term ID. |
||
1283 | * @param string $field |
||
1284 | * @param string $old |
||
1285 | * @param string $new |
||
1286 | * @since 1.0 |
||
1287 | * @access public |
||
1288 | */ |
||
1289 | public function save_field_wysiwyg($term_id, $field, $old, $new) |
||
1293 | |||
1294 | /** |
||
1295 | * Save repeater Fields. |
||
1296 | * |
||
1297 | * @param string $term_id The term ID. |
||
1298 | * @param string $field |
||
1299 | * @param string|mixed $old |
||
1300 | * @param string|mixed $new |
||
1301 | * @since 1.0 |
||
1302 | * @access public |
||
1303 | */ |
||
1304 | public function save_field_repeater($term_id, $field, $old, $new) |
||
1335 | |||
1336 | /** |
||
1337 | * Save File Field. |
||
1338 | * |
||
1339 | * @param string $term_id The term ID. |
||
1340 | * @param string $field |
||
1341 | * @param string $old |
||
1342 | * @param string $new |
||
1343 | * @since 1.0 |
||
1344 | * @access public |
||
1345 | */ |
||
1346 | public function save_field_file($term_id, $field, $old, $new) |
||
1380 | |||
1381 | /** |
||
1382 | * Save repeater File Field. |
||
1383 | * @param string $term_id The term ID. |
||
1384 | * @param string $field |
||
1385 | * @param string $old |
||
1386 | * @param string $new |
||
1387 | * @since 1.0 |
||
1388 | * @access public |
||
1389 | * @return int|void |
||
1390 | */ |
||
1391 | public function save_field_file_repeater($term_id, $field, $old, $new) |
||
1422 | |||
1423 | /** |
||
1424 | * Add missed values for meta box. |
||
1425 | * |
||
1426 | * @since 1.0 |
||
1427 | * @access public |
||
1428 | */ |
||
1429 | public function add_missed_values() |
||
1445 | |||
1446 | /** |
||
1447 | * Check if field with $type exists. |
||
1448 | * |
||
1449 | * @param string $type |
||
1450 | * @since 1.0 |
||
1451 | * @access public |
||
1452 | */ |
||
1453 | public function has_field($type) |
||
1463 | |||
1464 | /** |
||
1465 | * Check if current page is edit page. |
||
1466 | * |
||
1467 | * @since 1.0 |
||
1468 | * @access public |
||
1469 | */ |
||
1470 | public function is_edit_page() |
||
1475 | |||
1476 | /** |
||
1477 | * Fixes the odd indexing of multiple file uploads. |
||
1478 | * |
||
1479 | * Goes from the format: |
||
1480 | * $_FILES['field']['key']['index'] |
||
1481 | * to |
||
1482 | * The More standard and appropriate: |
||
1483 | * $_FILES['field']['index']['key'] |
||
1484 | * |
||
1485 | * @param string $files |
||
1486 | * @since 1.0 |
||
1487 | * @access public |
||
1488 | */ |
||
1489 | public function fix_file_array(&$files) |
||
1503 | |||
1504 | /** |
||
1505 | * Get proper JQuery UI version. |
||
1506 | * |
||
1507 | * Used in order to not conflict with WP Admin Scripts. |
||
1508 | * |
||
1509 | * @since 1.0 |
||
1510 | * @access public |
||
1511 | */ |
||
1512 | public function get_jqueryui_ver() |
||
1524 | |||
1525 | /** |
||
1526 | * Add Field to meta box (generic function) |
||
1527 | * @author Ohad Raz |
||
1528 | * @since 1.0 |
||
1529 | * @access public |
||
1530 | * @param $id string field id, i.e. the meta key |
||
1531 | * @param $args mixed|array |
||
1532 | */ |
||
1533 | public function addField($id, $args) |
||
1539 | |||
1540 | |||
1541 | /** |
||
1542 | * Add Text Field to meta box |
||
1543 | * @author Ohad Raz |
||
1544 | * @since 1.0 |
||
1545 | * @access public |
||
1546 | * @param $id string field id, i.e. the meta key |
||
1547 | * @param $args mixed|array |
||
1548 | * 'name' => // field name/label string optional |
||
1549 | * 'desc' => // field description, string optional |
||
1550 | * 'std' => // default value, string optional |
||
1551 | * 'style' => // custom style for field, string optional |
||
1552 | * 'validate_func' => // validate function, string optional |
||
1553 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1554 | */ |
||
1555 | View Code Duplication | public function addText($id, $args, $repeater = false) |
|
1565 | |||
1566 | /** |
||
1567 | * Add Hidden Field to meta box |
||
1568 | * @author Ohad Raz |
||
1569 | * @since 0.1.3 |
||
1570 | * @access public |
||
1571 | * @param $id string field id, i.e. the meta key |
||
1572 | * @param $args mixed|array |
||
1573 | * 'name' => // field name/label string optional |
||
1574 | * 'desc' => // field description, string optional |
||
1575 | * 'std' => // default value, string optional |
||
1576 | * 'style' => // custom style for field, string optional |
||
1577 | * 'validate_func' => // validate function, string optional |
||
1578 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1579 | */ |
||
1580 | View Code Duplication | public function addHidden($id, $args, $repeater = false) |
|
1590 | |||
1591 | /** |
||
1592 | * Add Paragraph to meta box |
||
1593 | * @author Ohad Raz |
||
1594 | * @since 0.1.3 |
||
1595 | * @access public |
||
1596 | * @param $id string field id, i.e. the meta key |
||
1597 | * @param $value paragraph html |
||
1598 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1599 | */ |
||
1600 | public function addParagraph($id, $args, $repeater = false) |
||
1610 | |||
1611 | /** |
||
1612 | * Add Checkbox Field to meta box |
||
1613 | * @author Ohad Raz |
||
1614 | * @since 1.0 |
||
1615 | * @access public |
||
1616 | * @param $id string field id, i.e. the meta key |
||
1617 | * @param $args mixed|array |
||
1618 | * 'name' => // field name/label string optional |
||
1619 | * 'desc' => // field description, string optional |
||
1620 | * 'std' => // default value, string optional |
||
1621 | * 'validate_func' => // validate function, string optional |
||
1622 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1623 | */ |
||
1624 | View Code Duplication | public function addCheckbox($id, $args, $repeater = false) |
|
1634 | |||
1635 | /** |
||
1636 | * Add CheckboxList Field to meta box |
||
1637 | * @author Ohad Raz |
||
1638 | * @since 1.0 |
||
1639 | * @access public |
||
1640 | * @param $id string field id, i.e. the meta key |
||
1641 | * @param $options (array) array of key => value pairs for select options |
||
1642 | * @param $args mixed|array |
||
1643 | * 'name' => // field name/label string optional |
||
1644 | * 'desc' => // field description, string optional |
||
1645 | * 'std' => // default value, string optional |
||
1646 | * 'validate_func' => // validate function, string optional |
||
1647 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1648 | * |
||
1649 | * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false); |
||
1650 | * which means the last param as false to get the values in an array |
||
1651 | */ |
||
1652 | View Code Duplication | public function addCheckboxList($id, $options, $args, $repeater = false) |
|
1662 | |||
1663 | /** |
||
1664 | * Add Textarea Field to meta box |
||
1665 | * @author Ohad Raz |
||
1666 | * @since 1.0 |
||
1667 | * @access public |
||
1668 | * @param $id string field id, i.e. the meta key |
||
1669 | * @param $args mixed|array |
||
1670 | * 'name' => // field name/label string optional |
||
1671 | * 'desc' => // field description, string optional |
||
1672 | * 'std' => // default value, string optional |
||
1673 | * 'style' => // custom style for field, string optional |
||
1674 | * 'validate_func' => // validate function, string optional |
||
1675 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1676 | */ |
||
1677 | View Code Duplication | public function addTextarea($id, $args, $repeater = false) |
|
1687 | |||
1688 | /** |
||
1689 | * Add Select Field to meta box |
||
1690 | * @author Ohad Raz |
||
1691 | * @since 1.0 |
||
1692 | * @access public |
||
1693 | * @param $id string field id, i.e. the meta key |
||
1694 | * @param $options (array) array of key => value pairs for select options |
||
1695 | * @param $args mixed|array |
||
1696 | * 'name' => // field name/label string optional |
||
1697 | * 'desc' => // field description, string optional |
||
1698 | * 'std' => // default value, (array) optional |
||
1699 | * 'multiple' => // select multiple values, optional. Default is false. |
||
1700 | * 'validate_func' => // validate function, string optional |
||
1701 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1702 | */ |
||
1703 | View Code Duplication | public function addSelect($id, $options, $args, $repeater = false) |
|
1713 | |||
1714 | |||
1715 | /** |
||
1716 | * Add Radio Field to meta box |
||
1717 | * @author Ohad Raz |
||
1718 | * @since 1.0 |
||
1719 | * @access public |
||
1720 | * @param $id string field id, i.e. the meta key |
||
1721 | * @param $options (array) array of key => value pairs for radio options |
||
1722 | * @param $args mixed|array |
||
1723 | * 'name' => // field name/label string optional |
||
1724 | * 'desc' => // field description, string optional |
||
1725 | * 'std' => // default value, string optional |
||
1726 | * 'validate_func' => // validate function, string optional |
||
1727 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1728 | */ |
||
1729 | View Code Duplication | public function addRadio($id, $options, $args, $repeater = false) |
|
1739 | |||
1740 | /** |
||
1741 | * Add Date Field to meta box |
||
1742 | * @author Ohad Raz |
||
1743 | * @since 1.0 |
||
1744 | * @access public |
||
1745 | * @param $id string field id, i.e. the meta key |
||
1746 | * @param $args mixed|array |
||
1747 | * 'name' => // field name/label string optional |
||
1748 | * 'desc' => // field description, string optional |
||
1749 | * 'std' => // default value, string optional |
||
1750 | * 'validate_func' => // validate function, string optional |
||
1751 | * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn |
||
1752 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1753 | */ |
||
1754 | View Code Duplication | public function addDate($id, $args, $repeater = false) |
|
1764 | |||
1765 | /** |
||
1766 | * Add Time Field to meta box |
||
1767 | * @author Ohad Raz |
||
1768 | * @since 1.0 |
||
1769 | * @access public |
||
1770 | * @param $id string- field id, i.e. the meta key |
||
1771 | * @param $args mixed|array |
||
1772 | * 'name' => // field name/label string optional |
||
1773 | * 'desc' => // field description, string optional |
||
1774 | * 'std' => // default value, string optional |
||
1775 | * 'validate_func' => // validate function, string optional |
||
1776 | * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX |
||
1777 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1778 | */ |
||
1779 | View Code Duplication | public function addTime($id, $args, $repeater = false) |
|
1789 | |||
1790 | /** |
||
1791 | * Add Color Field to meta box |
||
1792 | * @author Ohad Raz |
||
1793 | * @since 1.0 |
||
1794 | * @access public |
||
1795 | * @param $id string field id, i.e. the meta key |
||
1796 | * @param $args mixed|array |
||
1797 | * 'name' => // field name/label string optional |
||
1798 | * 'desc' => // field description, string optional |
||
1799 | * 'std' => // default value, string optional |
||
1800 | * 'validate_func' => // validate function, string optional |
||
1801 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1802 | */ |
||
1803 | View Code Duplication | public function addColor($id, $args, $repeater = false) |
|
1813 | |||
1814 | /** |
||
1815 | * Add Image Field to meta box |
||
1816 | * @author Ohad Raz |
||
1817 | * @since 1.0 |
||
1818 | * @access public |
||
1819 | * @param $id string field id, i.e. the meta key |
||
1820 | * @param $args mixed|array |
||
1821 | * 'name' => // field name/label string optional |
||
1822 | * 'desc' => // field description, string optional |
||
1823 | * 'validate_func' => // validate function, string optional |
||
1824 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1825 | */ |
||
1826 | View Code Duplication | public function addImage($id, $args, $repeater = false) |
|
1837 | |||
1838 | /** |
||
1839 | * Add File Field to meta box |
||
1840 | * @author Ohad Raz |
||
1841 | * @since 1.0 |
||
1842 | * @access public |
||
1843 | * @param $id string field id, i.e. the meta key |
||
1844 | * @param $args mixed|array |
||
1845 | * 'name' => // field name/label string optional |
||
1846 | * 'desc' => // field description, string optional |
||
1847 | * 'validate_func' => // validate function, string optional |
||
1848 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1849 | */ |
||
1850 | View Code Duplication | public function addFile($id, $args, $repeater = false) |
|
1860 | |||
1861 | /** |
||
1862 | * Add WYSIWYG Field to meta box |
||
1863 | * @author Ohad Raz |
||
1864 | * @since 1.0 |
||
1865 | * @access public |
||
1866 | * @param $id string field id, i.e. the meta key |
||
1867 | * @param $args mixed|array |
||
1868 | * 'name' => // field name/label string optional |
||
1869 | * 'desc' => // field description, string optional |
||
1870 | * 'std' => // default value, string optional |
||
1871 | * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' |
||
1872 | * 'validate_func' => // validate function, string optional |
||
1873 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1874 | */ |
||
1875 | View Code Duplication | public function addWysiwyg($id, $args, $repeater = false) |
|
1885 | |||
1886 | /** |
||
1887 | * Add Taxonomy Field to meta box |
||
1888 | * @author Ohad Raz |
||
1889 | * @since 1.0 |
||
1890 | * @access public |
||
1891 | * @param $id string field id, i.e. the meta key |
||
1892 | * @param $options mixed|array options of taxonomy field |
||
1893 | * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category |
||
1894 | * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' |
||
1895 | * 'args' => // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) |
||
1896 | * @param $args mixed|array |
||
1897 | * 'name' => // field name/label string optional |
||
1898 | * 'desc' => // field description, string optional |
||
1899 | * 'std' => // default value, string optional |
||
1900 | * 'validate_func' => // validate function, string optional |
||
1901 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1902 | */ |
||
1903 | public function addTaxonomy($id, $options, $args, $repeater = false) |
||
1918 | |||
1919 | /** |
||
1920 | * Add posts Field to meta box |
||
1921 | * @author Ohad Raz |
||
1922 | * @since 1.0 |
||
1923 | * @access public |
||
1924 | * @param $id string field id, i.e. the meta key |
||
1925 | * @param $options mixed|array options of taxonomy field |
||
1926 | * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type |
||
1927 | * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' |
||
1928 | * 'args' => // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) |
||
1929 | * @param $args mixed|array |
||
1930 | * 'name' => // field name/label string optional |
||
1931 | * 'desc' => // field description, string optional |
||
1932 | * 'std' => // default value, string optional |
||
1933 | * 'validate_func' => // validate function, string optional |
||
1934 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
1935 | */ |
||
1936 | public function addPosts($id, $options, $args, $repeater = false) |
||
1949 | |||
1950 | /** |
||
1951 | * Add repeater Field Block to meta box |
||
1952 | * @author Ohad Raz |
||
1953 | * @since 1.0 |
||
1954 | * @access public |
||
1955 | * @param $id string field id, i.e. the meta key |
||
1956 | * @param $args mixed|array |
||
1957 | * 'name' => // field name/label string optional |
||
1958 | * 'desc' => // field description, string optional |
||
1959 | * 'std' => // default value, string optional |
||
1960 | * 'style' => // custom style for field, string optional |
||
1961 | * 'validate_func' => // validate function, string optional |
||
1962 | * 'fields' => //fields to repeater |
||
1963 | */ |
||
1964 | public function addRepeaterBlock($id, $args) |
||
1970 | |||
1971 | |||
1972 | /** |
||
1973 | * Finish Declaration of Meta Box |
||
1974 | * @author Ohad Raz |
||
1975 | * @since 1.0 |
||
1976 | * @access public |
||
1977 | */ |
||
1978 | public function Finish() |
||
1986 | |||
1987 | /** |
||
1988 | * Helper function to check for empty arrays |
||
1989 | * @author Ohad Raz |
||
1990 | * @since 1.0 |
||
1991 | * @access public |
||
1992 | * @param $args mixed|array |
||
1993 | */ |
||
1994 | public function is_array_empty($array) |
||
2012 | |||
2013 | |||
2014 | //get term meta field |
||
2015 | View Code Duplication | public function get_tax_meta($term_id, $key, $multi = false, $post_type = '') |
|
2035 | |||
2036 | //delete meta |
||
2037 | public function delete_tax_meta($term_id, $key, $post_type = '') |
||
2055 | |||
2056 | //update meta |
||
2057 | View Code Duplication | public function update_tax_meta($term_id, $key, $value, $post_type = '') |
|
2086 | |||
2087 | |||
2088 | } // End Class |
||
2089 | |||
2161 | } |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..