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 Geodir_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 Geodir_Tax_Meta_Class, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 41 | class Geodir_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) |
||
| 978 | |||
| 979 | /** |
||
| 980 | * Show Color Field. |
||
| 981 | * |
||
| 982 | * @param string $field |
||
| 983 | * @param string $meta |
||
| 984 | * @since 1.0 |
||
| 985 | * @access public |
||
| 986 | */ |
||
| 987 | public function show_field_color($field, $meta) |
||
| 1002 | |||
| 1003 | /** |
||
| 1004 | * Show Checkbox List Field |
||
| 1005 | * |
||
| 1006 | * @param string $field |
||
| 1007 | * @param string $meta |
||
| 1008 | * @since 1.0 |
||
| 1009 | * @access public |
||
| 1010 | */ |
||
| 1011 | public function show_field_checkbox_list($field, $meta) |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * Show Date Field. |
||
| 1033 | * |
||
| 1034 | * @param string $field |
||
| 1035 | * @param string $meta |
||
| 1036 | * @since 1.0 |
||
| 1037 | * @access public |
||
| 1038 | */ |
||
| 1039 | public function show_field_date($field, $meta) |
||
| 1045 | |||
| 1046 | /** |
||
| 1047 | * Show time field. |
||
| 1048 | * |
||
| 1049 | * @param string $field |
||
| 1050 | * @param string $meta |
||
| 1051 | * @since 1.0 |
||
| 1052 | * @access public |
||
| 1053 | */ |
||
| 1054 | public function show_field_time($field, $meta) |
||
| 1060 | |||
| 1061 | /** |
||
| 1062 | * Show Posts field. |
||
| 1063 | * used creating a posts/pages/custom types checkboxlist or a select dropdown |
||
| 1064 | * |
||
| 1065 | * @global object $post The current post object. |
||
| 1066 | * @param string $field |
||
| 1067 | * @param string $meta |
||
| 1068 | * @since 1.0 |
||
| 1069 | * @access public |
||
| 1070 | */ |
||
| 1071 | View Code Duplication | public function show_field_posts($field, $meta) |
|
| 1096 | |||
| 1097 | /** |
||
| 1098 | * Show Taxonomy field. |
||
| 1099 | * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown |
||
| 1100 | * |
||
| 1101 | * @global object $post The current post object. |
||
| 1102 | * @param string $field |
||
| 1103 | * @param string $meta |
||
| 1104 | * @since 1.0 |
||
| 1105 | * @access public |
||
| 1106 | * |
||
| 1107 | * @uses get_terms() |
||
| 1108 | */ |
||
| 1109 | View Code Duplication | public function show_field_taxonomy($field, $meta) |
|
| 1134 | |||
| 1135 | /** |
||
| 1136 | * Save Data from Metabox |
||
| 1137 | * |
||
| 1138 | * @param string $term_id The term ID. |
||
| 1139 | * @since 1.0 |
||
| 1140 | * @access public |
||
| 1141 | * @return string |
||
| 1142 | */ |
||
| 1143 | public function save($term_id) |
||
| 1236 | |||
| 1237 | /** |
||
| 1238 | * Common function for saving fields. |
||
| 1239 | * |
||
| 1240 | * @param string $term_id The term ID. |
||
| 1241 | * @param string $field |
||
| 1242 | * @param string $old |
||
| 1243 | * @param string|mixed $new |
||
| 1244 | * @since 1.0 |
||
| 1245 | * @access public |
||
| 1246 | */ |
||
| 1247 | public function save_field($term_id, $field, $old, $new) |
||
| 1256 | |||
| 1257 | /** |
||
| 1258 | * function for saving image field. |
||
| 1259 | * |
||
| 1260 | * @param string $term_id The term ID. |
||
| 1261 | * @param string $field |
||
| 1262 | * @param string $old |
||
| 1263 | * @param string|mixed $new |
||
| 1264 | * @since 1.0 |
||
| 1265 | * @access public |
||
| 1266 | */ |
||
| 1267 | public function save_field_image($term_id, $field, $old, $new) |
||
| 1277 | |||
| 1278 | /* |
||
| 1279 | * Save Wysiwyg Field. |
||
| 1280 | * |
||
| 1281 | * @param string $term_id The term ID. |
||
| 1282 | * @param string $field |
||
| 1283 | * @param string $old |
||
| 1284 | * @param string $new |
||
| 1285 | * @since 1.0 |
||
| 1286 | * @access public |
||
| 1287 | */ |
||
| 1288 | public function save_field_wysiwyg($term_id, $field, $old, $new) |
||
| 1292 | |||
| 1293 | /** |
||
| 1294 | * Save repeater Fields. |
||
| 1295 | * |
||
| 1296 | * @param string $term_id The term ID. |
||
| 1297 | * @param string $field |
||
| 1298 | * @param string|mixed $old |
||
| 1299 | * @param string|mixed $new |
||
| 1300 | * @since 1.0 |
||
| 1301 | * @access public |
||
| 1302 | */ |
||
| 1303 | public function save_field_repeater($term_id, $field, $old, $new) |
||
| 1334 | |||
| 1335 | /** |
||
| 1336 | * Save File Field. |
||
| 1337 | * |
||
| 1338 | * @param string $term_id The term ID. |
||
| 1339 | * @param string $field |
||
| 1340 | * @param string $old |
||
| 1341 | * @param string $new |
||
| 1342 | * @since 1.0 |
||
| 1343 | * @access public |
||
| 1344 | */ |
||
| 1345 | public function save_field_file($term_id, $field, $old, $new) |
||
| 1379 | |||
| 1380 | /** |
||
| 1381 | * Save repeater File Field. |
||
| 1382 | * @param string $term_id The term ID. |
||
| 1383 | * @param string $field |
||
| 1384 | * @param string $old |
||
| 1385 | * @param string $new |
||
| 1386 | * @since 1.0 |
||
| 1387 | * @access public |
||
| 1388 | * @return int|void |
||
| 1389 | */ |
||
| 1390 | public function save_field_file_repeater($term_id, $field, $old, $new) |
||
| 1421 | |||
| 1422 | /** |
||
| 1423 | * Add missed values for meta box. |
||
| 1424 | * |
||
| 1425 | * @since 1.0 |
||
| 1426 | * @access public |
||
| 1427 | */ |
||
| 1428 | public function add_missed_values() |
||
| 1444 | |||
| 1445 | /** |
||
| 1446 | * Check if field with $type exists. |
||
| 1447 | * |
||
| 1448 | * @param string $type |
||
| 1449 | * @since 1.0 |
||
| 1450 | * @access public |
||
| 1451 | */ |
||
| 1452 | public function has_field($type) |
||
| 1462 | |||
| 1463 | /** |
||
| 1464 | * Check if current page is edit page. |
||
| 1465 | * |
||
| 1466 | * @since 1.0 |
||
| 1467 | * @access public |
||
| 1468 | */ |
||
| 1469 | public function is_edit_page() |
||
| 1474 | |||
| 1475 | /** |
||
| 1476 | * Fixes the odd indexing of multiple file uploads. |
||
| 1477 | * |
||
| 1478 | * Goes from the format: |
||
| 1479 | * $_FILES['field']['key']['index'] |
||
| 1480 | * to |
||
| 1481 | * The More standard and appropriate: |
||
| 1482 | * $_FILES['field']['index']['key'] |
||
| 1483 | * |
||
| 1484 | * @param string $files |
||
| 1485 | * @since 1.0 |
||
| 1486 | * @access public |
||
| 1487 | */ |
||
| 1488 | public function fix_file_array(&$files) |
||
| 1502 | |||
| 1503 | /** |
||
| 1504 | * Get proper JQuery UI version. |
||
| 1505 | * |
||
| 1506 | * Used in order to not conflict with WP Admin Scripts. |
||
| 1507 | * |
||
| 1508 | * @since 1.0 |
||
| 1509 | * @access public |
||
| 1510 | */ |
||
| 1511 | public function get_jqueryui_ver() |
||
| 1523 | |||
| 1524 | /** |
||
| 1525 | * Add Field to meta box (generic function) |
||
| 1526 | * @author Ohad Raz |
||
| 1527 | * @since 1.0 |
||
| 1528 | * @access public |
||
| 1529 | * @param $id string field id, i.e. the meta key |
||
| 1530 | * @param $args mixed|array |
||
| 1531 | */ |
||
| 1532 | public function addField($id, $args) |
||
| 1538 | |||
| 1539 | |||
| 1540 | /** |
||
| 1541 | * Add Text Field to meta box |
||
| 1542 | * @author Ohad Raz |
||
| 1543 | * @since 1.0 |
||
| 1544 | * @access public |
||
| 1545 | * @param $id string field id, i.e. the meta key |
||
| 1546 | * @param $args mixed|array |
||
| 1547 | * 'name' => // field name/label string optional |
||
| 1548 | * 'desc' => // field description, string optional |
||
| 1549 | * 'std' => // default value, string optional |
||
| 1550 | * 'style' => // custom style for field, string optional |
||
| 1551 | * 'validate_func' => // validate function, string optional |
||
| 1552 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1553 | */ |
||
| 1554 | View Code Duplication | public function addText($id, $args, $repeater = false) |
|
| 1564 | |||
| 1565 | /** |
||
| 1566 | * Add Hidden Field to meta box |
||
| 1567 | * @author Ohad Raz |
||
| 1568 | * @since 0.1.3 |
||
| 1569 | * @access public |
||
| 1570 | * @param $id string field id, i.e. the meta key |
||
| 1571 | * @param $args mixed|array |
||
| 1572 | * 'name' => // field name/label string optional |
||
| 1573 | * 'desc' => // field description, string optional |
||
| 1574 | * 'std' => // default value, string optional |
||
| 1575 | * 'style' => // custom style for field, string optional |
||
| 1576 | * 'validate_func' => // validate function, string optional |
||
| 1577 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1578 | */ |
||
| 1579 | View Code Duplication | public function addHidden($id, $args, $repeater = false) |
|
| 1589 | |||
| 1590 | /** |
||
| 1591 | * Add Paragraph to meta box |
||
| 1592 | * @author Ohad Raz |
||
| 1593 | * @since 0.1.3 |
||
| 1594 | * @access public |
||
| 1595 | * @param $id string field id, i.e. the meta key |
||
| 1596 | * @param $value paragraph html |
||
| 1597 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1598 | */ |
||
| 1599 | public function addParagraph($id, $args, $repeater = false) |
||
| 1609 | |||
| 1610 | /** |
||
| 1611 | * Add Checkbox Field to meta box |
||
| 1612 | * @author Ohad Raz |
||
| 1613 | * @since 1.0 |
||
| 1614 | * @access public |
||
| 1615 | * @param $id string field id, i.e. the meta key |
||
| 1616 | * @param $args mixed|array |
||
| 1617 | * 'name' => // field name/label string optional |
||
| 1618 | * 'desc' => // field description, string optional |
||
| 1619 | * 'std' => // default value, string optional |
||
| 1620 | * 'validate_func' => // validate function, string optional |
||
| 1621 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1622 | */ |
||
| 1623 | View Code Duplication | public function addCheckbox($id, $args, $repeater = false) |
|
| 1633 | |||
| 1634 | /** |
||
| 1635 | * Add CheckboxList Field to meta box |
||
| 1636 | * @author Ohad Raz |
||
| 1637 | * @since 1.0 |
||
| 1638 | * @access public |
||
| 1639 | * @param $id string field id, i.e. the meta key |
||
| 1640 | * @param $options (array) array of key => value pairs for select options |
||
| 1641 | * @param $args mixed|array |
||
| 1642 | * 'name' => // field name/label string optional |
||
| 1643 | * 'desc' => // field description, string optional |
||
| 1644 | * 'std' => // default value, string optional |
||
| 1645 | * 'validate_func' => // validate function, string optional |
||
| 1646 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1647 | * |
||
| 1648 | * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false); |
||
| 1649 | * which means the last param as false to get the values in an array |
||
| 1650 | */ |
||
| 1651 | View Code Duplication | public function addCheckboxList($id, $options, $args, $repeater = false) |
|
| 1661 | |||
| 1662 | /** |
||
| 1663 | * Add Textarea Field to meta box |
||
| 1664 | * @author Ohad Raz |
||
| 1665 | * @since 1.0 |
||
| 1666 | * @access public |
||
| 1667 | * @param $id string field id, i.e. the meta key |
||
| 1668 | * @param $args mixed|array |
||
| 1669 | * 'name' => // field name/label string optional |
||
| 1670 | * 'desc' => // field description, string optional |
||
| 1671 | * 'std' => // default value, string optional |
||
| 1672 | * 'style' => // custom style for field, string optional |
||
| 1673 | * 'validate_func' => // validate function, string optional |
||
| 1674 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1675 | */ |
||
| 1676 | View Code Duplication | public function addTextarea($id, $args, $repeater = false) |
|
| 1686 | |||
| 1687 | /** |
||
| 1688 | * Add Select Field to meta box |
||
| 1689 | * @author Ohad Raz |
||
| 1690 | * @since 1.0 |
||
| 1691 | * @access public |
||
| 1692 | * @param $id string field id, i.e. the meta key |
||
| 1693 | * @param $options (array) array of key => value pairs for select options |
||
| 1694 | * @param $args mixed|array |
||
| 1695 | * 'name' => // field name/label string optional |
||
| 1696 | * 'desc' => // field description, string optional |
||
| 1697 | * 'std' => // default value, (array) optional |
||
| 1698 | * 'multiple' => // select multiple values, optional. Default is false. |
||
| 1699 | * 'validate_func' => // validate function, string optional |
||
| 1700 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1701 | */ |
||
| 1702 | View Code Duplication | public function addSelect($id, $options, $args, $repeater = false) |
|
| 1712 | |||
| 1713 | |||
| 1714 | /** |
||
| 1715 | * Add Radio Field to meta box |
||
| 1716 | * @author Ohad Raz |
||
| 1717 | * @since 1.0 |
||
| 1718 | * @access public |
||
| 1719 | * @param $id string field id, i.e. the meta key |
||
| 1720 | * @param $options (array) array of key => value pairs for radio options |
||
| 1721 | * @param $args mixed|array |
||
| 1722 | * 'name' => // field name/label string optional |
||
| 1723 | * 'desc' => // field description, string optional |
||
| 1724 | * 'std' => // default value, string optional |
||
| 1725 | * 'validate_func' => // validate function, string optional |
||
| 1726 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1727 | */ |
||
| 1728 | View Code Duplication | public function addRadio($id, $options, $args, $repeater = false) |
|
| 1738 | |||
| 1739 | /** |
||
| 1740 | * Add Date Field to meta box |
||
| 1741 | * @author Ohad Raz |
||
| 1742 | * @since 1.0 |
||
| 1743 | * @access public |
||
| 1744 | * @param $id string field id, i.e. the meta key |
||
| 1745 | * @param $args mixed|array |
||
| 1746 | * 'name' => // field name/label string optional |
||
| 1747 | * 'desc' => // field description, string optional |
||
| 1748 | * 'std' => // default value, string optional |
||
| 1749 | * 'validate_func' => // validate function, string optional |
||
| 1750 | * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn |
||
| 1751 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1752 | */ |
||
| 1753 | View Code Duplication | public function addDate($id, $args, $repeater = false) |
|
| 1763 | |||
| 1764 | /** |
||
| 1765 | * Add Time Field to meta box |
||
| 1766 | * @author Ohad Raz |
||
| 1767 | * @since 1.0 |
||
| 1768 | * @access public |
||
| 1769 | * @param $id string- field id, i.e. the meta key |
||
| 1770 | * @param $args mixed|array |
||
| 1771 | * 'name' => // field name/label string optional |
||
| 1772 | * 'desc' => // field description, string optional |
||
| 1773 | * 'std' => // default value, string optional |
||
| 1774 | * 'validate_func' => // validate function, string optional |
||
| 1775 | * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX |
||
| 1776 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1777 | */ |
||
| 1778 | View Code Duplication | public function addTime($id, $args, $repeater = false) |
|
| 1788 | |||
| 1789 | /** |
||
| 1790 | * Add Color Field to meta box |
||
| 1791 | * @author Ohad Raz |
||
| 1792 | * @since 1.0 |
||
| 1793 | * @access public |
||
| 1794 | * @param $id string field id, i.e. the meta key |
||
| 1795 | * @param $args mixed|array |
||
| 1796 | * 'name' => // field name/label string optional |
||
| 1797 | * 'desc' => // field description, string optional |
||
| 1798 | * 'std' => // default value, string optional |
||
| 1799 | * 'validate_func' => // validate function, string optional |
||
| 1800 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1801 | */ |
||
| 1802 | View Code Duplication | public function addColor($id, $args, $repeater = false) |
|
| 1812 | |||
| 1813 | /** |
||
| 1814 | * Add Image Field to meta box |
||
| 1815 | * @author Ohad Raz |
||
| 1816 | * @since 1.0 |
||
| 1817 | * @access public |
||
| 1818 | * @param $id string field id, i.e. the meta key |
||
| 1819 | * @param $args mixed|array |
||
| 1820 | * 'name' => // field name/label string optional |
||
| 1821 | * 'desc' => // field description, string optional |
||
| 1822 | * 'validate_func' => // validate function, string optional |
||
| 1823 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1824 | */ |
||
| 1825 | View Code Duplication | public function addImage($id, $args, $repeater = false) |
|
| 1836 | |||
| 1837 | /** |
||
| 1838 | * Add File Field to meta box |
||
| 1839 | * @author Ohad Raz |
||
| 1840 | * @since 1.0 |
||
| 1841 | * @access public |
||
| 1842 | * @param $id string field id, i.e. the meta key |
||
| 1843 | * @param $args mixed|array |
||
| 1844 | * 'name' => // field name/label string optional |
||
| 1845 | * 'desc' => // field description, string optional |
||
| 1846 | * 'validate_func' => // validate function, string optional |
||
| 1847 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1848 | */ |
||
| 1849 | View Code Duplication | public function addFile($id, $args, $repeater = false) |
|
| 1859 | |||
| 1860 | /** |
||
| 1861 | * Add WYSIWYG Field to meta box |
||
| 1862 | * @author Ohad Raz |
||
| 1863 | * @since 1.0 |
||
| 1864 | * @access public |
||
| 1865 | * @param $id string field id, i.e. the meta key |
||
| 1866 | * @param $args mixed|array |
||
| 1867 | * 'name' => // field name/label string optional |
||
| 1868 | * 'desc' => // field description, string optional |
||
| 1869 | * 'std' => // default value, string optional |
||
| 1870 | * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' |
||
| 1871 | * 'validate_func' => // validate function, string optional |
||
| 1872 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1873 | */ |
||
| 1874 | View Code Duplication | public function addWysiwyg($id, $args, $repeater = false) |
|
| 1884 | |||
| 1885 | /** |
||
| 1886 | * Add Taxonomy Field to meta box |
||
| 1887 | * @author Ohad Raz |
||
| 1888 | * @since 1.0 |
||
| 1889 | * @access public |
||
| 1890 | * @param $id string field id, i.e. the meta key |
||
| 1891 | * @param $options mixed|array options of taxonomy field |
||
| 1892 | * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category |
||
| 1893 | * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' |
||
| 1894 | * 'args' => // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) |
||
| 1895 | * @param $args mixed|array |
||
| 1896 | * 'name' => // field name/label string optional |
||
| 1897 | * 'desc' => // field description, string optional |
||
| 1898 | * 'std' => // default value, string optional |
||
| 1899 | * 'validate_func' => // validate function, string optional |
||
| 1900 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1901 | */ |
||
| 1902 | public function addTaxonomy($id, $options, $args, $repeater = false) |
||
| 1917 | |||
| 1918 | /** |
||
| 1919 | * Add posts Field to meta box |
||
| 1920 | * @author Ohad Raz |
||
| 1921 | * @since 1.0 |
||
| 1922 | * @access public |
||
| 1923 | * @param $id string field id, i.e. the meta key |
||
| 1924 | * @param $options mixed|array options of taxonomy field |
||
| 1925 | * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type |
||
| 1926 | * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' |
||
| 1927 | * 'args' => // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) |
||
| 1928 | * @param $args mixed|array |
||
| 1929 | * 'name' => // field name/label string optional |
||
| 1930 | * 'desc' => // field description, string optional |
||
| 1931 | * 'std' => // default value, string optional |
||
| 1932 | * 'validate_func' => // validate function, string optional |
||
| 1933 | * @param $repeater bool is this a field inside a repeatr? true|false(default) |
||
| 1934 | */ |
||
| 1935 | public function addPosts($id, $options, $args, $repeater = false) |
||
| 1948 | |||
| 1949 | /** |
||
| 1950 | * Add repeater Field Block to meta box |
||
| 1951 | * @author Ohad Raz |
||
| 1952 | * @since 1.0 |
||
| 1953 | * @access public |
||
| 1954 | * @param $id string field id, i.e. the meta key |
||
| 1955 | * @param $args mixed|array |
||
| 1956 | * 'name' => // field name/label string optional |
||
| 1957 | * 'desc' => // field description, string optional |
||
| 1958 | * 'std' => // default value, string optional |
||
| 1959 | * 'style' => // custom style for field, string optional |
||
| 1960 | * 'validate_func' => // validate function, string optional |
||
| 1961 | * 'fields' => //fields to repeater |
||
| 1962 | */ |
||
| 1963 | public function addRepeaterBlock($id, $args) |
||
| 1969 | |||
| 1970 | |||
| 1971 | /** |
||
| 1972 | * Finish Declaration of Meta Box |
||
| 1973 | * @author Ohad Raz |
||
| 1974 | * @since 1.0 |
||
| 1975 | * @access public |
||
| 1976 | */ |
||
| 1977 | public function Finish() |
||
| 1985 | |||
| 1986 | /** |
||
| 1987 | * Helper function to check for empty arrays |
||
| 1988 | * @author Ohad Raz |
||
| 1989 | * @since 1.0 |
||
| 1990 | * @access public |
||
| 1991 | * @param $args mixed|array |
||
| 1992 | */ |
||
| 1993 | public function is_array_empty($array) |
||
| 2011 | |||
| 2012 | |||
| 2013 | //get term meta field |
||
| 2014 | public function get_tax_meta($term_id, $key, $multi = false, $post_type = '') |
||
| 2034 | |||
| 2035 | //delete meta |
||
| 2036 | public function delete_tax_meta($term_id, $key, $post_type = '') |
||
| 2054 | |||
| 2055 | //update meta |
||
| 2056 | View Code Duplication | public function update_tax_meta($term_id, $key, $value, $post_type = '') |
|
| 2085 | |||
| 2086 | |||
| 2087 | } // End Class |
||
| 2088 | |||
| 2172 | } |
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..