Skip to content

Instantly share code, notes, and snippets.

<?php
function sc_embassy_countries() {
return array("Afghanistan","Albania","Algeria","Andorra","Angola","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Central African Republic","Chad","Chile","China","Colombia","Comoros","Cook Islands","Costa Rica","Croatia","Cuba","Cyprus","Czech Republic","Democratic Republic of Congo","Denmark","Djibouti","Dominican Republic","East Timor","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia","Georgia","Germany","Ghana","Greece","Greenland","Grenada","Guatemala","Guinea","Guinea - Bissau","Guyana","Haiti","Honduras","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Ivory Coast","Jamaica","Japan","
@albionselimaj
albionselimaj / icon.php
Created July 5, 2017 08:40
Override Elementor's 'Icon' control to include custom icon packs.
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* A Font Icon select box.
*/
class CASE27_Elementor_Control_Icon extends Control_Base {
<?php
return [
'&#xf26e;' => 'fa-500px',
'&#xf2b9;' => 'fa-address-book',
'&#xf2ba;' => 'fa-address-book-o',
'&#xf2bb;' => 'fa-address-card',
'&#xf2bc;' => 'fa-address-card-o',
'&#xf042;' => 'fa-adjust',
'&#xf170;' => 'fa-adn',
<?php
return [
'&#xE84D;' => '3d_rotation',
'&#xE190;' => 'access_alarm',
'&#xE191;' => 'access_alarms',
'&#xE192;' => 'access_time',
'&#xE84E;' => 'accessibility',
'&#xE84F;' => 'account_balance',
'&#xE850;' => 'account_balance_wallet',
@albionselimaj
albionselimaj / custom-content-blocks.php
Last active November 6, 2017 14:00
Add custom content blocks
<?php
/*
* my-listing-child/functions.php
*/
add_filter( 'case27/listingtypes/profile_layout_blocks', function( $blocks ) {
$blocks[] = [
'type' => 'block_name', // needs to be something unique
'icon' => 'view_headline', // from material-icons list
'title' => 'Block Title',
@albionselimaj
albionselimaj / kmllayers.php
Created November 28, 2017 04:34
kmllayers
<?php
# 1. Install MyListing Child Theme
# 2. Make sure you're editing through FTP, so you can restore the page if anything goes wrong.
# 3. Paste the code below in my-listing-child/functions.php below line 11.
// Enqueue script.js
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_script( 'child-script',
get_stylesheet_directory_uri() . '/script.js', ['jquery'],
(function() {
if ( document.getElementsByClassName('finder-map').length ) {
var interval = setInterval(function() {
if ( CASE27_Maps.get( CASE27_Explore_Listings.$xyz.map.id ) ) {
var map = CASE27_Maps.get( CASE27_Explore_Listings.$xyz.map.id ).map;
map.setOptions({
mapTypeControl: true,
scrollwheel: true,
styles: [],
@albionselimaj
albionselimaj / functions.php
Created January 3, 2018 04:49
Listing description character limit
// Limit listing description character length
add_filter('submit_job_form_validate_fields', function( $isValid, $fields, $values ) {
$description_character_limit = 280;
foreach ( $fields['job'] as $key => $field ) {
if ($field['slug'] == 'job_description' && isset($values['job']['job_description']) && strlen($values['job']['job_description']) > $description_character_limit) {
return new \WP_Error( 'validation-error', sprintf( __( '%s can\'t be longer than %s characters.', 'my-listing' ), $field['label'], $description_character_limit ) );
}
}
@albionselimaj
albionselimaj / functions.php
Created January 21, 2018 01:04
Add Terms & Condtions in WooCommerce registration form
add_action( 'woocommerce_register_form', function() {
wc_get_template( 'checkout/terms.php' );
} );
add_action( 'woocommerce_process_registration_errors', function( $errors, $username, $password, $email ){
if ( empty( $_POST['terms'] ) ) {
throw new Exception( __( 'You must accept the terms and conditions in order to register.', 'text-domain' ) );
}
return $errors;
}, 10, 4 );
@albionselimaj
albionselimaj / functions.php
Created January 21, 2018 11:33
Disable post author email on new comments
add_filter( 'comment_notification_recipients', '__return_empty_array', PHP_INT_MAX );
add_filter( 'comment_moderation_recipients', '__return_empty_array', PHP_INT_MAX );