Skip to content

Instantly share code, notes, and snippets.

@wrabit
wrabit / helpers.php
Last active Mar 18, 2020
PHP: Camel case to title case function
View helpers.php
if (!function_exists('camel_to_title')) {
function camel_to_title($string = '')
{
// let's create spaces
$intermediate = preg_replace('/(?!^)([[:upper:]][[:lower:]]+)/', ' $0', $string);
// now upper case words
return mb_convert_case($intermediate, MB_CASE_TITLE);
}
}
@wrabit
wrabit / _bulma_responsive_titles.scss
Last active Apr 8, 2019
Scaling responsive title sizing for Bulma
View _bulma_responsive_titles.scss
@include mobile {
.title.is-1 { font-size: $size-1 * 0.7 }
.title.is-2 { font-size: $size-2 * 0.7 }
.title.is-3 { font-size: $size-3 * 0.7 }
.title.is-4 { font-size: $size-4 * 0.7 }
.title.is-5 { font-size: $size-5 * 0.7 }
.title.is-6 { font-size: $size-6 * 0.7 }
}
@include tablet {
.title.is-1 { font-size: $size-1 * 0.8 }
@wrabit
wrabit / _bootstrap_bulma_helpers.scss
Last active Mar 29, 2020
Bootstrap style responsive helper utilities for Bulma
View _bootstrap_bulma_helpers.scss
/*
Start Bootstrap style responsive spacer helper
Utilities for spacing, text and float
*/
$spacer: 1rem !default;
$spacers: () !default;
$spacers: map-merge((
@wrabit
wrabit / Detect the first and last post in the WordPress loop
Last active May 24, 2018
Detect the first and last post in Wordpress loop
View Detect the first and last post in the WordPress loop
if ( $wp_query->post_count == 0 ) {
// First post
}
if( ( $wp_query->current_post +1) == $wp_query->post_count ) {
// Last post
}
// detect first, even in paginated results
if( $wp_query->post_count == 0 && !is_paged() ) {
@wrabit
wrabit / slugify-with-transliteration-of-foreign-characters.php
Last active Oct 29, 2018
Simple URL Slugging Function with Transliteration
View slugify-with-transliteration-of-foreign-characters.php
<?php
/**
* Slugifies a given string prepping it for usage as a URL string. Includes transliteration. Multi-byte ready for UTF-8.
* @param str $str Original url
* @param str $delimiter Separator to be used between words, default '-'
* @param bool $strtolower Keep existing case or convert all to lower, default true
* @return str Sluggified string;
*/
function slugify($str = '', $delimiter='-', $strtolower = true) {
$str = convert_foreign_characters($str);
You can’t perform that action at this time.