Skip to content

Instantly share code, notes, and snippets.

/**
* @brief Splits an address string containing a street, number and number addition
*
* @param $streetStr string An address string containing a street, number (optional) and number addition (optional)
*
* @return array Data array with the following keys: street, number and numberAddition.
*/
private function split_street($streetStr) {
$aMatch = array();
@jakebellacera
jakebellacera / ICS.php
Last active June 2, 2024 02:20
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@Eckankar
Eckankar / domain.php
Created January 10, 2011 19:06
Scans for 3-letter domains
<?php
///////////////////////////////////////////////////////////////////////////////
//
// Scans for 3-letter domain names.
//
///////////////////////////////////////////////////////////////////////////////
// This is the number of domains the script will stop at.
$i = 100;
ob_start();
@jo-snips
jo-snips / events-conditional-wrappers.php
Last active December 21, 2023 12:27
The Events Calendar: Basic Conditional Wrappers
<?php
/*-----------------------------------------------------------------------------------*/
/* Conditional Logic to Detect Various Event Related Views/Pages
/*-----------------------------------------------------------------------------------*/
if( tribe_is_month() && !is_tax() ) { // Month View Page
echo 'were on the month view page';
} elseif( tribe_is_month() && is_tax() ) { // Month View Category Page
@absfarah
absfarah / CSS_Specificity.php
Created May 23, 2012 09:09
A PHP function that determines the specificity of a CSS selector
<?php
function specificity($selector) {
// Pseudo classes
$classes = array(":link", ":visited", ":hover", ":active", ":focus", ":target", ":lang", ":enabled",
":disabled", ":checked", ":indeterminate", ":root", ":nth-child", ":nth-last-child",
":nth-of-type", ":nth-last-of-type", ":first-child", ":last-child", ":first-of-type",
":last-of-type", ":only-child", ":only-of-type", ":empty", ":contains", ":not");
// Pseudo elements
@jo-snips
jo-snips / custom-events-advanced-widget.php
Created June 9, 2012 16:17
The Events Calendar: Custom Events Advanced List Widget
<?php
/**
* This is the template for the output of the events list widget.
* All the items are turned on and off through the widget admin.
* There is currently no default styling, which is highly needed.
*
* You can customize this view by putting a replacement file of the same name (events-list-load-widget-display.php) in the events/ directory of your theme.
*
* When the template is loaded, the following vars are set: $start, $end, $venue, $address, $city, $state, $province'], $zip, $country, $phone, $cost
@kenkubiak
kenkubiak / Sprite.php
Created September 4, 2012 22:56
Building an SVG Sprite from SVG icon assets ... in PHP
<?php
/**
* Create an SVG sprite as a DOMDocument.
*/
class Sprite {
/**
* The URI for the SVG namespace.
*
@asaokamei
asaokamei / Tags.php
Created September 19, 2012 02:39
PHP HTML Tag Generator Class.
<?php
/**
* @method Tags a()
* @method Tags href()
* @method Tags target()
* @method Tags style()
* @method Tags div()
* @method Tags input()
* @method Tags value()
@justintadlock
justintadlock / in-main-loop.php
Last active February 11, 2024 20:23
A conditional tag for checking if we're in the core WP main query + loop.
<?php
/**
* Conditional to test if we're in the loop of the main query on a WordPress page.
* Please note that checking `in_the_loop() && is_main_query()` will NOT work in
* this scenario.
*/
add_action( 'loop_start', 'my_loop_start' );
add_action( 'loop_end', 'my_loop_end' );
@bradp
bradp / gist:4999343
Last active September 5, 2022 20:36
WordPress function to convert address to Lat/Long
<?php
function brrad_geocode($street_address,$city,$state){
$street_address = str_replace(" ", "+", $street_address); //google doesn't like spaces in urls, but who does?
$city = str_replace(" ", "+", $city);
$state = str_replace(" ", "+", $state);
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=$street_address,+$city,+$state&sensor=false";
$google_api_response = wp_remote_get( $url );