Skip to content

Instantly share code, notes, and snippets.

@farookibrahim
Created June 24, 2020 05:25
Show Gist options
  • Select an option

  • Save farookibrahim/46517529583c0206e0cfe90d87dcfc5c to your computer and use it in GitHub Desktop.

Select an option

Save farookibrahim/46517529583c0206e0cfe90d87dcfc5c to your computer and use it in GitHub Desktop.
Vodi - Customize Shortcode Atts Orderby Options
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