Skip to content

Instantly share code, notes, and snippets.

View shishirraven's full-sized avatar
🖥️
Coding

Shishir Raven shishirraven

🖥️
Coding
View GitHub Profile
@shishirraven
shishirraven / BraveDropMenuTag.vue
Created January 14, 2022 19:17
BraveDropMenuTag
<BraveDropMenu>
...
</BraveDropMenu>
@shishirraven
shishirraven / BraveDropMenuAddButton.vue
Created January 14, 2022 19:20
BraveDropMenuAddButton
<BraveDropMenu>
<template #button>
<div role="button" class="btn btn-light px-3 "> <i class="bi bi-plus-lg"></i> Button <i class="bi bi-chevron-down"></i></div>
</template>
</BraveDropMenu>
@shishirraven
shishirraven / BraveDropMenuExampleWithBothSlots.vue
Created January 14, 2022 19:21
BraveDropMenuExampleWithBothSlots
<BraveDropMenu class="me-3">
<template #button>
<div role="button" class="btn btn-primary text-white px-3 "> <i class="bi bi-plus-lg"></i> Button <i class="bi bi-chevron-down"></i></div>
</template>
<template #menu>
<div class="list-group bg-white shadow" style="min-width:200px;" >
<div role="button" class="list-group-item list-group-item-action"><i class="bi me-1 bi-person-plus"></i> A second link item</div>
<div role="button" class="list-group-item list-group-item-action"><i class="bi me-1 bi-envelope-plus"></i> A second link item</div>
</div>
</template>
<template>
<div>
<BraveSelect class="me-3" v-model="selectValue" :options="options" dropdown-class="shadow rounded border list-group bg-white">
<template v-slot:button="{ selectedValue }">
<div role="button" class="btn btn-primary text-white px-3 d-flex ">
<div v-if="selectedValue!=null">
<strong>{{ selectedValue.name }} </strong> is written in <strong> {{ selectedValue.language }}</strong>
</div>
<div v-else>
Select a Value
@shishirraven
shishirraven / function.php
Created January 24, 2022 00:45
Add meta your meta field to the allowed values of the REST API orderby parameter
$post_type ="wf_account";
// Add meta your meta field to the allowed values of the REST API orderby parameter
add_filter(
'rest_' . $post_type . '_collection_params',
function( $params ) {
$fields = ["first_name","last_name","address","email"];
foreach ($fields as $key => $value) {
$params['orderby']['enum'][] = $value;
}
return $params;
@shishirraven
shishirraven / function.php
Created January 24, 2022 01:31
Adding Orderby support for custom meta fields
add_filter(
'rest_' . $post_type . '_query',
function ( $args, $request ) {
$fields = ["first_name","last_name","address","email"];
$order_by = $request->get_param( 'orderby' );
if ( isset( $order_by ) && in_array($order_by, $fields)) {
$args['meta_key'] = $order_by;
$args['orderby'] = 'meta_value'; // user 'meta_value_num' for numerical fields
}
return $args;
add_action( 'rest_api_init', 'addOrderbySupportRest' );
function addOrderbySupportRest(){
$post_type ="wf_account";
// Add meta your meta field to the allowed values of the REST API orderby parameter
add_filter(
'rest_' . $post_type . '_collection_params',
function( $params ) {
$fields = ["first_name","last_name","address","email"];
add_action( 'rest_api_init', 'rest_api_filter_add_filters' );
/**
* Add the necessary filter to each post type
**/
function rest_api_filter_add_filters() {
foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
add_filter( 'rest_' . $post_type->name . '_query', 'rest_api_filter_add_filter_param', 10, 2 );
}
}
<style lang="scss">
$card-border-radius:.95rem;
$card-bg:rgba(248,246,242,.3);
$border-radius: .45rem !default;
$border-radius-sm: .3rem !default;
$border-radius-lg: .4rem !default;
@import url(https://fonts.googleapis.com/css?family=Poppins:200,300,400,700);
@shishirraven
shishirraven / vue.config.js
Created February 5, 2022 18:45
How to turn off filenameHasing
module.exports = {
publicPath: './',
filenameHashing :false}