Skip to content

Instantly share code, notes, and snippets.

@esedic
esedic / .htaccess
Created June 5, 2021 16:20 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@esedic
esedic / version-string.php
Created April 6, 2021 12:49 — forked from marsjaninzmarsa/version-string.php
My solution for cache busting in WordPress (drop-in to `/mu-plugins/` in Bedrock).
<?php
/**
* Replaces query version in registered scripts or styles with file modified time
*
* @link https://wordpress.stackexchange.com/a/346024/51130 based on
*
* @param $src
*
* @return string
@esedic
esedic / countUp-jquery.js
Created January 3, 2021 11:22 — forked from inorganik/countUp-jquery.js
A CountUp extension for jQuery
// Dependency: CountUp.js: https://github.com/inorganik/CountUp.js
(function ($) {
$.fn.countup = function (params) {
// make sure dependency is present
if (typeof CountUp !== 'function') {
console.error('countUp.js is a required dependency of countUp-jquery.js.');
return;
}
@esedic
esedic / youtube_id_regex.php
Created November 11, 2020 09:24 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@esedic
esedic / csv_to_array.php
Created October 29, 2020 13:40 — forked from fadupla/csv_to_array.php
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
<?php
$args = [
// parameters go here
];
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// display the post
@esedic
esedic / get_article_link.php
Created June 22, 2020 13:13 — forked from KrenTrox/JOOMLA + PHP : get article (menu) link
Get article (menu) link in Joomla
<?php
JRoute::_(ContentHelperRoute::getArticleRoute($item->id, $item->catid))
<?php
function the_date_range($args) {
global $post;
$default = array(
'start_field' => 'start_date',
'end_field' => null,
'base_format' => 'Ymd',
'post_id' => $post->ID,
'separator' => '<span class="date-separator">&ndash;</span>',
'month_format' => 'F',
@esedic
esedic / GoogleMapsApi.js
Created December 22, 2019 09:29 — forked from mavame/GoogleMapsApi.js
A simple class for loading the Google Maps Javascript API in browser async using ES6 and Promise
/**
* Use this class to ensure Google Maps API javascript is loaded before running any google map specific code.
*/
export class GoogleMapsApi {
/**
* Constructor set up config.
*/
constructor() {
// api key for google maps
@esedic
esedic / pizza.json
Created December 22, 2019 09:26 — forked from mavame/pizza.json
Sample pizza locations
{
"businesses": [
{
"id": "minellis-pizza-columbus-2",
"name": "Minelli's Pizza",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/RClRY8K40PbFvE-zg6CNJA/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/minellis-pizza-columbus-2?adjust_creative=MCLKONVnfSv060BOXT4UYQ&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=MCLKONVnfSv060BOXT4UYQ",
"review_count": 31,
"categories": [