Skip to content

Instantly share code, notes, and snippets.

@castorstudio
castorstudio / SLUG.md
Created April 19, 2024 18:35 — forked from lucasmezencio/SLUG.md
Creating URL slugs properly in PHP (including transliteration for UTF-8)

Creating URL slugs properly in PHP (including transliteration for UTF-8)

The point to use a slug (semantic URL) besides of improve the SEO of your articles is to prevent that the user, at the creation of for example an article, it uses special characters that aren't allowed in a URL, appropiate the usage etc. What target usage means, is context dependent.

In this article, you'll learn how to slugify a string in PHP properly, including (or not) support (conversion) for cyrilic and special latin characters.

Slugify in PHP

The following function exposes a simple way to convert text into a valid slug:

@castorstudio
castorstudio / jet-booking-muliple-units.php
Created November 23, 2022 13:15 — forked from Crocoblock/jet-booking-muliple-units.php
JetBooking. Allow to book multiple units at single purchase
<?php
/**
* Allow to book multiple units/appartments/tickets at same date/dates with single purchase
* You need to add '_capacity' field into the form. This field should be responsible for number of booked items
*/
add_filter( 'jet-booking/form-action/pre-process', function( $result, $booking, $action ) {
$capacity = absint( $action->getRequest( '_capacity' ) );
if ( ! $capacity && 1 === $capacity ) {
@castorstudio
castorstudio / wp-related-posts.php
Created February 25, 2022 19:00
Wp_Query related posts
@castorstudio
castorstudio / class-virtualthemedpage-bc.php
Created July 8, 2021 19:04 — forked from brianoz/class-virtualthemedpage-bc.php
WordPress Virtual page with theme
<?php
/*
* Virtual Themed Page class
*
* This class implements virtual pages for a plugin.
*
* It is designed to be included then called for each part of the plugin
* that wants virtual pages.
*
* It supports multiple virtual pages and content generation functions.
@castorstudio
castorstudio / Apache.md
Created April 12, 2021 16:04 — forked from ignatisD/Apache.md
MailHog localhost xampp/wamp integration

#MailHog example page

MailHog is an email testing tool for developers.

It gives the developer the option to intercept and inspect the emails sent by his application.

You can download the MailHog Windows client from one of the links below.