{"action":"created","issue":{"url":"https://api.github.com/repos/greensun7/tilda-wordpress-plugin/issues/10","repository_url":"https://api.github.com/repos/greensun7/tilda-wordpress-plugin","labels_url":"https://api.github.com/repos/greensun7/tilda-wordpress-plugin/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/greensun7/tilda-wordpress-plugin/issues/10/comments","events_url":"https://api.github.com/repos/greensun7/tilda-wordpress-plugin/issues/10/events","html_url":"https://github.com/greensun7/tilda-wordpress-plugin/issues/10","id":327221579,"number":10,"title":"Некорректная обработка id \"custom post types\" перед сохранением в wp_options","user":{"login":"versusbassz","id":2342074,"avatar_url":"https://avatars0.githubusercontent.com/u/2342074?v=4","gravatar_id":"","url":"https://api.github.com/users/versusbassz","html_url":"https://github.com/versusbassz","followers_url":"https://api.github.com/users/versusbassz/followers","following_url":"https://api.github.com/users/versusbassz/following{/other_user}","gists_url":"https://api.github.com/users/versusbassz/gists{/gist_id}","starred_url":"https://api.github.com/users/versusbassz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/versusbassz/subscriptions","organizations_url":"https://api.github.com/users/versusbassz/orgs","repos_url":"https://api.github.com/users/versusbassz/repos","events_url":"https://api.github.com/users/versusbassz/events{/privacy}","received_events_url":"https://api.github.com/users/versusbassz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-29T08:39:35Z","updated_at":"2018-05-29T09:19:19Z","closed_at":null,"author_association":"NONE","body":"Системные имена (id)  \"custom post types\" (далее CPT) могут содержать символы `_` и `-`,   \r\nэто нормальная практика для тех кто делаем префиксы для id своих CPT.   \r\nНапример в плагине ACF это имена `acf-field-group` и  `acf-field` (этот плагин данная проблема не затрагивает, просто указываю пример того как именуют CPT другие разработчики).\r\n\r\nВ моём случае мы имена всех наших CPT префиксим. Получается, что в html-форме настроек плагина отправляется например `myprefix_book`, а на выходе в БД кладётся `myprefixbook`. Ну и после сохранения соответственно нужные чекбоксы оказываются неотмеченными.\r\n\r\nПричина вот в этой валидации (строка с `preg_replace`):\r\n```php\r\n// Tilda_Admin::options_validate()\r\n        foreach ($input['enabledposttypes'] as $key => $type) {\r\n            $input['enabledposttypes'][$key] = preg_replace('/[^a-zA-Z0-9]/iu','', $type);\r\n            if (empty($input['enabledposttypes'][$key])) {\r\n                unset($input['enabledposttypes'][$key]);\r\n            }\r\n        }\r\n```\r\nПроблема появилась после релиза решаюшего этот тикет #3\r\n\r\nИмхо эту проверку (`preg_replace`) лучше удалить. От неё больше вреда, чем пользы."},"comment":{"url":"https://api.github.com/repos/greensun7/tilda-wordpress-plugin/issues/comments/392710137","html_url":"https://github.com/greensun7/tilda-wordpress-plugin/issues/10#issuecomment-392710137","issue_url":"https://api.github.com/repos/greensun7/tilda-wordpress-plugin/issues/10","id":392710137,"user":{"login":"islandfuture","id":11860956,"avatar_url":"https://avatars1.githubusercontent.com/u/11860956?v=4","gravatar_id":"","url":"https://api.github.com/users/islandfuture","html_url":"https://github.com/islandfuture","followers_url":"https://api.github.com/users/islandfuture/followers","following_url":"https://api.github.com/users/islandfuture/following{/other_user}","gists_url":"https://api.github.com/users/islandfuture/gists{/gist_id}","starred_url":"https://api.github.com/users/islandfuture/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/islandfuture/subscriptions","organizations_url":"https://api.github.com/users/islandfuture/orgs","repos_url":"https://api.github.com/users/islandfuture/repos","events_url":"https://api.github.com/users/islandfuture/events{/privacy}","received_events_url":"https://api.github.com/users/islandfuture/received_events","type":"User","site_admin":false},"created_at":"2018-05-29T09:19:19Z","updated_at":"2018-05-29T09:19:19Z","author_association":"COLLABORATOR","body":"Спасибо за найденный баг.\r\nПоправил. Выгрузил - версия 0.2.29\r\n\r\nPS: проверку убрать нельзя - добавил в разрешенные символы знаки подчеркивания и минус."}}
{"actor":{"display_login":"islandfuture"}}