Snippets Collections
function example_return_select_label ($field_selector, $post_id) {
	$field = get_field_object($field_selector, $post_id);

	$choices = $field['choices'];
	$value = $field['value'];

	if ( isset($choices[$value]) ) {
		return $choices[$value];
	}
}


// Example usage (https://d.pr/i/Xj7DQ3):
//[example_return_select_label("field_6247468a6a53a",{ID})]
const friends = [
  { name: "Abby", age: 22 },
  { name: "Boby", age: 16 },
  { name: "Coel", age: 20 },
  { name: "Dany", age: 15 }
];

//who can drink?
friends.filter(friend => friend.age >= 18);


//get list of buttons and make sure there are no duplicates

function displayButtons(){
    const companies = products.reduce((total, item) => {
       total.push(item.company)
       total = [...new Set(total)]
       return total
    },['All'])
 
    const buttons = companies.map((item) => {
       return `<button class="company-btn">${item}</button>`
    }).join('')
 
    buttonsContainer.innerHTML = buttons
 
 }


 // or we could do this...
 const someBtns = ['all',...new Set(products.map((product) => product.company)),];  
  console.log(someBtns)
<?php

add_filter( 'acf/validate_value/name=property_size', 'validate_property_size_field', 10, 4 );

function validate_property_size_field( $valid, $value, $field, $input ){

  // bail early if value is already invalid
  if ( ! $valid ) { return $valid; }

  $property_type = $_POST['acf']['field_5f0aa92348bb6'];

  if ( $property_type == 'Rent' ){
    if ( ! $value ) {
      $valid = __( 'This field is required for Rental Properties' );
    }
  }

  return $valid;

}
Sort(Filter('YouTube Resources', Text(Created,"mm/dd/yyyy") = Text(Today(),"mm/dd/yyyy")), Created,Descending)
Set(currentUser, User()); //require for the on start property

Set(varFirstName, Trim(Last(FirstN(Split(currentUser.FullName," "), 1)).Result))
CheckOutFrom eq '@{formatDateTime(utcNow(), 'yyyy-MM-dd')}'
/**
*   WooCommerce woocommerce_order_item_line_item_html action hook registeration.
*/
add_action('woocommerce_order_item_line_item_html', 'woocommerce_order_item_line_item_html', 1, 3);


/**
* Callback Listener for customised line item functionality in the admin.
*/
function woocommerce_order_item_line_item_html($item_id, $item, $order){
    // Add your custom line item functionality.
    // A good example would be order fulfillment for a line item.
}
add_filter( 'woocommerce_product_get_stock_quantity' ,'custom_get_stock_quantity', 10, 2 );
add_filter( 'woocommerce_product_variation_get_stock_quantity' ,'custom_get_stock_quantity', 10, 2 );
function custom_get_stock_quantity( $value, $product ) {
    $value = 15; // <== Just for testing
    return $value;
}
To Filter Model Array:

var filteredItems = unfilteredItems.filter { $0.cat == "garden" }

To Filter an Array:

let result = arr.filter {$0.contains("ali")}
Get-Service | Where-Object -FilterScript {$_.StartType -EQ 'Automatic'}
import React from 'react';

const people = [
  {
    name: 'James',
    age: 31,
  },
  {
    name: 'John',
    age: 45,
  },
  {
    name: 'Paul',
    age: 65,
  },
  {
    name: 'Ringo',
    age: 49,
  },
  {
    name: 'George',
    age: 34,
  }
];

function App() {
  return (
    <div>
      {people.filter(person => person.age < 60).map(filteredPerson => (
        <li>
          {filteredPerson.name}
        </li>
      ))}
    </div>
  );
}

export default App;
import React from 'react';

const names = ['James', 'John', 'Paul', 'Ringo', 'George'];

function App() {
  return (
    <div>
      {names.filter(name => name.includes('J')).map(filteredName => (
        <li>
          {filteredName}
        </li>
      ))}
    </div>
  );
}

export default App;
c3 = pd.Series(['China', 'US'])
df[df['countries'].isin(c1)]
# applying filter function 
df.filter(["Name", "College", "Salary"]) 

# importing pandas as pd 
import pandas as pd 
  
# Creating the dataframe  
df = pd.read_csv("nba.csv") 
  
# Using regular expression to extract all 
# columns which has letter 'a' or 'A' in its name. 
df.filter(regex ='[aA]') 
star

Wed Apr 05 2023 22:14:21 GMT+0000 (UTC) https://codetogo.io/how-to-filter-objects-in-array-in-javascript/

#javascript #array #filter #object
star

Mon Dec 19 2022 23:12:50 GMT+0000 (UTC)

#reduce #array #map #filter
star

Thu Sep 08 2022 08:24:18 GMT+0000 (UTC) https://itsmereal.com/advanced-custom-fields-conditional-required-field/

#wordpress #acf #require #field #conditionally #filter
star

Sat Jul 23 2022 09:10:03 GMT+0000 (UTC) https://powerusers.microsoft.com/t5/Building-Power-Apps/Sort-by-date-and-time/m-p/375869#M108713

#powerapps #filter #sortby
star

Tue May 31 2022 19:36:45 GMT+0000 (UTC) https://stackoverflow.com/questions/47611251/any-way-to-overwrite-get-stock-quantity-in-my-functions-php

#wordpress #php #stock #quantity #filter
star

Thu Jan 13 2022 10:58:19 GMT+0000 (UTC) https://stackoverflow.com/questions/48467867/adding-a-filter-to-an-array-in-swift-4

#swift #filter #array #ios
star

Mon Nov 08 2021 14:20:28 GMT+0000 (UTC) https://adamtheautomator.com/powershell-where-object/

#powershell #filter
star

Tue Jun 29 2021 09:34:54 GMT+0000 (UTC) https://upmostly.com/tutorials/react-filter-filtering-arrays-in-react-with-examples

#array #react.js #javascript #react #filter #map
star

Sat Oct 31 2020 00:55:40 GMT+0000 (UTC) https://stackoverflow.com/questions/19960077/how-to-filter-pandas-dataframe-using-in-and-not-in-like-in-sql

#pandas #isin #filter
star

Sat Oct 31 2020 00:40:59 GMT+0000 (UTC) https://www.geeksforgeeks.org/python-pandas-dataframe-filter/

#pandas #filter #column
star

Sat Oct 31 2020 00:38:58 GMT+0000 (UTC) https://www.geeksforgeeks.org/python-pandas-dataframe-filter/

#pandas #filter

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension