Skip to content

Instantly share code, notes, and snippets.

View stgoos's full-sized avatar

Steven stgoos

  • The Netherlands
View GitHub Profile
@stgoos
stgoos / SLUG.md
Created January 5, 2023 09:36 — 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:

@stgoos
stgoos / gw-gravity-forms-minimum-characters.php
Created December 28, 2022 09:17 — forked from spivurno/gw-gravity-forms-minimum-characters.php
Gravity Wiz // Require Minimum Character Limit for Gravity Forms
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-min-and-max-character-limit.php
*/
/**
* Gravity Wiz // Require Minimum Character Limit for Gravity Forms
*
* Adds support for requiring a minimum number of characters for text-based Gravity Form fields.
@stgoos
stgoos / functions.php
Created December 28, 2022 09:11 — forked from rmrf-run/functions.php
Gravity forms validation for IP address, valid URLs, and regex
<?php
add_filter('gform_validation_1', 'ip_validation');
function ip_validation($validation_result){
$form = $validation_result["form"];
//validate input 9 on form 1 for valid IP
if($_POST['input_9'] != filter_var($_POST['input_9'], FILTER_VALIDATE_IP)){
$validation_result["is_valid"] = false;
foreach($form["fields"] as &$field){
if($field["id"] == "9"){
$field["failed_validation"] = true;
@stgoos
stgoos / debug.log
Created December 9, 2022 14:28 — forked from damiencarbery/debug.log
Description: Disable selected plugins for specific IP addresses - very useful when debugging plugin clashes: k: https://www.damiencarbery.com/2018/03/disable-selected-plugins-for-specified-ips/
[10-Mar-2018 16:08:01 UTC]
array (
//query-monitor/query-monitor.php,
//hello.php,
);
@stgoos
stgoos / multisite-plugins-activated.php
Created December 9, 2022 13:47 — forked from damiencarbery/multisite-plugins-activated.php
Active Multisite Plugins: List of active plugins on a Multisite installation. https://www.damiencarbery.com/2019/05/active-multisite-plugins/
<?php
/*
Plugin Name: Multisite Plugins Activate
Plugin URI: http://www.damiencarbery.com
Description: List of active plugins on a Multisite installation.
Author: Damien2
*/
// Based on: http://wordpress.stackexchange.com/a/54782/57684
@stgoos
stgoos / Excel VBA - SFDC 15 to 18
Created September 26, 2022 15:36 — forked from trevorcgibson/Excel VBA - SFDC 15 to 18
VBA code for Microsoft Excel to convert 15-digit Salesforce.com record ids to their 18-digit checksum version. Use by adding into a new module in the Excel VBA code editor. NOTE: I did not write this - but can't quite remember who/where I got it from. If it's yours, please let me know and I'll update to provide attribution.
Function FixID(InID As String) As String
If Len(InID) = 18 Then
FixID = InID
Exit Function
End If
Dim InChars As String, InI As Integer, InUpper As String
Dim InCnt As Integer
@stgoos
stgoos / gist:5594402350397b3c9ce59f29817bb605
Last active April 14, 2022 22:03 — forked from spivurno/gp-limit-choices-shared-limits-field.php
Gravity Perks // Limit Choices // Shared Limits Field
We couldn’t find that file to show.
@stgoos
stgoos / gw-gravity-forms-submission-limit.php
Created April 14, 2022 22:00 — forked from spivurno/gw-gravity-forms-submission-limit.php
Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value)
<?php
/**
* Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value)
*
* Limit the number of times a form can be submitted per a specific time period. You modify this limit to apply to
* the visitor's IP address, the user's ID, the user's role, a specific form URL, or the value of a specific field.
* These "limiters" can be combined to create more complex limitations.
*
* @version 3.0
* @author David Smith <[email protected]>
@stgoos
stgoos / custom-registration-fields.php
Created June 28, 2021 17:31 — forked from meetawahab/custom-registration-fields.php
Add First Name & Last Name field on the WordPress registration form.
<?php
add_action( 'register_form', 'loginpress_plugin_register_form_custom_field' );
function loginpress_plugin_register_form_custom_field() {
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : '';
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : ''; ?>
<p>
<label for="first_name">
<?php _e( 'First Name', 'loginpress' ) ?><br />
<?php
# SHORTS
# DIRECTORY SEPARATOR
define( 'DS', DIRECTORY_SEPARATOR );
# PATH SEPARATOR
define( 'PS', PATH_SEPARATOR );
# Absolute path to the WordPress directory.
! defined( 'ABSPATH' )
AND define( 'ABSPATH', dirname( __FILE__ ).DS );