Created
June 24, 2020 05:25
-
-
Save farookibrahim/46517529583c0206e0cfe90d87dcfc5c to your computer and use it in GitHub Desktop.
Vodi - Customize Shortcode Atts Orderby Options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if( ! function_exists( 'vodi_child_block_editor_assets_shortcode_atts_orderby_options' ) ) { | |
| function vodi_child_block_editor_assets_shortcode_atts_orderby_options() { | |
| $custom_script = ' | |
| var addFilter = wp.hooks.addFilter; | |
| addFilter("vodi.component.shortcodeAtts.orderby.options", "vodi-child/shortcode-atts-orderby-options", vodiChildShortCodeOrderbyOptions); | |
| function vodiChildShortCodeOrderbyOptions(options,props) { | |
| const { postType } = props; | |
| return [ | |
| { label: "Title", value: "title" }, | |
| { label: "Date", value: ( postType === "movie" ? "release_date" : "date" ) }, | |
| { label: "ID", value: "id" }, | |
| { label: "Random", value: "rand" }, | |
| ]; | |
| } | |
| '; | |
| wp_add_inline_script( 'wp-blocks', $custom_script ); | |
| } | |
| } | |
| add_action( 'enqueue_block_editor_assets', 'vodi_child_block_editor_assets_shortcode_atts_orderby_options', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment