Skip to content

Instantly share code, notes, and snippets.

@vitorspencer
vitorspencer / bp-custom.php
Last active May 11, 2021 20:48
Add Buddypress xProfile Languages select field
<?php
/*
Add a Language (multi) select field to Buddypress xProfile fields.
You can adapt it to any other type of select field, for example one with list of Countries, Cities, etc...
Add the following to /wp-content/plugins/bp-custom.php and then visit /wp-admin/users.php?page=bp-profile-setup
Read more about bp-custom.php at the official Buddypress https://codex.buddypress.org/themes/bp-custom-php/
*/
function bp_add_languages_xprofile_select_field() {
$.fn.select2.amd.define('select2/data/extended-ajax',['./ajax','./tags','../utils','module','jquery'], function(AjaxAdapter, Tags, Utils, module, $){
function ExtendedAjaxAdapter ($element,options) {
//we need explicitly process minimumInputLength value
//to decide should we use AjaxAdapter or return defaultResults,
//so it is impossible to use MinimumLength decorator here
this.minimumInputLength = options.get('minimumInputLength');
this.defaultResults = options.get('defaultResults');
ExtendedAjaxAdapter.__super__.constructor.call(this,$element,options);
@vitorspencer
vitorspencer / functions.php
Created March 14, 2018 18:02
Wordpress Functions
<?php
/*
* Add your own functions here. You can also copy some of the theme functions into this file.
* Wordpress will use those functions instead of the original functions then.
*/
function mytheme_enqueue_styles() {
wp_register_style('googleFonts', '//fonts.googleapis.com/css?family=Roboto+Condensed:400,700');
wp_enqueue_style( 'googleFonts');
@vitorspencer
vitorspencer / flush-dns.sh
Last active March 10, 2018 10:02
Flush DNS cache Ubuntu 16.04
# !/bin/bash
# NB: First install nscd with sudo apt-get install nscd
# run this command to flush dns cache:
sudo /etc/init.d/dns-clean restart
# or use:
sudo /etc/init.d/networking force-reload
# Flush nscd dns cache:
sudo /etc/init.d/nscd restart
# If you wanted to refresh your settings you could disable and then run
sudo service network-manager restart
@vitorspencer
vitorspencer / 0_reuse_code.js
Created August 10, 2016 20:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console