{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/WP-Job-Manager/issues/565","labels_url":"https://api.github.com/repos/Automattic/WP-Job-Manager/issues/565/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/WP-Job-Manager/issues/565/comments","events_url":"https://api.github.com/repos/Automattic/WP-Job-Manager/issues/565/events","html_url":"https://github.com/Automattic/WP-Job-Manager/pull/565","id":116880875,"number":565,"title":"Allow optional taxonomy term-select fields","user":{"login":"tripflex","id":553732,"avatar_url":"https://avatars.githubusercontent.com/u/553732?v=3","gravatar_id":"","url":"https://api.github.com/users/tripflex","html_url":"https://github.com/tripflex","followers_url":"https://api.github.com/users/tripflex/followers","following_url":"https://api.github.com/users/tripflex/following{/other_user}","gists_url":"https://api.github.com/users/tripflex/gists{/gist_id}","starred_url":"https://api.github.com/users/tripflex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tripflex/subscriptions","organizations_url":"https://api.github.com/users/tripflex/orgs","repos_url":"https://api.github.com/users/tripflex/repos","events_url":"https://api.github.com/users/tripflex/events{/privacy}","received_events_url":"https://api.github.com/users/tripflex/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-14T00:26:47Z","updated_at":"2015-11-14T00:27:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/WP-Job-Manager/pulls/565","html_url":"https://github.com/Automattic/WP-Job-Manager/pull/565","diff_url":"https://github.com/Automattic/WP-Job-Manager/pull/565.diff","patch_url":"https://github.com/Automattic/WP-Job-Manager/pull/565.patch"},"body":"Currently the way that taxonomy fields are validated is in a `foreach` loop through the array.  If the field is a `term-select` field the value will be either empty or an integer for the selected taxonomy. \r\n\r\nThe problem is if a `term-select` field is set as optional, and the user does not select a value, when processing through validation the value is an empty string, and is placed into an array, creating an array with one member, that is empty.  \r\n\r\nThis causes the `term_exists()` to fail and returns a `WP_Error` saying the term is invalid.  \r\n\r\nThis PR adds an inline if statement to check if the value is empty, and if so, return an empty array, instead of an array with one member that is empty.\r\n\r\nhttps://github.com/tripflex/wp-job-manager-field-editor/issues/289"},"comment":{"url":"https://api.github.com/repos/Automattic/WP-Job-Manager/issues/comments/156598267","html_url":"https://github.com/Automattic/WP-Job-Manager/pull/565#issuecomment-156598267","issue_url":"https://api.github.com/repos/Automattic/WP-Job-Manager/issues/565","id":156598267,"user":{"login":"fourleafed","id":1687522,"avatar_url":"https://avatars.githubusercontent.com/u/1687522?v=3","gravatar_id":"","url":"https://api.github.com/users/fourleafed","html_url":"https://github.com/fourleafed","followers_url":"https://api.github.com/users/fourleafed/followers","following_url":"https://api.github.com/users/fourleafed/following{/other_user}","gists_url":"https://api.github.com/users/fourleafed/gists{/gist_id}","starred_url":"https://api.github.com/users/fourleafed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fourleafed/subscriptions","organizations_url":"https://api.github.com/users/fourleafed/orgs","repos_url":"https://api.github.com/users/fourleafed/repos","events_url":"https://api.github.com/users/fourleafed/events{/privacy}","received_events_url":"https://api.github.com/users/fourleafed/received_events","type":"User","site_admin":false},"created_at":"2015-11-14T00:27:03Z","updated_at":"2015-11-14T00:27:03Z","body":"-- Please reply above this line --\n\nHi Automattic/wp-Job-Manager We have received your email. We will\nrespond to you as soon as possible.Kind regards!\n\n-----------------------------------------------------------\n## Automattic/wp-Job-Manager sent a message, on Nov 14 @ 1:26 (CET):\n\nCurrently the way that taxonomy fields are validated is in a foreach\nloop through the array. If the field is a term-select field the value\nwill be either empty or an integer for the selected taxonomy.\nThe problem is if a term-select field is set as optional, and the user\ndoes not select a value, when processing through validation the value\nis an empty string, and is placed into an array, creating an array\nwith one member, that is empty.\nThis causes the term_exists() to fail and returns a WP_Error saying\nthe term is invalid.\nThis PR adds an inline if statement to check if the value is empty,\nand if so, return an empty array, instead of an array with one member\nthat is empty.\ntripflex/wp-job-manager-field-editor#289\n\nYou can view, comment on, or merge this pull request online at:\n  https://github.com/Automattic/WP-Job-Manager/pull/565\nCommit Summary\n\nallow optional term-select fields\n\nFile Changes\n\nM includes/forms/class-wp-job-manager-form-submit-job.php (2)\n\nPatch Links:\n\nhttps://github.com/Automattic/WP-Job-Manager/pull/565.patch\nhttps://github.com/Automattic/WP-Job-Manager/pull/565.diff\n\n-\nReply to this email directly or view it on GitHub.\n\n-----------------------------------------------------------\n"}}