Skip to content

Instantly share code, notes, and snippets.

@ethicka
ethicka / head.js.chrome-ios.js
Created November 10, 2013 18:17
Add Chrome iOS class using head.js
head.ready(function() {
if(navigator.userAgent.match('CriOS')) head.feature("chrome-ios", true);
else head.feature("chrome-ios", false);
});
@ethicka
ethicka / hardening-wp.md
Last active September 18, 2016 22:52
Hardening WordPress

Hardening WordPress

Change file permissions

Run the following commands:

find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} \;

find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} \;

@ethicka
ethicka / acf-validate-facebook-url-field.php
Last active July 3, 2017 15:38
ACF Validate Facebook Field
<?php
/*
* Validate Facebook URL field
* URL field must be named "facebook_video_url" or you can change is in the filter below.
* Source: https://www.advancedcustomfields.com/resources/acf-validate_value/
*/
function acf_validate_facebook_url( $valid, $value, $field, $input ){
// If already not valid, then exit
if( !$valid ) {
return $valid;
@ethicka
ethicka / wrap-link-if-url-passed.php
Created July 5, 2017 17:50
Wrap Link if URL is Passed

Common Commands

Apache (Ubuntu)

apache2ctl configtest - Configtest before restarting Apache.

service apache restart - Restart Apache.

service apache restart - Restart MySQL.

@ethicka
ethicka / redirect-to-homepage
Last active March 21, 2018 14:02
.htaccess redirect to homepage
# Redirect to homepage
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? http://example.com/ [R=301,L]
@ethicka
ethicka / restore-trash.md
Created July 31, 2018 14:39
Restoring Trash functionality if Trash forces you to immediately delete files in Mac OS High Sierra.

Restore Trash

Run the following commands in shell:

rm -rf ~/.Trash/
mkdir ~/.Trash/

Then relaunch the Finder to apply permissions: Command + Option + Esc and Relaunch Finder.

@ethicka
ethicka / abbreviations.txt
Created September 20, 2019 17:42
WP ACF States Abbreviations Values
AL : Alabama
AK : Alaska
AS : American Samoa
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
DC : District of Columbia
@ethicka
ethicka / build-a-name.php
Created April 29, 2020 21:37
Build a name from a prefix and suffix
<?php
/**
* Build a name
*/
function build_name($prefix, $fname, $lname, $suffix) {
$name = $fname . ' ' . $lname;
if($prefix) $name = $prefix . ' ' . $name;
if($suffix) $name = $name .= $suffix;
return $name;
}
@ethicka
ethicka / build-comma-separated-string.php
Created April 29, 2020 21:38
Build a comma separated string of one or more strings
<?php
/**
* Build Comma-Separated String
* Won't add a hanging comma if there's only passed value
*/
function comma_separated($array) {
$string = implode(', ', $array);
if (preg_match("/, $/", $string)) { // if it ends in a comma, remove the comma
$string = substr($string, 0, -2);
}