Complex classes like Pods 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 Pods, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 8 | class Pods implements Iterator { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * Whether the Pods object is in a PHP Iterator call. |
||
| 12 | * |
||
| 13 | * @var bool |
||
| 14 | */ |
||
| 15 | private $iterator = false; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * PodsAPI object. |
||
| 19 | * |
||
| 20 | * @var PodsAPI |
||
| 21 | */ |
||
| 22 | public $api; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * PodsData object. |
||
| 26 | * |
||
| 27 | * @var PodsData |
||
| 28 | */ |
||
| 29 | public $data; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * PodsData object for additional calls. |
||
| 33 | * |
||
| 34 | * @var PodsData |
||
| 35 | */ |
||
| 36 | public $alt_data; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Array of pod item arrays. |
||
| 40 | * |
||
| 41 | * @var array |
||
| 42 | */ |
||
| 43 | public $rows; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Current pod item array. |
||
| 47 | * |
||
| 48 | * @var array |
||
| 49 | */ |
||
| 50 | public $row; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Row number. |
||
| 54 | * |
||
| 55 | * @var int |
||
| 56 | */ |
||
| 57 | private $row_number; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Override pod item array. |
||
| 61 | * |
||
| 62 | * @var array |
||
| 63 | */ |
||
| 64 | public $row_override = array(); |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Whether to display errors on the screen. |
||
| 68 | * |
||
| 69 | * @var bool |
||
| 70 | */ |
||
| 71 | public $display_errors = true; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Current pod information. |
||
| 75 | * |
||
| 76 | * @var array|bool|mixed|null|void |
||
| 77 | */ |
||
| 78 | public $pod_data; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Last used Pods::find() parameters. |
||
| 82 | * |
||
| 83 | * @var array |
||
| 84 | */ |
||
| 85 | public $params = array(); |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Current Pod name. |
||
| 89 | * |
||
| 90 | * @var string |
||
| 91 | */ |
||
| 92 | public $pod; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Current Pod ID. |
||
| 96 | * |
||
| 97 | * @var int |
||
| 98 | */ |
||
| 99 | public $pod_id; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Pod fields information. |
||
| 103 | * |
||
| 104 | * @var array |
||
| 105 | */ |
||
| 106 | public $fields; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Last used filters() parameters. |
||
| 110 | * |
||
| 111 | * @var array |
||
| 112 | */ |
||
| 113 | public $filters = array(); |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Detail page URL used for Advanced Content Types. |
||
| 117 | * |
||
| 118 | * @var string |
||
| 119 | */ |
||
| 120 | public $detail_page; |
||
| 121 | |||
| 122 | /** |
||
| 123 | * Current Item ID. |
||
| 124 | * |
||
| 125 | * @var int |
||
| 126 | */ |
||
| 127 | public $id; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Last used limit from find() lookup. |
||
| 131 | * |
||
| 132 | * @var int |
||
| 133 | */ |
||
| 134 | public $limit = 15; |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Last used offset from find() lookup. |
||
| 138 | * |
||
| 139 | * @var int |
||
| 140 | */ |
||
| 141 | public $offset = 0; |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Query variable used for pagination number. |
||
| 145 | * |
||
| 146 | * @var string |
||
| 147 | */ |
||
| 148 | public $page_var = 'pg'; |
||
| 149 | |||
| 150 | /** |
||
| 151 | * Last used page from find() lookup. |
||
| 152 | * |
||
| 153 | * @var int|mixed |
||
| 154 | */ |
||
| 155 | public $page = 1; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Last used state of whether pagination was enabled from find() lookup. |
||
| 159 | * |
||
| 160 | * @var bool |
||
| 161 | */ |
||
| 162 | public $pagination = true; |
||
| 163 | |||
| 164 | /** |
||
| 165 | * Last used state of whether search was enabled from find() lookup. |
||
| 166 | * |
||
| 167 | * @var bool |
||
| 168 | */ |
||
| 169 | public $search = true; |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Query variable used for search string. |
||
| 173 | * |
||
| 174 | * @var string |
||
| 175 | */ |
||
| 176 | public $search_var = 'search'; |
||
| 177 | |||
| 178 | /** |
||
| 179 | * Search mode (int | text | text_like). |
||
| 180 | * |
||
| 181 | * @var string |
||
| 182 | */ |
||
| 183 | public $search_mode = 'int'; |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Total number of records returned from find() lookup. |
||
| 187 | * |
||
| 188 | * @var int |
||
| 189 | */ |
||
| 190 | public $total = 0; |
||
| 191 | |||
| 192 | /** |
||
| 193 | * Total number of records found from find() lookup. |
||
| 194 | * |
||
| 195 | * @var int |
||
| 196 | */ |
||
| 197 | public $total_found = 0; |
||
| 198 | |||
| 199 | /** |
||
| 200 | * Last used ui options for ui() call. |
||
| 201 | * |
||
| 202 | * @var array |
||
| 203 | */ |
||
| 204 | public $ui = array(); |
||
|
|
|||
| 205 | |||
| 206 | /** |
||
| 207 | * Page template to use for SEO feature in Pods Pages. |
||
| 208 | * |
||
| 209 | * @var string |
||
| 210 | */ |
||
| 211 | public $page_template; |
||
| 212 | |||
| 213 | /** |
||
| 214 | * Body classes to use for SEO feature in Pods Pages. |
||
| 215 | * |
||
| 216 | * @var array |
||
| 217 | */ |
||
| 218 | public $body_classes; |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Meta tags to use for SEO feature in Pods Pages. |
||
| 222 | * |
||
| 223 | * @var array |
||
| 224 | */ |
||
| 225 | public $meta = array(); |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Meta properties to use for SEO feature in Pods Pages. |
||
| 229 | * |
||
| 230 | * @var array |
||
| 231 | */ |
||
| 232 | public $meta_properties = array(); |
||
| 233 | |||
| 234 | /** |
||
| 235 | * Meta custom HTML to use for SEO feature in Pods Pages. |
||
| 236 | * |
||
| 237 | * @var string |
||
| 238 | */ |
||
| 239 | public $meta_extra = ''; |
||
| 240 | |||
| 241 | /** |
||
| 242 | * Last SQL query used by a find() lookup. |
||
| 243 | * |
||
| 244 | * @var string |
||
| 245 | */ |
||
| 246 | public $sql; |
||
| 247 | |||
| 248 | /** |
||
| 249 | * Pods_Deprecated object. |
||
| 250 | * |
||
| 251 | * @var Pods_Deprecated |
||
| 252 | */ |
||
| 253 | public $deprecated; |
||
| 254 | |||
| 255 | /** |
||
| 256 | * Old Pod name variable. |
||
| 257 | * |
||
| 258 | * @var string |
||
| 259 | * |
||
| 260 | * @deprecated 2.0 |
||
| 261 | */ |
||
| 262 | public $datatype; |
||
| 263 | |||
| 264 | /** |
||
| 265 | * Old Pod ID variable. |
||
| 266 | * |
||
| 267 | * @var int |
||
| 268 | * |
||
| 269 | * @deprecated 2.0 |
||
| 270 | */ |
||
| 271 | public $datatype_id; |
||
| 272 | |||
| 273 | /** |
||
| 274 | * Constructor - Pods Framework core. |
||
| 275 | * |
||
| 276 | * @param string $pod The pod name. |
||
| 277 | * @param mixed $id (optional) The ID or slug, to load a single record; Provide array of $params to run 'find'. |
||
| 278 | * |
||
| 279 | * @license http://www.gnu.org/licenses/gpl-2.0.html |
||
| 280 | * @since 1.0.0 |
||
| 281 | * @link https://pods.io/docs/pods/ |
||
| 282 | */ |
||
| 283 | public function __construct( $pod = null, $id = null ) { |
||
| 388 | |||
| 389 | /** |
||
| 390 | * Whether this Pod object is valid or not |
||
| 391 | * |
||
| 392 | * @return bool |
||
| 393 | * |
||
| 394 | * @since 2.0 |
||
| 395 | */ |
||
| 396 | public function valid() { |
||
| 408 | |||
| 409 | /** |
||
| 410 | * Check if in Iterator mode |
||
| 411 | * |
||
| 412 | * @return bool |
||
| 413 | * |
||
| 414 | * @since 2.3.4 |
||
| 415 | * |
||
| 416 | * @link http://www.php.net/manual/en/class.iterator.php |
||
| 417 | */ |
||
| 418 | public function is_iterator() { |
||
| 422 | |||
| 423 | /** |
||
| 424 | * Turn off Iterator mode to off |
||
| 425 | * |
||
| 426 | * @return void |
||
| 427 | * |
||
| 428 | * @since 2.3.4 |
||
| 429 | * |
||
| 430 | * @link http://www.php.net/manual/en/class.iterator.php |
||
| 431 | */ |
||
| 432 | public function stop_iterator() { |
||
| 437 | |||
| 438 | /** |
||
| 439 | * Rewind Iterator |
||
| 440 | * |
||
| 441 | * @since 2.3.4 |
||
| 442 | * |
||
| 443 | * @link http://www.php.net/manual/en/class.iterator.php |
||
| 444 | */ |
||
| 445 | public function rewind() { |
||
| 453 | |||
| 454 | /** |
||
| 455 | * Get current Iterator row |
||
| 456 | * |
||
| 457 | * @return mixed|boolean |
||
| 458 | * |
||
| 459 | * @since 2.3.4 |
||
| 460 | * |
||
| 461 | * @link http://www.php.net/manual/en/class.iterator.php |
||
| 462 | */ |
||
| 463 | public function current() { |
||
| 471 | |||
| 472 | /** |
||
| 473 | * Get current Iterator key |
||
| 474 | * |
||
| 475 | * @return int |
||
| 476 | * |
||
| 477 | * @since 2.3.4 |
||
| 478 | * |
||
| 479 | * @link http://www.php.net/manual/en/class.iterator.php |
||
| 480 | */ |
||
| 481 | public function key() { |
||
| 485 | |||
| 486 | /** |
||
| 487 | * Move onto the next Iterator row |
||
| 488 | * |
||
| 489 | * @return void |
||
| 490 | * |
||
| 491 | * @since 2.3.4 |
||
| 492 | * |
||
| 493 | * @link http://www.php.net/manual/en/class.iterator.php |
||
| 494 | */ |
||
| 495 | public function next() { |
||
| 499 | |||
| 500 | /** |
||
| 501 | * Whether a Pod item exists or not when using fetch() or construct with an ID or slug |
||
| 502 | * |
||
| 503 | * @return bool |
||
| 504 | * |
||
| 505 | * @since 2.0 |
||
| 506 | */ |
||
| 507 | public function exists() { |
||
| 515 | |||
| 516 | /** |
||
| 517 | * Return an array of all rows returned from a find() call. |
||
| 518 | * |
||
| 519 | * Most of the time, you will want to loop through data using fetch() |
||
| 520 | * instead of using this function. |
||
| 521 | * |
||
| 522 | * @return array|bool An array of all rows returned from a find() call, or false if no items returned |
||
| 523 | * |
||
| 524 | * @since 2.0 |
||
| 525 | * @link https://pods.io/docs/data/ |
||
| 526 | */ |
||
| 527 | public function data() { |
||
| 537 | |||
| 538 | /** |
||
| 539 | * Return a field input for a specific field |
||
| 540 | * |
||
| 541 | * @param string|array $field Field name or Field data array. |
||
| 542 | * @param string|array|null $input_name Input field name to use (overrides default name). |
||
| 543 | * @param mixed $value Current value to use. |
||
| 544 | * |
||
| 545 | * @return string Field Input HTML |
||
| 546 | * |
||
| 547 | * @since 2.3.10 |
||
| 548 | */ |
||
| 549 | public function input( $field, $input_name = null, $value = '__null' ) { |
||
| 581 | |||
| 582 | /** |
||
| 583 | * Return field array from a Pod, a field's data, or a field option |
||
| 584 | * |
||
| 585 | * @param null $field Field name. |
||
| 586 | * @param null $option Option name. |
||
| 587 | * |
||
| 588 | * @return bool|mixed |
||
| 589 | * |
||
| 590 | * @since 2.0 |
||
| 591 | */ |
||
| 592 | public function fields( $field = null, $option = null ) { |
||
| 644 | |||
| 645 | /** |
||
| 646 | * Return row array for an item |
||
| 647 | * |
||
| 648 | * @return array|false |
||
| 649 | * |
||
| 650 | * @since 2.0 |
||
| 651 | */ |
||
| 652 | public function row() { |
||
| 662 | |||
| 663 | /** |
||
| 664 | * Return the output for a field. If you want the raw value for use in PHP for custom manipulation, |
||
| 665 | * you will want to use field() instead. This function will automatically convert arrays into a |
||
| 666 | * list of text such as "Rick, John, and Gary" |
||
| 667 | * |
||
| 668 | * @param string|array|object $name The field name, or an associative array of parameters. |
||
| 669 | * @param boolean|array|object $single (optional) For tableless fields, to return an array or the first. |
||
| 670 | * |
||
| 671 | * @return string|null|false The output from the field, null if the field doesn't exist, false if no value returned |
||
| 672 | * for tableless fields |
||
| 673 | * @since 2.0 |
||
| 674 | * @link https://pods.io/docs/display/ |
||
| 675 | */ |
||
| 676 | public function display( $name, $single = null ) { |
||
| 722 | |||
| 723 | /** |
||
| 724 | * Return the raw output for a field If you want the raw value for use in PHP for custom manipulation, |
||
| 725 | * you will want to use field() instead. This function will automatically convert arrays into a |
||
| 726 | * list of text such as "Rick, John, and Gary" |
||
| 727 | * |
||
| 728 | * @param string|array|object $name The field name, or an associative array of parameters. |
||
| 729 | * @param boolean|array|object $single (optional) For tableless fields, to return an array or the first. |
||
| 730 | * |
||
| 731 | * @return string|null|false The output from the field, null if the field doesn't exist, false if no value returned |
||
| 732 | * for tableless fields |
||
| 733 | * @since 2.0 |
||
| 734 | * @link https://pods.io/docs/display/ |
||
| 735 | */ |
||
| 736 | public function raw( $name, $single = null ) { |
||
| 758 | |||
| 759 | /** |
||
| 760 | * Return the value for a field. |
||
| 761 | * |
||
| 762 | * If you are getting a field for output in a theme, most of the time you will want to use display() instead. |
||
| 763 | * |
||
| 764 | * This function will return arrays for relationship and file fields. |
||
| 765 | * |
||
| 766 | * @param string|array|object $name The field name, or an associative array of parameters. |
||
| 767 | * @param boolean|array|object $single For tableless fields, to return the whole array or the just the first item, |
||
| 768 | * or an associative array of parameters. |
||
| 769 | * @param boolean|array|object $raw Whether to return the raw value, or to run through the field type's display |
||
| 770 | * method, or an associative array of parameters. |
||
| 771 | * |
||
| 772 | * @return mixed|null Value returned depends on the field type, null if the field doesn't exist, false if no value |
||
| 773 | * returned for tableless fields. |
||
| 774 | * @since 2.0 |
||
| 775 | * @link https://pods.io/docs/field/ |
||
| 776 | */ |
||
| 777 | public function field( $name, $single = null, $raw = false ) { |
||
| 778 | |||
| 779 | $defaults = array( |
||
| 780 | 'name' => $name, |
||
| 781 | 'orderby' => null, |
||
| 782 | 'single' => $single, |
||
| 783 | 'params' => null, |
||
| 784 | 'in_form' => false, |
||
| 785 | 'raw' => $raw, |
||
| 786 | 'raw_display' => false, |
||
| 787 | 'display' => false, |
||
| 788 | 'get_meta' => false, |
||
| 789 | 'output' => null, |
||
| 790 | 'deprecated' => false, |
||
| 791 | // extra data to send to field handlers. |
||
| 792 | 'args' => array(), |
||
| 793 | ); |
||
| 794 | |||
| 795 | if ( is_object( $name ) ) { |
||
| 796 | $name = get_object_vars( $name ); |
||
| 797 | } |
||
| 798 | |||
| 799 | if ( is_object( $single ) ) { |
||
| 800 | $single = get_object_vars( $single ); |
||
| 801 | } |
||
| 802 | |||
| 803 | if ( is_object( $raw ) ) { |
||
| 804 | $raw = get_object_vars( $raw ); |
||
| 805 | } |
||
| 806 | |||
| 807 | if ( is_array( $name ) ) { |
||
| 808 | $defaults['name'] = null; |
||
| 809 | |||
| 810 | $params = (object) array_merge( $defaults, (array) $name ); |
||
| 811 | } elseif ( is_array( $single ) ) { |
||
| 812 | $defaults['single'] = null; |
||
| 813 | |||
| 814 | $params = (object) array_merge( $defaults, (array) $single ); |
||
| 815 | } elseif ( is_array( $raw ) ) { |
||
| 816 | $defaults['raw'] = false; |
||
| 817 | |||
| 818 | $params = (object) array_merge( $defaults, (array) $raw ); |
||
| 819 | } else { |
||
| 820 | $params = (object) $defaults; |
||
| 821 | }//end if |
||
| 822 | |||
| 823 | if ( $params->in_form ) { |
||
| 824 | $params->output = 'ids'; |
||
| 825 | } elseif ( null === $params->output ) { |
||
| 826 | /** |
||
| 827 | * Override the way related fields are output |
||
| 828 | * |
||
| 829 | * @param string $output How to output related fields. Default is 'arrays'. Options: ids|names|objects|arrays|pods|find |
||
| 830 | * @param array|object $row Current row being outputted. |
||
| 831 | * @param array $params Params array passed to field(). |
||
| 832 | * @param Pods $this Current Pods object. |
||
| 833 | */ |
||
| 834 | $params->output = apply_filters( 'pods_pods_field_related_output_type', 'arrays', $this->row, $params, $this ); |
||
| 835 | } |
||
| 836 | |||
| 837 | if ( in_array( $params->output, array( 'id', 'name', 'object', 'array', 'pod' ), true ) ) { |
||
| 838 | $params->output .= 's'; |
||
| 839 | } |
||
| 840 | |||
| 841 | // Support old $orderby variable. |
||
| 842 | if ( null !== $params->single && is_string( $params->single ) && empty( $params->orderby ) ) { |
||
| 843 | if ( ! class_exists( 'Pod' ) || Pod::$deprecated_notice ) { |
||
| 844 | pods_deprecated( 'Pods::field', '2.0', 'Use $params[ \'orderby\' ] instead' ); |
||
| 845 | } |
||
| 846 | |||
| 847 | $params->orderby = $params->single; |
||
| 848 | $params->single = false; |
||
| 849 | } |
||
| 850 | |||
| 851 | if ( null !== $params->single ) { |
||
| 852 | $params->single = (boolean) $params->single; |
||
| 853 | } |
||
| 854 | |||
| 855 | $params->name = trim( $params->name ); |
||
| 856 | if ( is_array( $params->name ) || '' === $params->name ) { |
||
| 857 | return null; |
||
| 858 | } |
||
| 859 | |||
| 860 | $params->full_name = $params->name; |
||
| 861 | |||
| 862 | $value = null; |
||
| 863 | |||
| 864 | if ( isset( $this->row_override[ $params->name ] ) ) { |
||
| 865 | $value = $this->row_override[ $params->name ]; |
||
| 866 | } |
||
| 867 | |||
| 868 | if ( false === $this->row() ) { |
||
| 869 | if ( false !== $this->data() ) { |
||
| 870 | $this->fetch(); |
||
| 871 | } else { |
||
| 872 | return $value; |
||
| 873 | } |
||
| 874 | } |
||
| 875 | |||
| 876 | if ( $this->data->field_id === $params->name ) { |
||
| 877 | if ( isset( $this->row[ $params->name ] ) ) { |
||
| 878 | return $this->row[ $params->name ]; |
||
| 879 | // @codingStandardsIgnoreLine. |
||
| 880 | } elseif ( null !== $value ) { |
||
| 881 | return $value; |
||
| 882 | } |
||
| 883 | |||
| 884 | return 0; |
||
| 885 | } |
||
| 886 | |||
| 887 | $tableless_field_types = PodsForm::tableless_field_types(); |
||
| 888 | $simple_tableless_objects = PodsForm::simple_tableless_objects(); |
||
| 889 | |||
| 890 | $params->traverse = array(); |
||
| 891 | |||
| 892 | if ( in_array( $params->name, array( |
||
| 893 | '_link', |
||
| 894 | 'detail_url', |
||
| 895 | ), true ) || ( in_array( $params->name, array( |
||
| 896 | 'permalink', |
||
| 897 | 'the_permalink', |
||
| 898 | ), true ) && in_array( $this->pod_data['type'], array( |
||
| 899 | 'post_type', |
||
| 900 | 'taxonomy', |
||
| 901 | 'media', |
||
| 902 | 'user', |
||
| 903 | 'comment', |
||
| 904 | ), true ) ) ) { |
||
| 905 | if ( 0 < strlen( $this->detail_page ) ) { |
||
| 906 | $value = get_home_url() . '/' . $this->do_magic_tags( $this->detail_page ); |
||
| 907 | } elseif ( in_array( $this->pod_data['type'], array( 'post_type', 'media' ), true ) ) { |
||
| 908 | $value = get_permalink( $this->id() ); |
||
| 909 | } elseif ( 'taxonomy' === $this->pod_data['type'] ) { |
||
| 910 | $value = get_term_link( $this->id(), $this->pod_data['name'] ); |
||
| 911 | } elseif ( 'user' === $this->pod_data['type'] ) { |
||
| 912 | $value = get_author_posts_url( $this->id() ); |
||
| 913 | } elseif ( 'comment' === $this->pod_data['type'] ) { |
||
| 914 | $value = get_comment_link( $this->id() ); |
||
| 915 | } |
||
| 916 | } |
||
| 917 | |||
| 918 | $field_data = false; |
||
| 919 | $last_field_data = false; |
||
| 920 | $field_type = false; |
||
| 921 | |||
| 922 | $first_field = explode( '.', $params->name ); |
||
| 923 | $first_field = $first_field[0]; |
||
| 924 | |||
| 925 | if ( isset( $this->fields[ $first_field ] ) ) { |
||
| 926 | $field_data = $this->fields[ $first_field ]; |
||
| 927 | $field_type = 'field'; |
||
| 928 | } elseif ( ! empty( $this->pod_data['object_fields'] ) ) { |
||
| 929 | if ( isset( $this->pod_data['object_fields'][ $first_field ] ) ) { |
||
| 930 | $field_data = $this->pod_data['object_fields'][ $first_field ]; |
||
| 931 | $field_type = 'object_field'; |
||
| 932 | } else { |
||
| 933 | $object_fields = (array) $this->pod_data['object_fields']; |
||
| 934 | |||
| 935 | foreach ( $object_fields as $object_field => $object_field_opt ) { |
||
| 936 | if ( in_array( $first_field, $object_field_opt['alias'], true ) ) { |
||
| 937 | if ( $first_field === $params->name ) { |
||
| 938 | $params->name = $object_field; |
||
| 939 | } |
||
| 940 | |||
| 941 | $first_field = $object_field; |
||
| 942 | $field_data = $object_field_opt; |
||
| 943 | $field_type = 'object_field'; |
||
| 944 | |||
| 945 | break; |
||
| 946 | } |
||
| 947 | } |
||
| 948 | } |
||
| 949 | }//end if |
||
| 950 | |||
| 951 | // Simple fields have no other output options. |
||
| 952 | if ( 'pick' === $field_data['type'] && in_array( $field_data['pick_object'], $simple_tableless_objects, true ) ) { |
||
| 953 | $params->output = 'arrays'; |
||
| 954 | } |
||
| 955 | |||
| 956 | if ( empty( $value ) && in_array( $field_data['type'], $tableless_field_types, true ) ) { |
||
| 957 | $params->raw = true; |
||
| 958 | |||
| 959 | $value = false; |
||
| 960 | |||
| 961 | $row_key = sprintf( '_%s_%s', $params->output, $params->name ); |
||
| 962 | |||
| 963 | if ( 'arrays' !== $params->output && isset( $this->row[ $row_key ] ) ) { |
||
| 964 | $value = $this->row[ '_' . $params->output . '_' . $params->name ]; |
||
| 965 | } elseif ( 'arrays' === $params->output && isset( $this->row[ $params->name ] ) ) { |
||
| 966 | $value = $this->row[ $params->name ]; |
||
| 967 | } |
||
| 968 | |||
| 969 | if ( false !== $value && ! is_array( $value ) && 'pick' === $field_data['type'] && in_array( $field_data['pick_object'], $simple_tableless_objects, true ) ) { |
||
| 970 | $value = PodsForm::field_method( 'pick', 'simple_value', $params->name, $value, $field_data, $this->pod_data, $this->id(), true ); |
||
| 971 | } |
||
| 972 | } |
||
| 973 | |||
| 974 | if ( empty( $value ) && isset( $this->row[ $params->name ] ) && ( ! in_array( $field_data['type'], $tableless_field_types, true ) || 'arrays' === $params->output ) ) { |
||
| 975 | if ( empty( $field_data ) || in_array( $field_data['type'], array( |
||
| 976 | 'boolean', |
||
| 977 | 'number', |
||
| 978 | 'currency', |
||
| 979 | ), true ) ) { |
||
| 980 | $params->raw = true; |
||
| 981 | } |
||
| 982 | |||
| 983 | if ( null === $params->single ) { |
||
| 984 | if ( isset( $this->fields[ $params->name ] ) && ! in_array( $this->fields[ $params->name ]['type'], $tableless_field_types, true ) ) { |
||
| 985 | $params->single = true; |
||
| 986 | } else { |
||
| 987 | $params->single = false; |
||
| 988 | } |
||
| 989 | } |
||
| 990 | |||
| 991 | $value = $this->row[ $params->name ]; |
||
| 992 | } elseif ( empty( $value ) ) { |
||
| 993 | $object_field_found = false; |
||
| 994 | |||
| 995 | if ( 'object_field' === $field_type ) { |
||
| 996 | $object_field_found = true; |
||
| 997 | |||
| 998 | if ( isset( $this->row[ $first_field ] ) ) { |
||
| 999 | $value = $this->row[ $first_field ]; |
||
| 1000 | } elseif ( in_array( $field_data['type'], $tableless_field_types, true ) ) { |
||
| 1001 | $this->fields[ $first_field ] = $field_data; |
||
| 1002 | |||
| 1003 | $object_field_found = false; |
||
| 1004 | } else { |
||
| 1005 | return null; |
||
| 1006 | } |
||
| 1007 | } |
||
| 1008 | |||
| 1009 | if ( 'post_type' === $this->pod_data['type'] && ! isset( $this->fields[ $params->name ] ) ) { |
||
| 1010 | if ( ! isset( $this->fields['post_thumbnail'] ) && ( 'post_thumbnail' === $params->name || 0 === strpos( $params->name, 'post_thumbnail.' ) ) ) { |
||
| 1011 | $size = 'thumbnail'; |
||
| 1012 | |||
| 1013 | if ( 0 === strpos( $params->name, 'post_thumbnail.' ) ) { |
||
| 1014 | $field_names = explode( '.', $params->name ); |
||
| 1015 | |||
| 1016 | if ( isset( $field_names[1] ) ) { |
||
| 1017 | $size = $field_names[1]; |
||
| 1018 | } |
||
| 1019 | } |
||
| 1020 | |||
| 1021 | // Pods will auto-get the thumbnail ID if this isn't an attachment. |
||
| 1022 | $value = pods_image( $this->id(), $size, 0, null, true ); |
||
| 1023 | |||
| 1024 | $object_field_found = true; |
||
| 1025 | } elseif ( ! isset( $this->fields['post_thumbnail_url'] ) && ( 'post_thumbnail_url' === $params->name || 0 === strpos( $params->name, 'post_thumbnail_url.' ) ) ) { |
||
| 1026 | $size = 'thumbnail'; |
||
| 1027 | |||
| 1028 | if ( 0 === strpos( $params->name, 'post_thumbnail_url.' ) ) { |
||
| 1029 | $field_names = explode( '.', $params->name ); |
||
| 1030 | |||
| 1031 | if ( isset( $field_names[1] ) ) { |
||
| 1032 | $size = $field_names[1]; |
||
| 1033 | } |
||
| 1034 | } |
||
| 1035 | |||
| 1036 | // Pods will auto-get the thumbnail ID if this isn't an attachment. |
||
| 1037 | $value = pods_image_url( $this->id(), $size, 0, true ); |
||
| 1038 | |||
| 1039 | $object_field_found = true; |
||
| 1040 | } elseif ( 0 === strpos( $params->name, 'image_attachment.' ) ) { |
||
| 1041 | $size = 'thumbnail'; |
||
| 1042 | |||
| 1043 | $image_id = 0; |
||
| 1044 | |||
| 1045 | $field_names = explode( '.', $params->name ); |
||
| 1046 | |||
| 1047 | if ( isset( $field_names[1] ) ) { |
||
| 1048 | $image_id = $field_names[1]; |
||
| 1049 | } |
||
| 1050 | |||
| 1051 | if ( isset( $field_names[2] ) ) { |
||
| 1052 | $size = $field_names[2]; |
||
| 1053 | } |
||
| 1054 | |||
| 1055 | if ( ! empty( $image_id ) ) { |
||
| 1056 | $value = pods_image( $image_id, $size, 0, null, true ); |
||
| 1057 | |||
| 1058 | if ( ! empty( $value ) ) { |
||
| 1059 | $object_field_found = true; |
||
| 1060 | } |
||
| 1061 | } |
||
| 1062 | } elseif ( 0 === strpos( $params->name, 'image_attachment_url.' ) ) { |
||
| 1063 | $size = 'thumbnail'; |
||
| 1064 | |||
| 1065 | $image_id = 0; |
||
| 1066 | |||
| 1067 | $field_names = explode( '.', $params->name ); |
||
| 1068 | |||
| 1069 | if ( isset( $field_names[1] ) ) { |
||
| 1070 | $image_id = $field_names[1]; |
||
| 1071 | } |
||
| 1072 | |||
| 1073 | if ( isset( $field_names[2] ) ) { |
||
| 1074 | $size = $field_names[2]; |
||
| 1075 | } |
||
| 1076 | |||
| 1077 | if ( ! empty( $image_id ) ) { |
||
| 1078 | $value = pods_image_url( $image_id, $size, 0, true ); |
||
| 1079 | |||
| 1080 | if ( ! empty( $value ) ) { |
||
| 1081 | $object_field_found = true; |
||
| 1082 | } |
||
| 1083 | } |
||
| 1084 | }//end if |
||
| 1085 | } elseif ( 'user' === $this->pod_data['type'] && ! isset( $this->fields[ $params->name ] ) ) { |
||
| 1086 | if ( ! isset( $this->fields['avatar'] ) && ( 'avatar' === $params->name || 0 === strpos( $params->name, 'avatar.' ) ) ) { |
||
| 1087 | $size = null; |
||
| 1088 | |||
| 1089 | if ( 0 === strpos( $params->name, 'avatar.' ) ) { |
||
| 1090 | $field_names = explode( '.', $params->name ); |
||
| 1091 | |||
| 1092 | if ( isset( $field_names[1] ) ) { |
||
| 1093 | $size = (int) $field_names[1]; |
||
| 1094 | } |
||
| 1095 | } |
||
| 1096 | |||
| 1097 | if ( 0 < $size ) { |
||
| 1098 | $value = get_avatar( $this->id(), $size ); |
||
| 1099 | } else { |
||
| 1100 | $value = get_avatar( $this->id() ); |
||
| 1101 | } |
||
| 1102 | |||
| 1103 | $object_field_found = true; |
||
| 1104 | } |
||
| 1105 | } elseif ( 0 === strpos( $params->name, 'image_attachment.' ) ) { |
||
| 1106 | $size = 'thumbnail'; |
||
| 1107 | |||
| 1108 | $image_id = 0; |
||
| 1109 | |||
| 1110 | $field_names = explode( '.', $params->name ); |
||
| 1111 | |||
| 1112 | if ( isset( $field_names[1] ) ) { |
||
| 1113 | $image_id = $field_names[1]; |
||
| 1114 | } |
||
| 1115 | |||
| 1116 | if ( isset( $field_names[2] ) ) { |
||
| 1117 | $size = $field_names[2]; |
||
| 1118 | } |
||
| 1119 | |||
| 1120 | if ( ! empty( $image_id ) ) { |
||
| 1121 | $value = pods_image( $image_id, $size, 0, null, true ); |
||
| 1122 | |||
| 1123 | if ( ! empty( $value ) ) { |
||
| 1124 | $object_field_found = true; |
||
| 1125 | } |
||
| 1126 | } |
||
| 1127 | } elseif ( 0 === strpos( $params->name, 'image_attachment_url.' ) ) { |
||
| 1128 | $size = 'thumbnail'; |
||
| 1129 | |||
| 1130 | $image_id = 0; |
||
| 1131 | |||
| 1132 | $field_names = explode( '.', $params->name ); |
||
| 1133 | |||
| 1134 | if ( isset( $field_names[1] ) ) { |
||
| 1135 | $image_id = $field_names[1]; |
||
| 1136 | } |
||
| 1137 | |||
| 1138 | if ( isset( $field_names[2] ) ) { |
||
| 1139 | $size = $field_names[2]; |
||
| 1140 | } |
||
| 1141 | |||
| 1142 | if ( ! empty( $image_id ) ) { |
||
| 1143 | $value = pods_image_url( $image_id, $size, 0, true ); |
||
| 1144 | |||
| 1145 | if ( ! empty( $value ) ) { |
||
| 1146 | $object_field_found = true; |
||
| 1147 | } |
||
| 1148 | } |
||
| 1149 | }//end if |
||
| 1150 | |||
| 1151 | if ( false === $object_field_found ) { |
||
| 1152 | $params->traverse = array( $params->name ); |
||
| 1153 | |||
| 1154 | if ( false !== strpos( $params->name, '.' ) ) { |
||
| 1155 | $params->traverse = explode( '.', $params->name ); |
||
| 1156 | |||
| 1157 | $params->name = $params->traverse[0]; |
||
| 1158 | } |
||
| 1159 | |||
| 1160 | if ( isset( $this->fields[ $params->name ], $this->fields[ $params->name ]['type'] ) ) { |
||
| 1161 | /** |
||
| 1162 | * Modify value returned by field() after its retrieved, but before its validated or formatted |
||
| 1163 | * |
||
| 1164 | * Filter name is set dynamically with name of field: "pods_pods_field_{field_name}" |
||
| 1165 | * |
||
| 1166 | * @since unknown |
||
| 1167 | * |
||
| 1168 | * @param array|string|null $value Value retrieved. |
||
| 1169 | * @param array|object $row Current row being outputted. |
||
| 1170 | * @param array $params Params array passed to field(). |
||
| 1171 | * @param object|Pods $this Current Pods object. |
||
| 1172 | */ |
||
| 1173 | $v = apply_filters( 'pods_pods_field_' . $this->fields[ $params->name ]['type'], null, $this->fields[ $params->name ], $this->row, $params, $this ); |
||
| 1174 | |||
| 1175 | if ( null !== $v ) { |
||
| 1176 | return $v; |
||
| 1177 | } |
||
| 1178 | } |
||
| 1179 | |||
| 1180 | $simple = false; |
||
| 1181 | |||
| 1182 | if ( isset( $this->fields[ $params->name ] ) ) { |
||
| 1183 | if ( 'meta' === $this->pod_data['storage'] && ! in_array( $this->fields[ $params->name ]['type'], $tableless_field_types, true ) ) { |
||
| 1184 | $simple = true; |
||
| 1185 | } |
||
| 1186 | |||
| 1187 | if ( in_array( $this->fields[ $params->name ]['type'], $tableless_field_types, true ) ) { |
||
| 1188 | $params->raw = true; |
||
| 1189 | |||
| 1190 | if ( 'pick' === $this->fields[ $params->name ]['type'] && in_array( $this->fields[ $params->name ]['pick_object'], $simple_tableless_objects, true ) ) { |
||
| 1191 | $simple = true; |
||
| 1192 | $params->single = true; |
||
| 1193 | } |
||
| 1194 | } elseif ( in_array( $this->fields[ $params->name ]['type'], array( |
||
| 1195 | 'boolean', |
||
| 1196 | 'number', |
||
| 1197 | 'currency', |
||
| 1198 | ), true ) ) { |
||
| 1199 | $params->raw = true; |
||
| 1200 | } |
||
| 1201 | } |
||
| 1202 | |||
| 1203 | $is_field_set = isset( $this->fields[ $params->name ] ); |
||
| 1204 | $is_tableless_field = false; |
||
| 1205 | |||
| 1206 | if ( $is_field_set ) { |
||
| 1207 | $is_tableless_field = in_array( $this->fields[ $params->name ]['type'], $tableless_field_types, true ); |
||
| 1208 | } |
||
| 1209 | |||
| 1210 | if ( $simple || ! $is_field_set || ! $is_tableless_field ) { |
||
| 1211 | if ( null === $params->single ) { |
||
| 1212 | if ( $is_field_set && ! $is_tableless_field ) { |
||
| 1213 | $params->single = true; |
||
| 1214 | } else { |
||
| 1215 | $params->single = false; |
||
| 1216 | } |
||
| 1217 | } |
||
| 1218 | |||
| 1219 | $no_conflict = pods_no_conflict_check( $this->pod_data['type'] ); |
||
| 1220 | |||
| 1221 | if ( ! $no_conflict ) { |
||
| 1222 | pods_no_conflict_on( $this->pod_data['type'] ); |
||
| 1223 | } |
||
| 1224 | |||
| 1225 | if ( in_array( $this->pod_data['type'], array( |
||
| 1226 | 'post_type', |
||
| 1227 | 'media', |
||
| 1228 | 'taxonomy', |
||
| 1229 | 'user', |
||
| 1230 | 'comment', |
||
| 1231 | ), true ) ) { |
||
| 1232 | $id = $this->id(); |
||
| 1233 | |||
| 1234 | $metadata_type = $this->pod_data['type']; |
||
| 1235 | |||
| 1236 | if ( in_array( $this->pod_data['type'], array( 'post_type', 'media' ), true ) ) { |
||
| 1237 | $metadata_type = 'post'; |
||
| 1238 | |||
| 1239 | // Support for WPML 'duplicated' translation handling. |
||
| 1240 | if ( did_action( 'wpml_loaded' ) && apply_filters( 'wpml_is_translated_post_type', false, $this->pod_data['name'] ) ) { |
||
| 1241 | $master_post_id = (int) apply_filters( 'wpml_master_post_from_duplicate', $id ); |
||
| 1242 | |||
| 1243 | if ( 0 < $master_post_id ) { |
||
| 1244 | $id = $master_post_id; |
||
| 1245 | } |
||
| 1246 | } |
||
| 1247 | } elseif ( 'taxonomy' === $this->pod_data['type'] ) { |
||
| 1248 | $metadata_type = 'term'; |
||
| 1249 | } |
||
| 1250 | |||
| 1251 | $value = get_metadata( $metadata_type, $id, $params->name, $params->single ); |
||
| 1252 | |||
| 1253 | $single_multi = 'single'; |
||
| 1254 | |||
| 1255 | if ( $is_field_set ) { |
||
| 1256 | $single_multi = pods_v( $this->fields[ $params->name ]['type'] . '_format_type', $this->fields[ $params->name ]['options'], $single_multi ); |
||
| 1257 | } |
||
| 1258 | |||
| 1259 | if ( $simple && ! is_array( $value ) && 'single' !== $single_multi ) { |
||
| 1260 | $value = get_metadata( $metadata_type, $id, $params->name ); |
||
| 1261 | } |
||
| 1262 | } elseif ( 'settings' === $this->pod_data['type'] ) { |
||
| 1263 | $value = get_option( $this->pod_data['name'] . '_' . $params->name, null ); |
||
| 1264 | }//end if |
||
| 1265 | |||
| 1266 | // Handle Simple Relationships. |
||
| 1267 | if ( $simple ) { |
||
| 1268 | if ( null === $params->single ) { |
||
| 1269 | $params->single = false; |
||
| 1270 | } |
||
| 1271 | |||
| 1272 | $value = PodsForm::field_method( 'pick', 'simple_value', $params->name, $value, $this->fields[ $params->name ], $this->pod_data, $this->id(), true ); |
||
| 1273 | } |
||
| 1274 | |||
| 1275 | if ( ! $no_conflict ) { |
||
| 1276 | pods_no_conflict_off( $this->pod_data['type'] ); |
||
| 1277 | } |
||
| 1278 | } else { |
||
| 1279 | // Dot-traversal. |
||
| 1280 | $pod = $this->pod; |
||
| 1281 | $ids = array( $this->id() ); |
||
| 1282 | $all_fields = array(); |
||
| 1283 | |||
| 1284 | $lookup = $params->traverse; |
||
| 1285 | |||
| 1286 | // Get fields matching traversal names. |
||
| 1287 | if ( ! empty( $lookup ) ) { |
||
| 1288 | $fields = $this->api->load_fields( array( |
||
| 1289 | 'name' => $lookup, |
||
| 1290 | 'type' => $tableless_field_types, |
||
| 1291 | 'object_fields' => true, |
||
| 1292 | // @todo support object fields too. |
||
| 1293 | ) ); |
||
| 1294 | |||
| 1295 | if ( ! empty( $fields ) ) { |
||
| 1296 | foreach ( $fields as $field ) { |
||
| 1297 | if ( ! empty( $field ) ) { |
||
| 1298 | if ( ! isset( $all_fields[ $field['pod'] ] ) ) { |
||
| 1299 | $all_fields[ $field['pod'] ] = array(); |
||
| 1300 | } |
||
| 1301 | |||
| 1302 | $all_fields[ $field['pod'] ][ $field['name'] ] = $field; |
||
| 1303 | } |
||
| 1304 | } |
||
| 1305 | } |
||
| 1306 | |||
| 1307 | if ( ! empty( $this->pod_data['object_fields'] ) ) { |
||
| 1308 | $object_fields = (array) $this->pod_data['object_fields']; |
||
| 1309 | |||
| 1310 | foreach ( $object_fields as $object_field => $object_field_opt ) { |
||
| 1311 | if ( in_array( $object_field_opt['type'], $tableless_field_types, true ) ) { |
||
| 1312 | $all_fields[ $this->pod ][ $object_field ] = $object_field_opt; |
||
| 1313 | } |
||
| 1314 | } |
||
| 1315 | } |
||
| 1316 | }//end if |
||
| 1317 | |||
| 1318 | $last_type = ''; |
||
| 1319 | $last_object = ''; |
||
| 1320 | $last_pick_val = ''; |
||
| 1321 | |||
| 1322 | $single_multi = pods_v( $this->fields[ $params->name ]['type'] . '_format_type', $this->fields[ $params->name ]['options'], 'single' ); |
||
| 1323 | |||
| 1324 | if ( 'multi' === $single_multi ) { |
||
| 1325 | $limit = (int) pods_v( $this->fields[ $params->name ]['type'] . '_limit', $this->fields[ $params->name ]['options'], 0 ); |
||
| 1326 | } else { |
||
| 1327 | $limit = 1; |
||
| 1328 | } |
||
| 1329 | |||
| 1330 | // Loop through each traversal level. |
||
| 1331 | foreach ( $params->traverse as $key => $field ) { |
||
| 1332 | $last_loop = false; |
||
| 1333 | |||
| 1334 | if ( count( $params->traverse ) <= ( $key + 1 ) ) { |
||
| 1335 | $last_loop = true; |
||
| 1336 | } |
||
| 1337 | |||
| 1338 | $field_exists = isset( $all_fields[ $pod ][ $field ] ); |
||
| 1339 | |||
| 1340 | $simple = false; |
||
| 1341 | $last_options = array(); |
||
| 1342 | |||
| 1343 | if ( $field_exists && 'pick' === $all_fields[ $pod ][ $field ]['type'] && in_array( $all_fields[ $pod ][ $field ]['pick_object'], $simple_tableless_objects, true ) ) { |
||
| 1344 | $simple = true; |
||
| 1345 | $last_options = $all_fields[ $pod ][ $field ]; |
||
| 1346 | } |
||
| 1347 | |||
| 1348 | // Tableless handler. |
||
| 1349 | if ( $field_exists && ( ! $simple || ! in_array( $all_fields[ $pod ][ $field ]['type'], array( |
||
| 1350 | 'pick', |
||
| 1351 | 'taxonomy', |
||
| 1352 | 'comment', |
||
| 1353 | ), true ) ) ) { |
||
| 1354 | $type = $all_fields[ $pod ][ $field ]['type']; |
||
| 1355 | $pick_object = $all_fields[ $pod ][ $field ]['pick_object']; |
||
| 1356 | $pick_val = $all_fields[ $pod ][ $field ]['pick_val']; |
||
| 1357 | |||
| 1358 | if ( 'table' === $pick_object ) { |
||
| 1359 | $pick_val = pods_v( 'pick_table', $all_fields[ $pod ][ $field ]['options'], $pick_val, true ); |
||
| 1360 | } elseif ( '__current__' === $pick_val ) { |
||
| 1361 | $pick_val = $pod; |
||
| 1362 | } |
||
| 1363 | |||
| 1364 | $last_limit = 0; |
||
| 1365 | |||
| 1366 | if ( in_array( $type, $tableless_field_types, true ) ) { |
||
| 1367 | $single_multi = pods_v( "{$type}_format_type", $all_fields[ $pod ][ $field ]['options'], 'single' ); |
||
| 1368 | |||
| 1369 | if ( 'multi' === $single_multi ) { |
||
| 1370 | $last_limit = (int) pods_v( "{$type}_limit", $all_fields[ $pod ][ $field ]['options'], 0 ); |
||
| 1371 | } else { |
||
| 1372 | $last_limit = 1; |
||
| 1373 | } |
||
| 1374 | } |
||
| 1375 | |||
| 1376 | $last_type = $type; |
||
| 1377 | $last_object = $pick_object; |
||
| 1378 | $last_pick_val = $pick_val; |
||
| 1379 | $last_options = $all_fields[ $pod ][ $field ]; |
||
| 1380 | |||
| 1381 | // Temporary hack until there's some better handling here. |
||
| 1382 | $last_limit *= count( $ids ); |
||
| 1383 | |||
| 1384 | // Get related IDs. |
||
| 1385 | if ( ! isset( $all_fields[ $pod ][ $field ]['pod_id'] ) ) { |
||
| 1386 | $all_fields[ $pod ][ $field ]['pod_id'] = 0; |
||
| 1387 | } |
||
| 1388 | |||
| 1389 | if ( isset( $all_fields[ $pod ][ $field ]['id'] ) ) { |
||
| 1390 | $ids = $this->api->lookup_related_items( $all_fields[ $pod ][ $field ]['id'], $all_fields[ $pod ][ $field ]['pod_id'], $ids, $all_fields[ $pod ][ $field ] ); |
||
| 1391 | } |
||
| 1392 | |||
| 1393 | // No items found. |
||
| 1394 | if ( empty( $ids ) ) { |
||
| 1395 | return false; |
||
| 1396 | } elseif ( 0 < $last_limit ) { |
||
| 1397 | // @todo This should return array() if not $params->single. |
||
| 1398 | $ids = array_slice( $ids, 0, $last_limit ); |
||
| 1399 | } |
||
| 1400 | |||
| 1401 | // Get $pod if related to a Pod. |
||
| 1402 | if ( ! empty( $pick_object ) && ( ! empty( $pick_val ) || in_array( $pick_object, array( |
||
| 1403 | 'user', |
||
| 1404 | 'media', |
||
| 1405 | 'comment', |
||
| 1406 | ), true ) ) ) { |
||
| 1407 | if ( 'pod' === $pick_object ) { |
||
| 1408 | $pod = $pick_val; |
||
| 1409 | } else { |
||
| 1410 | $check = $this->api->get_table_info( $pick_object, $pick_val ); |
||
| 1411 | |||
| 1412 | if ( ! empty( $check ) && ! empty( $check['pod'] ) ) { |
||
| 1413 | $pod = $check['pod']['name']; |
||
| 1414 | } |
||
| 1415 | } |
||
| 1416 | } |
||
| 1417 | } else { |
||
| 1418 | // Assume last iteration. |
||
| 1419 | if ( 0 === $key ) { |
||
| 1420 | // Invalid field. |
||
| 1421 | return false; |
||
| 1422 | } |
||
| 1423 | |||
| 1424 | $last_loop = true; |
||
| 1425 | }//end if |
||
| 1426 | |||
| 1427 | if ( $last_loop ) { |
||
| 1428 | $object_type = $last_object; |
||
| 1429 | $object = $last_pick_val; |
||
| 1430 | |||
| 1431 | if ( in_array( $last_type, PodsForm::file_field_types(), true ) ) { |
||
| 1432 | $object_type = 'media'; |
||
| 1433 | $object = 'attachment'; |
||
| 1434 | } |
||
| 1435 | |||
| 1436 | $data = array(); |
||
| 1437 | |||
| 1438 | $table = $this->api->get_table_info( $object_type, $object, null, null, $last_options ); |
||
| 1439 | |||
| 1440 | $join = array(); |
||
| 1441 | $where = array(); |
||
| 1442 | |||
| 1443 | if ( ! empty( $table['join'] ) ) { |
||
| 1444 | $join = (array) $table['join']; |
||
| 1445 | } |
||
| 1446 | |||
| 1447 | if ( ! empty( $ids ) || ! empty( $table['where'] ) ) { |
||
| 1448 | foreach ( $ids as $id ) { |
||
| 1449 | $where[ $id ] = '`t`.`' . $table['field_id'] . '` = ' . (int) $id; |
||
| 1450 | } |
||
| 1451 | |||
| 1452 | if ( ! empty( $where ) ) { |
||
| 1453 | $where = array( implode( ' OR ', $where ) ); |
||
| 1454 | } |
||
| 1455 | |||
| 1456 | if ( ! empty( $table['where'] ) ) { |
||
| 1457 | // @codingStandardsIgnoreLine. |
||
| 1458 | $where = array_merge( $where, array_values( (array) $table['where'] ) ); |
||
| 1459 | } |
||
| 1460 | } |
||
| 1461 | |||
| 1462 | /** |
||
| 1463 | * Related object. |
||
| 1464 | * |
||
| 1465 | * @var $related_obj Pods|false |
||
| 1466 | */ |
||
| 1467 | $related_obj = false; |
||
| 1468 | |||
| 1469 | // Check if we can return the full object/array or if we need to traverse into it. |
||
| 1470 | $is_field_output_full = false; |
||
| 1471 | |||
| 1472 | if ( false !== $field_exists && ( in_array( $last_type, $tableless_field_types, true ) && ! $simple ) ) { |
||
| 1473 | $is_field_output_full = true; |
||
| 1474 | } |
||
| 1475 | |||
| 1476 | if ( 'pod' === $object_type ) { |
||
| 1477 | $related_obj = pods( $object, null, false ); |
||
| 1478 | } elseif ( ! empty( $table['pod'] ) ) { |
||
| 1479 | $related_obj = pods( $table['pod']['name'], null, false ); |
||
| 1480 | } |
||
| 1481 | |||
| 1482 | if ( $related_obj || ! empty( $table['table'] ) ) { |
||
| 1483 | $sql = array( |
||
| 1484 | 'select' => '*, `t`.`' . $table['field_id'] . '` AS `pod_item_id`', |
||
| 1485 | 'table' => $table['table'], |
||
| 1486 | 'join' => $join, |
||
| 1487 | 'where' => $where, |
||
| 1488 | 'orderby' => $params->orderby, |
||
| 1489 | 'pagination' => false, |
||
| 1490 | 'search' => false, |
||
| 1491 | 'limit' => - 1, |
||
| 1492 | 'expires' => 180, |
||
| 1493 | // @todo This could potentially cause issues if someone changes the data within this time and persistent storage is used. |
||
| 1494 | ); |
||
| 1495 | |||
| 1496 | if ( ! empty( $table['where_default'] ) ) { |
||
| 1497 | $sql['where_default'] = $table['where_default']; |
||
| 1498 | } |
||
| 1499 | |||
| 1500 | // Output types. |
||
| 1501 | if ( in_array( $params->output, array( 'ids', 'objects', 'pods' ), true ) ) { |
||
| 1502 | $sql['select'] = '`t`.`' . $table['field_id'] . '` AS `pod_item_id`'; |
||
| 1503 | } elseif ( 'names' === $params->output && ! empty( $table['field_index'] ) ) { |
||
| 1504 | $sql['select'] = '`t`.`' . $table['field_index'] . '` AS `pod_item_index`, `t`.`' . $table['field_id'] . '` AS `pod_item_id`'; |
||
| 1505 | } |
||
| 1506 | |||
| 1507 | if ( ! empty( $params->params ) && is_array( $params->params ) ) { |
||
| 1508 | $where = $sql['where']; |
||
| 1509 | |||
| 1510 | // @codingStandardsIgnoreLine. |
||
| 1511 | $sql = array_merge( $sql, $params->params ); |
||
| 1512 | |||
| 1513 | if ( isset( $params->params['where'] ) ) { |
||
| 1514 | // @codingStandardsIgnoreLine. |
||
| 1515 | $sql['where'] = array_merge( (array) $where, (array) $params->params['where'] ); |
||
| 1516 | } |
||
| 1517 | } |
||
| 1518 | |||
| 1519 | $item_data = array(); |
||
| 1520 | |||
| 1521 | if ( ! $related_obj ) { |
||
| 1522 | if ( ! is_object( $this->alt_data ) ) { |
||
| 1523 | $this->alt_data = pods_data( null, 0, true, true ); |
||
| 1524 | } |
||
| 1525 | |||
| 1526 | $item_data = $this->alt_data->select( $sql ); |
||
| 1527 | } else { |
||
| 1528 | // Support 'find' output ordering. |
||
| 1529 | if ( $ids && 'find' === $params->output && $is_field_output_full && empty( $sql['orderby'] ) ) { |
||
| 1530 | // Handle default orderby for ordering by the IDs. |
||
| 1531 | $order_ids = implode( ', ', array_map( 'absint', $ids ) ); |
||
| 1532 | |||
| 1533 | $sql['orderby'] = 'FIELD( `t`.`' . $table['field_id'] . '`, ' . $order_ids . ' )'; |
||
| 1534 | } |
||
| 1535 | |||
| 1536 | $related_obj->find( $sql ); |
||
| 1537 | |||
| 1538 | // Support 'find' output. |
||
| 1539 | if ( 'find' === $params->output && $is_field_output_full ) { |
||
| 1540 | $data = $related_obj; |
||
| 1541 | |||
| 1542 | $is_field_output_full = true; |
||
| 1543 | } else { |
||
| 1544 | $item_data = $related_obj->data(); |
||
| 1545 | } |
||
| 1546 | }//end if |
||
| 1547 | |||
| 1548 | $items = array(); |
||
| 1549 | |||
| 1550 | if ( ! empty( $item_data ) ) { |
||
| 1551 | foreach ( $item_data as $item ) { |
||
| 1552 | if ( is_array( $item ) ) { |
||
| 1553 | $item = (object) $item; |
||
| 1554 | } |
||
| 1555 | |||
| 1556 | if ( empty( $item->pod_item_id ) ) { |
||
| 1557 | continue; |
||
| 1558 | } |
||
| 1559 | |||
| 1560 | // Bypass pass field. |
||
| 1561 | if ( isset( $item->user_pass ) ) { |
||
| 1562 | unset( $item->user_pass ); |
||
| 1563 | } |
||
| 1564 | |||
| 1565 | // Get Item ID. |
||
| 1566 | $item_id = $item->pod_item_id; |
||
| 1567 | |||
| 1568 | // Output types. |
||
| 1569 | if ( 'ids' === $params->output ) { |
||
| 1570 | $item = (int) $item_id; |
||
| 1571 | } elseif ( 'names' === $params->output && ! empty( $table['field_index'] ) ) { |
||
| 1572 | $item = $item->pod_item_index; |
||
| 1573 | } elseif ( 'objects' === $params->output ) { |
||
| 1574 | if ( in_array( $object_type, array( 'post_type', 'media' ), true ) ) { |
||
| 1575 | $item = get_post( $item_id ); |
||
| 1576 | } elseif ( 'taxonomy' === $object_type ) { |
||
| 1577 | $item = get_term( $item_id, $object ); |
||
| 1578 | } elseif ( 'user' === $object_type ) { |
||
| 1579 | $item = get_userdata( $item_id ); |
||
| 1580 | |||
| 1581 | if ( ! empty( $item ) ) { |
||
| 1582 | // Get other vars. |
||
| 1583 | $roles = $item->roles; |
||
| 1584 | $caps = $item->caps; |
||
| 1585 | $allcaps = $item->allcaps; |
||
| 1586 | |||
| 1587 | $item = $item->data; |
||
| 1588 | |||
| 1589 | // Set other vars. |
||
| 1590 | $item->roles = $roles; |
||
| 1591 | $item->caps = $caps; |
||
| 1592 | $item->allcaps = $allcaps; |
||
| 1593 | |||
| 1594 | unset( $item->user_pass ); |
||
| 1595 | } |
||
| 1596 | } elseif ( 'comment' === $object_type ) { |
||
| 1597 | $item = get_comment( $item_id ); |
||
| 1598 | } else { |
||
| 1599 | $item = (object) $item; |
||
| 1600 | }//end if |
||
| 1601 | } elseif ( 'pods' === $params->output ) { |
||
| 1602 | if ( in_array( $object_type, array( 'user', 'media' ), true ) ) { |
||
| 1603 | $item = pods( $object_type, (int) $item_id ); |
||
| 1604 | } else { |
||
| 1605 | $item = pods( $object, (int) $item_id ); |
||
| 1606 | } |
||
| 1607 | } else { |
||
| 1608 | // arrays. |
||
| 1609 | $item = get_object_vars( (object) $item ); |
||
| 1610 | }//end if |
||
| 1611 | |||
| 1612 | // Pass item data into $data. |
||
| 1613 | $items[ $item_id ] = $item; |
||
| 1614 | }//end foreach |
||
| 1615 | |||
| 1616 | // Cleanup. |
||
| 1617 | unset( $item_data ); |
||
| 1618 | |||
| 1619 | // Return all of the data in the order expected. |
||
| 1620 | if ( empty( $params->orderby ) ) { |
||
| 1621 | foreach ( $ids as $id ) { |
||
| 1622 | if ( isset( $items[ $id ] ) ) { |
||
| 1623 | $data[ $id ] = $items[ $id ]; |
||
| 1624 | } |
||
| 1625 | } |
||
| 1626 | } else { |
||
| 1627 | // Use order set by orderby. |
||
| 1628 | foreach ( $items as $id => $v ) { |
||
| 1629 | // @codingStandardsIgnoreLine. |
||
| 1630 | if ( in_array( $id, $ids ) ) { |
||
| 1631 | $data[ $id ] = $v; |
||
| 1632 | } |
||
| 1633 | } |
||
| 1634 | } |
||
| 1635 | }//end if |
||
| 1636 | }//end if |
||
| 1637 | |||
| 1638 | if ( in_array( $last_type, $tableless_field_types, true ) || in_array( $last_type, array( |
||
| 1639 | 'boolean', |
||
| 1640 | 'number', |
||
| 1641 | 'currency', |
||
| 1642 | ), true ) ) { |
||
| 1643 | $params->raw = true; |
||
| 1644 | } |
||
| 1645 | |||
| 1646 | if ( empty( $data ) ) { |
||
| 1647 | $value = false; |
||
| 1648 | } else { |
||
| 1649 | $object_type = $table['type']; |
||
| 1650 | |||
| 1651 | if ( in_array( $table['type'], array( 'post_type', 'attachment', 'media' ), true ) ) { |
||
| 1652 | $object_type = 'post'; |
||
| 1653 | } |
||
| 1654 | |||
| 1655 | $no_conflict = true; |
||
| 1656 | |||
| 1657 | if ( in_array( $object_type, array( |
||
| 1658 | 'post', |
||
| 1659 | 'taxonomy', |
||
| 1660 | 'user', |
||
| 1661 | 'comment', |
||
| 1662 | 'settings', |
||
| 1663 | ), true ) ) { |
||
| 1664 | $no_conflict = pods_no_conflict_check( $object_type ); |
||
| 1665 | |||
| 1666 | if ( ! $no_conflict ) { |
||
| 1667 | pods_no_conflict_on( $object_type ); |
||
| 1668 | } |
||
| 1669 | } |
||
| 1670 | |||
| 1671 | if ( $is_field_output_full ) { |
||
| 1672 | // Return entire array. |
||
| 1673 | $value = $data; |
||
| 1674 | } else { |
||
| 1675 | // Return an array of single column values. |
||
| 1676 | $value = array(); |
||
| 1677 | |||
| 1678 | foreach ( $data as $item_id => $item ) { |
||
| 1679 | // $field is 123x123, needs to be _src.123x123 |
||
| 1680 | $full_field = implode( '.', array_splice( $params->traverse, $key ) ); |
||
| 1681 | |||
| 1682 | if ( is_array( $item ) && isset( $item[ $field ] ) ) { |
||
| 1683 | if ( $table['field_id'] === $field ) { |
||
| 1684 | $value[] = (int) $item[ $field ]; |
||
| 1685 | } else { |
||
| 1686 | $value[] = $item[ $field ]; |
||
| 1687 | } |
||
| 1688 | } elseif ( is_object( $item ) && isset( $item->{$field} ) ) { |
||
| 1689 | if ( $table['field_id'] === $field ) { |
||
| 1690 | $value[] = (int) $item->{$field}; |
||
| 1691 | } else { |
||
| 1692 | $value[] = $item->{$field}; |
||
| 1693 | } |
||
| 1694 | } elseif ( ( ( false !== strpos( $full_field, '_src' ) || 'guid' === $field ) && ( in_array( $table['type'], array( |
||
| 1695 | 'attachment', |
||
| 1696 | 'media', |
||
| 1697 | ), true ) || in_array( $last_type, PodsForm::file_field_types(), true ) ) ) || ( in_array( $field, array( |
||
| 1698 | '_link', |
||
| 1699 | 'detail_url', |
||
| 1700 | ), true ) || in_array( $field, array( |
||
| 1701 | 'permalink', |
||
| 1702 | 'the_permalink', |
||
| 1703 | ), true ) && in_array( $last_type, PodsForm::file_field_types(), true ) ) ) { |
||
| 1704 | // @todo Refactor the above condition statement. |
||
| 1705 | $size = 'full'; |
||
| 1706 | |||
| 1707 | if ( false === strpos( 'image', get_post_mime_type( $item_id ) ) ) { |
||
| 1708 | // No default sizes for non-images. |
||
| 1709 | // When a size is defined this will be overwritten. |
||
| 1710 | $size = null; |
||
| 1711 | } |
||
| 1712 | |||
| 1713 | if ( false !== strpos( $full_field, '_src.' ) && 5 < strlen( $full_field ) ) { |
||
| 1714 | $size = substr( $full_field, 5 ); |
||
| 1715 | } elseif ( false !== strpos( $full_field, '_src_relative.' ) && 14 < strlen( $full_field ) ) { |
||
| 1716 | $size = substr( $full_field, 14 ); |
||
| 1717 | } elseif ( false !== strpos( $full_field, '_src_schemeless.' ) && 16 < strlen( $full_field ) ) { |
||
| 1718 | $size = substr( $full_field, 16 ); |
||
| 1719 | } |
||
| 1720 | |||
| 1721 | if ( $size ) { |
||
| 1722 | $value_url = pods_image_url( $item_id, $size ); |
||
| 1723 | } else { |
||
| 1724 | $value_url = wp_get_attachment_url( $item_id ); |
||
| 1725 | } |
||
| 1726 | |||
| 1727 | if ( ! empty( $value_url ) ) { |
||
| 1728 | if ( false !== strpos( $full_field, '_src_relative' ) ) { |
||
| 1729 | $value_url_parsed = wp_parse_url( $value_url ); |
||
| 1730 | $value_url = $value_url_parsed['path']; |
||
| 1731 | } elseif ( false !== strpos( $full_field, '_src_schemeless' ) ) { |
||
| 1732 | $value_url = str_replace( array( |
||
| 1733 | 'http://', |
||
| 1734 | 'https://', |
||
| 1735 | ), '//', $value_url ); |
||
| 1736 | } |
||
| 1737 | } |
||
| 1738 | |||
| 1739 | if ( ! empty( $value_url ) ) { |
||
| 1740 | $value[] = $value_url; |
||
| 1741 | } |
||
| 1742 | |||
| 1743 | $params->raw_display = true; |
||
| 1744 | } elseif ( false !== strpos( $full_field, '_img' ) && ( in_array( $table['type'], array( |
||
| 1745 | 'attachment', |
||
| 1746 | 'media', |
||
| 1747 | ), true ) || in_array( $last_type, PodsForm::file_field_types(), true ) ) ) { |
||
| 1748 | $size = 'full'; |
||
| 1749 | |||
| 1750 | if ( false !== strpos( $full_field, '_img.' ) && 5 < strlen( $full_field ) ) { |
||
| 1751 | $size = substr( $full_field, 5 ); |
||
| 1752 | } |
||
| 1753 | |||
| 1754 | $value[] = pods_image( $item_id, $size ); |
||
| 1755 | |||
| 1756 | $params->raw_display = true; |
||
| 1757 | } elseif ( in_array( $field, array( |
||
| 1758 | '_link', |
||
| 1759 | 'detail_url', |
||
| 1760 | ), true ) || in_array( $field, array( 'permalink', 'the_permalink' ), true ) ) { |
||
| 1761 | if ( 'pod' === $object_type ) { |
||
| 1762 | if ( is_object( $related_obj ) ) { |
||
| 1763 | $related_obj->fetch( $item_id ); |
||
| 1764 | |||
| 1765 | $value[] = $related_obj->field( 'detail_url' ); |
||
| 1766 | } else { |
||
| 1767 | $value[] = ''; |
||
| 1768 | } |
||
| 1769 | } elseif ( 'post' === $object_type ) { |
||
| 1770 | $value[] = get_permalink( $item_id ); |
||
| 1771 | } elseif ( 'taxonomy' === $object_type ) { |
||
| 1772 | $value[] = get_term_link( $item_id, $object ); |
||
| 1773 | } elseif ( 'user' === $object_type ) { |
||
| 1774 | $value[] = get_author_posts_url( $item_id ); |
||
| 1775 | } elseif ( 'comment' === $object_type ) { |
||
| 1776 | $value[] = get_comment_link( $item_id ); |
||
| 1777 | } else { |
||
| 1778 | $value[] = ''; |
||
| 1779 | } |
||
| 1780 | |||
| 1781 | $params->raw_display = true; |
||
| 1782 | } elseif ( in_array( $object_type, array( |
||
| 1783 | 'post', |
||
| 1784 | 'taxonomy', |
||
| 1785 | 'user', |
||
| 1786 | 'comment', |
||
| 1787 | ), true ) ) { |
||
| 1788 | $metadata_object_id = $item_id; |
||
| 1789 | |||
| 1790 | $metadata_type = $object_type; |
||
| 1791 | |||
| 1792 | if ( 'post' === $object_type ) { |
||
| 1793 | // Support for WPML 'duplicated' translation handling. |
||
| 1794 | if ( did_action( 'wpml_loaded' ) && apply_filters( 'wpml_is_translated_post_type', false, $object ) ) { |
||
| 1795 | $master_post_id = (int) apply_filters( 'wpml_master_post_from_duplicate', $metadata_object_id ); |
||
| 1796 | |||
| 1797 | if ( 0 < $master_post_id ) { |
||
| 1798 | $metadata_object_id = $master_post_id; |
||
| 1799 | } |
||
| 1800 | } |
||
| 1801 | } elseif ( 'taxonomy' === $object_type ) { |
||
| 1802 | $metadata_type = 'term'; |
||
| 1803 | } |
||
| 1804 | |||
| 1805 | $value[] = get_metadata( $metadata_type, $metadata_object_id, $field, true ); |
||
| 1806 | } elseif ( 'settings' === $object_type ) { |
||
| 1807 | $value[] = get_option( $object . '_' . $field ); |
||
| 1808 | }//end if |
||
| 1809 | }//end foreach |
||
| 1810 | }//end if |
||
| 1811 | |||
| 1812 | if ( ! $no_conflict && in_array( $object_type, array( |
||
| 1813 | 'post', |
||
| 1814 | 'taxonomy', |
||
| 1815 | 'user', |
||
| 1816 | 'comment', |
||
| 1817 | 'settings', |
||
| 1818 | ), true ) ) { |
||
| 1819 | pods_no_conflict_off( $object_type ); |
||
| 1820 | } |
||
| 1821 | |||
| 1822 | // Handle Simple Relationships. |
||
| 1823 | if ( $simple ) { |
||
| 1824 | if ( null === $params->single ) { |
||
| 1825 | $params->single = false; |
||
| 1826 | } |
||
| 1827 | |||
| 1828 | $value = PodsForm::field_method( 'pick', 'simple_value', $field, $value, $last_options, $all_fields[ $pod ], 0, true ); |
||
| 1829 | } elseif ( false === $params->in_form && ! empty( $value ) && is_array( $value ) ) { |
||
| 1830 | $value = array_values( $value ); |
||
| 1831 | } |
||
| 1832 | |||
| 1833 | // Return a single column value. |
||
| 1834 | if ( false === $params->in_form && 1 === $limit && ! empty( $value ) && is_array( $value ) && 1 === count( $value ) ) { |
||
| 1835 | $value = current( $value ); |
||
| 1836 | } |
||
| 1837 | }//end if |
||
| 1838 | |||
| 1839 | if ( $last_options ) { |
||
| 1840 | $last_field_data = $last_options; |
||
| 1841 | } |
||
| 1842 | |||
| 1843 | break; |
||
| 1844 | }//end if |
||
| 1845 | }//end foreach |
||
| 1846 | }//end if |
||
| 1847 | }//end if |
||
| 1848 | }//end if |
||
| 1849 | |||
| 1850 | if ( ! empty( $params->traverse ) && 1 < count( $params->traverse ) ) { |
||
| 1851 | $field_names = implode( '.', $params->traverse ); |
||
| 1852 | |||
| 1853 | $this->row[ $field_names ] = $value; |
||
| 1854 | } elseif ( 'arrays' !== $params->output && in_array( $field_data['type'], $tableless_field_types, true ) ) { |
||
| 1855 | $this->row[ '_' . $params->output . '_' . $params->full_name ] = $value; |
||
| 1856 | } elseif ( 'arrays' === $params->output || ! in_array( $field_data['type'], $tableless_field_types, true ) ) { |
||
| 1857 | $this->row[ $params->full_name ] = $value; |
||
| 1858 | } |
||
| 1859 | |||
| 1860 | if ( true === $params->single && is_array( $value ) && 1 === count( $value ) ) { |
||
| 1861 | $value = current( $value ); |
||
| 1862 | } |
||
| 1863 | |||
| 1864 | if ( ! empty( $last_field_data ) ) { |
||
| 1865 | $field_data = $last_field_data; |
||
| 1866 | } |
||
| 1867 | |||
| 1868 | // @todo Expand this into traversed fields too. |
||
| 1869 | if ( ! empty( $field_data ) && ( $params->display || ! $params->raw ) && ! $params->in_form && ! $params->raw_display ) { |
||
| 1870 | if ( $params->display || ( ( $params->get_meta || $params->deprecated ) && ! in_array( $field_data['type'], $tableless_field_types, true ) ) ) { |
||
| 1871 | $field_data['options'] = pods_v( 'options', $field_data, array(), true ); |
||
| 1872 | |||
| 1873 | $post_temp = false; |
||
| 1874 | $old_post = null; |
||
| 1875 | $old_post_id = null; |
||
| 1876 | |||
| 1877 | if ( empty( $GLOBALS['post'] ) && 'post_type' === pods_v( 'type', $this->pod_data ) && 0 < $this->id() ) { |
||
| 1878 | global $post_ID, $post; |
||
| 1879 | |||
| 1880 | $post_temp = true; |
||
| 1881 | |||
| 1882 | $old_post = $post; |
||
| 1883 | $old_post_id = $post_ID; |
||
| 1884 | |||
| 1885 | // @codingStandardsIgnoreLine. |
||
| 1886 | $post = get_post( $this->id() ); |
||
| 1887 | // @codingStandardsIgnoreLine. |
||
| 1888 | $post_ID = $this->id(); |
||
| 1889 | } |
||
| 1890 | |||
| 1891 | $filter = pods_v( 'display_filter', $field_data['options'] ); |
||
| 1892 | |||
| 1893 | if ( 0 < strlen( $filter ) ) { |
||
| 1894 | $args = array( |
||
| 1895 | $filter, |
||
| 1896 | $value, |
||
| 1897 | ); |
||
| 1898 | |||
| 1899 | $filter_args = pods_v( 'display_filter_args', $field_data['options'] ); |
||
| 1900 | |||
| 1901 | if ( ! empty( $filter_args ) ) { |
||
| 1902 | $args = array_merge( $args, compact( $filter_args ) ); |
||
| 1903 | } |
||
| 1904 | |||
| 1905 | $value = call_user_func_array( 'apply_filters', $args ); |
||
| 1906 | } elseif ( 1 === (int) pods_v( 'display_process', $field_data['options'], 1 ) ) { |
||
| 1907 | $value = PodsForm::display( $field_data['type'], $value, $params->name, array_merge( $field_data, $field_data['options'] ), $this->pod_data, $this->id() ); |
||
| 1908 | } |
||
| 1909 | |||
| 1910 | if ( $post_temp ) { |
||
| 1911 | // @codingStandardsIgnoreLine. |
||
| 1912 | $post = $old_post; |
||
| 1913 | // @codingStandardsIgnoreLine. |
||
| 1914 | $post_ID = $old_post_id; |
||
| 1915 | } |
||
| 1916 | } else { |
||
| 1917 | $value = PodsForm::value( $field_data['type'], $value, $params->name, array_merge( $field_data, $field_data['options'] ), $this->pod_data, $this->id() ); |
||
| 1918 | }//end if |
||
| 1919 | }//end if |
||
| 1920 | |||
| 1921 | /** |
||
| 1922 | * Modify value returned by field() directly before output. |
||
| 1923 | * |
||
| 1924 | * Will not run if value was null |
||
| 1925 | * |
||
| 1926 | * @since unknown |
||
| 1927 | * |
||
| 1928 | * @param array|string|null $value Value to be returned. |
||
| 1929 | * @param array|object $row Current row being outputted. |
||
| 1930 | * @param array $params Params array passed to field(). |
||
| 1931 | * @param object|Pods $this Current Pods object. |
||
| 1932 | */ |
||
| 1933 | $value = apply_filters( 'pods_pods_field', $value, $this->row, $params, $this ); |
||
| 1934 | |||
| 1935 | return $value; |
||
| 1936 | } |
||
| 1937 | |||
| 1938 | /** |
||
| 1939 | * Check if an item field has a specific value in it |
||
| 1940 | * |
||
| 1941 | * @param string $field Field name. |
||
| 1942 | * @param mixed $value Value to check. |
||
| 1943 | * @param int $id (optional) ID of the pod item to check. |
||
| 1944 | * |
||
| 1945 | * @return bool Whether the value was found |
||
| 1946 | * |
||
| 1947 | * @since 2.3.3 |
||
| 1948 | */ |
||
| 1949 | public function has( $field, $value, $id = null ) { |
||
| 2017 | |||
| 2018 | /** |
||
| 2019 | * Check if an item field is a specific value |
||
| 2020 | * |
||
| 2021 | * @param string $field Field name. |
||
| 2022 | * @param mixed $value Value to check. |
||
| 2023 | * @param int $id (optional) ID of the pod item to check. |
||
| 2024 | * |
||
| 2025 | * @return bool Whether the value was found |
||
| 2026 | * |
||
| 2027 | * @since 2.3.3 |
||
| 2028 | */ |
||
| 2029 | public function is( $field, $value, $id = null ) { |
||
| 2140 | |||
| 2141 | /** |
||
| 2142 | * Return the item ID |
||
| 2143 | * |
||
| 2144 | * @return int |
||
| 2145 | * @since 2.0 |
||
| 2146 | */ |
||
| 2147 | public function id() { |
||
| 2156 | |||
| 2157 | /** |
||
| 2158 | * Return the previous item ID, loops at the last id to return the first |
||
| 2159 | * |
||
| 2160 | * @param int|null $id ID to start from. |
||
| 2161 | * @param array|object|null $params_override Override the find() parameters. |
||
| 2162 | * |
||
| 2163 | * @return int |
||
| 2164 | * @since 2.0 |
||
| 2165 | */ |
||
| 2166 | public function prev_id( $id = null, $params_override = null ) { |
||
| 2245 | |||
| 2246 | /** |
||
| 2247 | * Return the next item ID, loops at the first id to return the last |
||
| 2248 | * |
||
| 2249 | * @param int|null $id ID to start from. |
||
| 2250 | * @param array|object|null $params_override Override the find() parameters. |
||
| 2251 | * |
||
| 2252 | * @return int |
||
| 2253 | * @since 2.0 |
||
| 2254 | */ |
||
| 2255 | public function next_id( $id = null, $params_override = null ) { |
||
| 2314 | |||
| 2315 | /** |
||
| 2316 | * Return the first item ID |
||
| 2317 | * |
||
| 2318 | * @param array|object|null $params_override Override the find() parameters. |
||
| 2319 | * |
||
| 2320 | * @return int |
||
| 2321 | * @since 2.3 |
||
| 2322 | */ |
||
| 2323 | public function first_id( $params_override = null ) { |
||
| 2359 | |||
| 2360 | /** |
||
| 2361 | * Return the last item ID |
||
| 2362 | * |
||
| 2363 | * @param array|object|null $params_override Override the find() parameters. |
||
| 2364 | * |
||
| 2365 | * @return int |
||
| 2366 | * @since 2.3 |
||
| 2367 | */ |
||
| 2368 | public function last_id( $params_override = null ) { |
||
| 2431 | |||
| 2432 | /** |
||
| 2433 | * Return the item name |
||
| 2434 | * |
||
| 2435 | * @return string |
||
| 2436 | * @since 2.0 |
||
| 2437 | */ |
||
| 2438 | public function index() { |
||
| 2442 | |||
| 2443 | /** |
||
| 2444 | * Find items of a pod, much like WP_Query, but with advanced table handling. |
||
| 2445 | * |
||
| 2446 | * @param array|object $params An associative array of parameters. |
||
| 2447 | * @param int $limit (deprecated) Limit the number of items to find, -1 to return all items with no limit. |
||
| 2448 | * @param string $where (deprecated) SQL WHERE declaration to use. |
||
| 2449 | * @param string $sql (deprecated) For advanced use, a custom SQL query to run. |
||
| 2450 | * |
||
| 2451 | * @return \Pods The pod object |
||
| 2452 | * @since 2.0 |
||
| 2453 | * @link https://pods.io/docs/find/ |
||
| 2454 | */ |
||
| 2455 | public function find( $params = null, $limit = 15, $where = null, $sql = null ) { |
||
| 2683 | |||
| 2684 | /** |
||
| 2685 | * Fetch an item from a Pod. If $id is null, it will return the next item in the list after running find(). |
||
| 2686 | * You can rewind the list back to the start by using reset(). |
||
| 2687 | * |
||
| 2688 | * Providing an $id will fetch a specific item from a Pod, much like a call to pods(), and can handle either an id |
||
| 2689 | * or slug. |
||
| 2690 | * |
||
| 2691 | * @see PodsData::fetch |
||
| 2692 | * |
||
| 2693 | * @param int $id ID or slug of the item to fetch. |
||
| 2694 | * @param bool $explicit_set Whether to set explicitly (use false when in loop). |
||
| 2695 | * |
||
| 2696 | * @return array An array of fields from the row |
||
| 2697 | * |
||
| 2698 | * @since 2.0 |
||
| 2699 | * @link https://pods.io/docs/fetch/ |
||
| 2700 | */ |
||
| 2701 | public function fetch( $id = null, $explicit_set = true ) { |
||
| 2721 | |||
| 2722 | /** |
||
| 2723 | * (Re)set the MySQL result pointer |
||
| 2724 | * |
||
| 2725 | * @see PodsData::reset |
||
| 2726 | * |
||
| 2727 | * @param int $row ID of the row to reset to. |
||
| 2728 | * |
||
| 2729 | * @return \Pods The pod object |
||
| 2730 | * |
||
| 2731 | * @since 2.0 |
||
| 2732 | * @link https://pods.io/docs/reset/ |
||
| 2733 | */ |
||
| 2734 | public function reset( $row = null ) { |
||
| 2750 | |||
| 2751 | /** |
||
| 2752 | * Fetch the total row count returned by the last call to find(), based on the 'limit' parameter set. |
||
| 2753 | * |
||
| 2754 | * This is different than the total number of rows found in the database, which you can get with total_found(). |
||
| 2755 | * |
||
| 2756 | * @see PodsData::total |
||
| 2757 | * |
||
| 2758 | * @return int Number of rows returned by find(), based on the 'limit' parameter set |
||
| 2759 | * @since 2.0 |
||
| 2760 | * @link https://pods.io/docs/total/ |
||
| 2761 | */ |
||
| 2762 | public function total() { |
||
| 2772 | |||
| 2773 | /** |
||
| 2774 | * Fetch the total amount of rows found by the last call to find(), regardless of the 'limit' parameter set. |
||
| 2775 | * |
||
| 2776 | * This is different than the total number of rows limited by the current call, which you can get with total(). |
||
| 2777 | * |
||
| 2778 | * @see PodsData::total_found |
||
| 2779 | * |
||
| 2780 | * @return int Number of rows returned by find(), regardless of the 'limit' parameter |
||
| 2781 | * @since 2.0 |
||
| 2782 | * @link https://pods.io/docs/total-found/ |
||
| 2783 | */ |
||
| 2784 | public function total_found() { |
||
| 2801 | |||
| 2802 | /** |
||
| 2803 | * Fetch the total number of pages, based on total rows found and the last find() limit |
||
| 2804 | * |
||
| 2805 | * @param null|int $limit Rows per page. |
||
| 2806 | * @param null|int $offset Offset of rows. |
||
| 2807 | * @param null|int $total Total rows. |
||
| 2808 | * |
||
| 2809 | * @return int Number of pages |
||
| 2810 | * @since 2.3.10 |
||
| 2811 | */ |
||
| 2812 | public function total_pages( $limit = null, $offset = null, $total = null ) { |
||
| 2831 | |||
| 2832 | /** |
||
| 2833 | * Fetch the zebra switch |
||
| 2834 | * |
||
| 2835 | * @see PodsData::zebra |
||
| 2836 | * |
||
| 2837 | * @return bool Zebra state |
||
| 2838 | * @since 1.12 |
||
| 2839 | */ |
||
| 2840 | public function zebra() { |
||
| 2846 | |||
| 2847 | /** |
||
| 2848 | * Fetch the nth state |
||
| 2849 | * |
||
| 2850 | * @see PodsData::nth |
||
| 2851 | * |
||
| 2852 | * @param int|string $nth The $nth to match on the PodsData::row_number. |
||
| 2853 | * |
||
| 2854 | * @return bool Whether $nth matches |
||
| 2855 | * @since 2.3 |
||
| 2856 | */ |
||
| 2857 | public function nth( $nth = null ) { |
||
| 2863 | |||
| 2864 | /** |
||
| 2865 | * Fetch the current position in the loop (starting at 1) |
||
| 2866 | * |
||
| 2867 | * @see PodsData::position |
||
| 2868 | * |
||
| 2869 | * @return int Current row number (+1) |
||
| 2870 | * @since 2.3 |
||
| 2871 | */ |
||
| 2872 | public function position() { |
||
| 2878 | |||
| 2879 | /** |
||
| 2880 | * Add an item to a Pod by giving an array of field data or set a specific field to |
||
| 2881 | * a specific value if you're just wanting to add a new item but only set one field. |
||
| 2882 | * |
||
| 2883 | * You may be looking for save() in most cases where you're setting a specific field. |
||
| 2884 | * |
||
| 2885 | * @see PodsAPI::save_pod_item |
||
| 2886 | * |
||
| 2887 | * @param array|string $data Either an associative array of field information or a field name. |
||
| 2888 | * @param mixed $value (optional) Value of the field, if $data is a field name. |
||
| 2889 | * |
||
| 2890 | * @return int The item ID |
||
| 2891 | * |
||
| 2892 | * @since 2.0 |
||
| 2893 | * @link https://pods.io/docs/add/ |
||
| 2894 | */ |
||
| 2895 | public function add( $data = null, $value = null ) { |
||
| 2915 | |||
| 2916 | /** |
||
| 2917 | * Add an item to the values of a relationship field, add a value to a number field (field+1), add time to a date |
||
| 2918 | * field, or add text to a text field |
||
| 2919 | * |
||
| 2920 | * @see PodsAPI::save_pod_item |
||
| 2921 | * |
||
| 2922 | * @param string $field Field name. |
||
| 2923 | * @param mixed $value IDs to add, int|float to add to number field, string for dates (+1 day), or string for text. |
||
| 2924 | * @param int $id (optional) ID of the pod item to update. |
||
| 2925 | * |
||
| 2926 | * @return int The item ID |
||
| 2927 | * |
||
| 2928 | * @since 2.3 |
||
| 2929 | */ |
||
| 2930 | public function add_to( $field, $value, $id = null ) { |
||
| 3031 | |||
| 3032 | /** |
||
| 3033 | * Remove an item from the values of a relationship field, remove a value from a number field (field-1), remove |
||
| 3034 | * time to a date field |
||
| 3035 | * |
||
| 3036 | * @see PodsAPI::save_pod_item |
||
| 3037 | * |
||
| 3038 | * @param string $field Field name. |
||
| 3039 | * @param mixed $value IDs to add, int|float to add to number field, string for dates (-1 day), or string for text. |
||
| 3040 | * @param int $id (optional) ID of the pod item to update. |
||
| 3041 | * |
||
| 3042 | * @return int The item ID |
||
| 3043 | * |
||
| 3044 | * @since 2.3.3 |
||
| 3045 | */ |
||
| 3046 | public function remove_from( $field, $value = null, $id = null ) { |
||
| 3169 | |||
| 3170 | /** |
||
| 3171 | * Save an item by giving an array of field data or set a specific field to a specific value. |
||
| 3172 | * |
||
| 3173 | * Though this function has the capacity to add new items, best practice should direct you |
||
| 3174 | * to use add() for that instead. |
||
| 3175 | * |
||
| 3176 | * @see PodsAPI::save_pod_item |
||
| 3177 | * |
||
| 3178 | * @param array|string $data Either an associative array of field information or a field name. |
||
| 3179 | * @param mixed $value (optional) Value of the field, if $data is a field name. |
||
| 3180 | * @param int $id (optional) ID of the pod item to update. |
||
| 3181 | * @param array $params (optional) Additional params to send to save_pod_item. |
||
| 3182 | * |
||
| 3183 | * @return int The item ID |
||
| 3184 | * |
||
| 3185 | * @since 2.0 |
||
| 3186 | * @link https://pods.io/docs/save/ |
||
| 3187 | */ |
||
| 3188 | public function save( $data = null, $value = null, $id = null, $params = null ) { |
||
| 3252 | |||
| 3253 | /** |
||
| 3254 | * Delete an item |
||
| 3255 | * |
||
| 3256 | * @see PodsAPI::delete_pod_item |
||
| 3257 | * |
||
| 3258 | * @param int $id ID of the Pod item to delete. |
||
| 3259 | * |
||
| 3260 | * @return bool Whether the item was successfully deleted |
||
| 3261 | * |
||
| 3262 | * @since 2.0 |
||
| 3263 | * @link https://pods.io/docs/delete/ |
||
| 3264 | */ |
||
| 3265 | public function delete( $id = null ) { |
||
| 3284 | |||
| 3285 | /** |
||
| 3286 | * Reset Pod |
||
| 3287 | * |
||
| 3288 | * @see PodsAPI::reset_pod |
||
| 3289 | * |
||
| 3290 | * @return bool Whether the Pod was successfully reset |
||
| 3291 | * |
||
| 3292 | * @since 2.1.1 |
||
| 3293 | */ |
||
| 3294 | public function reset_pod() { |
||
| 3307 | |||
| 3308 | /** |
||
| 3309 | * Duplicate an item |
||
| 3310 | * |
||
| 3311 | * @see PodsAPI::duplicate_pod_item |
||
| 3312 | * |
||
| 3313 | * @param int $id ID of the pod item to duplicate. |
||
| 3314 | * |
||
| 3315 | * @return int|bool ID of the new pod item |
||
| 3316 | * |
||
| 3317 | * @since 2.0 |
||
| 3318 | * @link https://pods.io/docs/duplicate/ |
||
| 3319 | */ |
||
| 3320 | public function duplicate( $id = null ) { |
||
| 3339 | |||
| 3340 | /** |
||
| 3341 | * Import data / Save multiple rows of data at once |
||
| 3342 | * |
||
| 3343 | * @see PodsAPI::import |
||
| 3344 | * |
||
| 3345 | * @param mixed $import_data PHP associative array or CSV input. |
||
| 3346 | * @param bool $numeric_mode Use IDs instead of the name field when matching. |
||
| 3347 | * @param string $format Format of import data, options are php or csv. |
||
| 3348 | * |
||
| 3349 | * @return array IDs of imported items |
||
| 3350 | * |
||
| 3351 | * @since 2.3 |
||
| 3352 | */ |
||
| 3353 | public function import( $import_data, $numeric_mode = false, $format = null ) { |
||
| 3357 | |||
| 3358 | /** |
||
| 3359 | * Export an item's data |
||
| 3360 | * |
||
| 3361 | * @see PodsAPI::export_pod_item |
||
| 3362 | * |
||
| 3363 | * @param array $fields (optional) Fields to export. |
||
| 3364 | * @param int $id (optional) ID of the pod item to export. |
||
| 3365 | * @param null|string $format (optional) The format of the export (php | json). |
||
| 3366 | * |
||
| 3367 | * @return array|bool Data array of the exported pod item |
||
| 3368 | * |
||
| 3369 | * @since 2.0 |
||
| 3370 | * @link https://pods.io/docs/export/ |
||
| 3371 | */ |
||
| 3372 | public function export( $fields = null, $id = null, $format = null ) { |
||
| 3412 | |||
| 3413 | /** |
||
| 3414 | * Export data from all items |
||
| 3415 | * |
||
| 3416 | * @see PodsAPI::export |
||
| 3417 | * |
||
| 3418 | * @param array $params An associative array of parameters. |
||
| 3419 | * |
||
| 3420 | * @return array Data arrays of all exported pod items |
||
| 3421 | * |
||
| 3422 | * @since 2.3 |
||
| 3423 | */ |
||
| 3424 | public function export_data( $params = null ) { |
||
| 3440 | |||
| 3441 | /** |
||
| 3442 | * Display the pagination controls, types supported by default |
||
| 3443 | * are simple, paginate and advanced. The base and format parameters |
||
| 3444 | * are used only for the paginate view. |
||
| 3445 | * |
||
| 3446 | * @param array|object $params Associative array of parameters. |
||
| 3447 | * |
||
| 3448 | * @return string Pagination HTML |
||
| 3449 | * @since 2.0 |
||
| 3450 | * @link https://pods.io/docs/pagination/ |
||
| 3451 | */ |
||
| 3452 | public function pagination( $params = null ) { |
||
| 3520 | |||
| 3521 | /** |
||
| 3522 | * Return a filter form for searching a Pod |
||
| 3523 | * |
||
| 3524 | * @param array|string $params Comma-separated list of fields or array of parameters. |
||
| 3525 | * |
||
| 3526 | * @return string Filters HTML |
||
| 3527 | * |
||
| 3528 | * @since 2.0 |
||
| 3529 | * @link https://pods.io/docs/filters/ |
||
| 3530 | */ |
||
| 3531 | public function filters( $params = null ) { |
||
| 3643 | |||
| 3644 | /** |
||
| 3645 | * Run a helper within a Pod Page or WP Template |
||
| 3646 | * |
||
| 3647 | * @see Pods_Helpers::helper |
||
| 3648 | * |
||
| 3649 | * @param string|array $helper Helper name. |
||
| 3650 | * @param string $value Value to run the helper on. |
||
| 3651 | * @param string $name Field name. |
||
| 3652 | * |
||
| 3653 | * @return mixed Anything returned by the helper |
||
| 3654 | * @since 2.0 |
||
| 3655 | */ |
||
| 3656 | public function helper( $helper, $value = null, $name = null ) { |
||
| 3735 | |||
| 3736 | /** |
||
| 3737 | * Display the page template |
||
| 3738 | * |
||
| 3739 | * @see Pods_Templates::template |
||
| 3740 | * |
||
| 3741 | * @param string $template_name The template name. |
||
| 3742 | * @param string|null $code Custom template code to use instead. |
||
| 3743 | * @param bool $deprecated Whether to use deprecated functionality based on old function usage. |
||
| 3744 | * |
||
| 3745 | * @return mixed Template output |
||
| 3746 | * |
||
| 3747 | * @since 2.0 |
||
| 3748 | * @link https://pods.io/docs/template/ |
||
| 3749 | */ |
||
| 3750 | public function template( $template_name, $code = null, $deprecated = false ) { |
||
| 3866 | |||
| 3867 | /** |
||
| 3868 | * Embed a form to add / edit a pod item from within your theme. Provide an array of $fields to include |
||
| 3869 | * and override options where needed. For WP object based Pods, you can pass through the WP object |
||
| 3870 | * field names too, such as "post_title" or "post_content" for example. |
||
| 3871 | * |
||
| 3872 | * @param array $params (optional) Fields to show on the form, defaults to all fields. |
||
| 3873 | * @param string $label (optional) Save button label, defaults to "Save Changes". |
||
| 3874 | * @param string $thank_you (optional) Thank you URL to send to upon success. |
||
| 3875 | * |
||
| 3876 | * @return bool|mixed |
||
| 3877 | * @since 2.0 |
||
| 3878 | * @link https://pods.io/docs/form/ |
||
| 3879 | */ |
||
| 3880 | public function form( $params = null, $label = null, $thank_you = null ) { |
||
| 4021 | |||
| 4022 | /** |
||
| 4023 | * Render a singular view for the Pod item content. |
||
| 4024 | * |
||
| 4025 | * @param array|string|null $fields (optional) Fields to show in the view, defaults to all fields. |
||
| 4026 | * |
||
| 4027 | * @return mixed |
||
| 4028 | * @since 2.3.10 |
||
| 4029 | */ |
||
| 4030 | public function view( $fields = null ) { |
||
| 4098 | |||
| 4099 | /** |
||
| 4100 | * Replace magic tags with their values |
||
| 4101 | * |
||
| 4102 | * @param string $code The content to evaluate. |
||
| 4103 | * |
||
| 4104 | * @return string Code with Magic Tags evaluated |
||
| 4105 | * |
||
| 4106 | * @since 2.0 |
||
| 4107 | */ |
||
| 4108 | public function do_magic_tags( $code ) { |
||
| 4127 | |||
| 4128 | /** |
||
| 4129 | * Replace magic tags with their values |
||
| 4130 | * |
||
| 4131 | * @param string|array $tag The magic tag to process. |
||
| 4132 | * |
||
| 4133 | * @return string Code with Magic Tags evaluated |
||
| 4134 | * |
||
| 4135 | * @since 2.0.2 |
||
| 4136 | */ |
||
| 4137 | private function process_magic_tags( $tag ) { |
||
| 4205 | |||
| 4206 | /** |
||
| 4207 | * |
||
| 4208 | * Generate UI for Data Management |
||
| 4209 | * |
||
| 4210 | * @param mixed $options Array or String containing Pod or Options to be used. |
||
| 4211 | * @param bool $amend Whether to amend the default UI options or replace entirely. |
||
| 4212 | * |
||
| 4213 | * @return PodsUI|null UI object or null if custom UI used |
||
| 4214 | * |
||
| 4215 | * @since 2.3.10 |
||
| 4216 | */ |
||
| 4217 | public function ui( $options = null, $amend = false ) { |
||
| 4460 | |||
| 4461 | /** |
||
| 4462 | * Handle filters / actions for the class |
||
| 4463 | * |
||
| 4464 | * @see pods_do_hook |
||
| 4465 | * |
||
| 4466 | * @param string $name Hook name. |
||
| 4467 | * |
||
| 4468 | * @return mixed Value filtered |
||
| 4469 | * |
||
| 4470 | * @since 2.0 |
||
| 4471 | */ |
||
| 4472 | private function do_hook( $name ) { |
||
| 4485 | |||
| 4486 | /** |
||
| 4487 | * Handle variables that have been deprecated and PodsData vars |
||
| 4488 | * |
||
| 4489 | * @param string $name Property name. |
||
| 4490 | * |
||
| 4491 | * @return mixed |
||
| 4492 | * |
||
| 4493 | * @since 2.0 |
||
| 4494 | */ |
||
| 4495 | public function __get( $name ) { |
||
| 4526 | |||
| 4527 | /** |
||
| 4528 | * Handle methods that have been deprecated and any aliasing. |
||
| 4529 | * |
||
| 4530 | * @param string $name Function name. |
||
| 4531 | * @param array $args Arguments passed to function. |
||
| 4532 | * |
||
| 4533 | * @return mixed|null |
||
| 4534 | * |
||
| 4535 | * @since 2.0 |
||
| 4536 | */ |
||
| 4537 | public function __call( $name, $args ) { |
||
| 4563 | |||
| 4564 | /** |
||
| 4565 | * Handle casting a Pods() object to string |
||
| 4566 | * |
||
| 4567 | * @return string Pod type and name in CURIE notation |
||
| 4568 | */ |
||
| 4569 | public function __toString() { |
||
| 4580 | } |
||
| 4581 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.