{"action":"created","issue":{"url":"https://api.github.com/repos/fusioneng/Shortcake/issues/464","labels_url":"https://api.github.com/repos/fusioneng/Shortcake/issues/464/labels{/name}","comments_url":"https://api.github.com/repos/fusioneng/Shortcake/issues/464/comments","events_url":"https://api.github.com/repos/fusioneng/Shortcake/issues/464/events","html_url":"https://github.com/fusioneng/Shortcake/issues/464","id":108091930,"number":464,"title":"Conditionally show/hide in modal selection?","user":{"login":"GaryJones","id":88371,"avatar_url":"https://avatars.githubusercontent.com/u/88371?v=3","gravatar_id":"","url":"https://api.github.com/users/GaryJones","html_url":"https://github.com/GaryJones","followers_url":"https://api.github.com/users/GaryJones/followers","following_url":"https://api.github.com/users/GaryJones/following{/other_user}","gists_url":"https://api.github.com/users/GaryJones/gists{/gist_id}","starred_url":"https://api.github.com/users/GaryJones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GaryJones/subscriptions","organizations_url":"https://api.github.com/users/GaryJones/orgs","repos_url":"https://api.github.com/users/GaryJones/repos","events_url":"https://api.github.com/users/GaryJones/events{/privacy}","received_events_url":"https://api.github.com/users/GaryJones/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-24T09:28:30Z","updated_at":"2015-09-24T13:51:19Z","closed_at":null,"body":"Is there a feature (if not, please consider this a suggestion) to conditionally hide certain post elements in the modal selection?\r\n\r\n![screenshot 2015-09-24 10 59 26](https://cloud.githubusercontent.com/assets/88371/10069798/6d623312-62a6-11e5-87b7-671b6fdc305d.png)\r\n\r\nHere, all of the Member Area items are really \"use once\" shortcodes, in the pages that output that logic (but which clients may want to add manually entered content between). However, for the regular posts where a client wants to use the EIA Visualization, the Member Area icons clutter up the view.\r\n\r\nIs there a way to conditionally choose when icons appear i.e. not only when editing a Page (vs Post) (using existing `post_type` key) but also when the user has a certain ID, or it's a Friday, or some other condition? i.e. some filterable value that accepts a custom closure (which returns true or false) before showing the icon in the modal?\r\n\r\n```php\r\nshortcode_ui_register_for_shortcode(\r\n\t\t'shortcake_dev',\r\n\t\tarray(\r\n\t\t\t...\r\n\t\t\t'post_type'     => array( 'post' ),\r\n\t\t\t'show_ui'      => function() {\r\n\t\t\t\t// Some custom condition that determines when the icon appears. Overrides `post_type`.\r\n\t\t\t\tif ( $foo ) { // Show icon if $foo.\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t...\r\n~~~\r\n\r\nIn my case, since our Member Area is a Page, with child pages, my custom condition would be to only show the Member Area icons when the current Page being edited has an ID of 123 / slug of `profile`, or has a parent with that ID / slug."},"comment":{"url":"https://api.github.com/repos/fusioneng/Shortcake/issues/comments/142933775","html_url":"https://github.com/fusioneng/Shortcake/issues/464#issuecomment-142933775","issue_url":"https://api.github.com/repos/fusioneng/Shortcake/issues/464","id":142933775,"user":{"login":"goldenapples","id":665992,"avatar_url":"https://avatars.githubusercontent.com/u/665992?v=3","gravatar_id":"","url":"https://api.github.com/users/goldenapples","html_url":"https://github.com/goldenapples","followers_url":"https://api.github.com/users/goldenapples/followers","following_url":"https://api.github.com/users/goldenapples/following{/other_user}","gists_url":"https://api.github.com/users/goldenapples/gists{/gist_id}","starred_url":"https://api.github.com/users/goldenapples/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldenapples/subscriptions","organizations_url":"https://api.github.com/users/goldenapples/orgs","repos_url":"https://api.github.com/users/goldenapples/repos","events_url":"https://api.github.com/users/goldenapples/events{/privacy}","received_events_url":"https://api.github.com/users/goldenapples/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T13:51:19Z","updated_at":"2015-09-24T13:51:19Z","body":"> Is there a way to conditionally choose when icons appear i.e. not only when editing a Page (vs Post) (using existing post_type key) but also when the user has a certain ID, or it's a Friday, or some other condition?\r\n\r\nYou can look at the context available to the `register_shortcode_ui` hook, which will give you the ID and the settings of the first editor on the page. (If you register the shortcode UI at that point, globals will also be set up, and you can check for the global post object, or current user, or any other variant).\r\n"}}