Skip to content

Instantly share code, notes, and snippets.

View csymlstd's full-sized avatar

Casey Milstead csymlstd

View GitHub Profile
@csymlstd
csymlstd / strip_atts_from_tags.php
Last active February 19, 2018 17:32
Strip Attributes from Tags
<?php
function strip_attributes($html) {
$dom = new DOMDocument;
$dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$xpath = new DOMXPath($dom);
$nodes = $xpath->query('//@*');
foreach ($nodes as $node) {
if($node->nodeName != "src" && $node->nodeName != "href") {
$node->parentNode->removeAttribute($node->nodeName);
@csymlstd
csymlstd / add_yoast_meta.php
Created February 19, 2018 18:04
Add Yoast Meta
<?php
function add_to_yoast_seo($post_id, $metatitle, $metadesc, $metakeywords){
$ret = false;
// Include plugin library to check if Yoast Seo is presently active
include_once( ABSPATH.'panel/includes/plugin.php' );
if(is_plugin_active(ABSPATH.'wp-content/plugins/wordpress-seo/wp-seo.php')) {
//plugin is activated
$updated_title = update_post_meta($post_id, '_yoast_wpseo_title', $metatitle);
@csymlstd
csymlstd / acf-states.txt
Created March 22, 2018 18:56
ACF States for Select
AL : Alabama
AK : Alaska
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
DC : District of Colombia
FL : Florida
@csymlstd
csymlstd / auth0-wordpress-config.md
Last active March 28, 2018 18:42
auth0 wordpress
@csymlstd
csymlstd / wp-get-post-by-meta.php
Created March 28, 2018 21:10
get wordpress post id by post_meta key and value
<?php
if (!function_exists('get_post_id_by_meta_key_and_value')) {
/**
* Get post id from meta key and value
* @param string $key
* @param mixed $value
* @return int|bool
* @author David M&aring;rtensson <david.martensson@gmail.com>
*/
function get_post_id_by_meta($key, $value) {
@csymlstd
csymlstd / gform-double-opt-in.php
Created April 20, 2018 19:56
Sending dynamic opt-in emails with tokens and updating form entries with opt-in. Helps with GDPR compliance of Gravity Forms.
// Confirm Email Address
add_action('template_redirect', function() {
if(is_page('confirm-email') && !isset($_GET['failed'])) {
if(!isset($_GET['form'])) {
wp_redirect('/confirm-email?failed=invalidform');
exit;
}
if(!isset($_GET['email'])) {
@csymlstd
csymlstd / axios.refresh_token.js
Last active July 16, 2018 20:37 — forked from culttm/axios.refresh_token.js
axios interceptors for refresh token
axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
const originalRequest = error.config;
if (error.response.status === 401 && !originalRequest._retry) {
originalRequest._retry = true;
@csymlstd
csymlstd / location-finder-en-espanol.txt
Created May 1, 2018 20:54
Spanish translations for location finder
"Getting your current location" = Obteniendo tu ubicación actual
"Allow your browser to use geolocation when requested, or search above." = Permite que tu navegador habilite la geolocalización, o utiliza la función de búsqueda situada en la parte superior.
"Could not get your current location" = No pudimos obtener tu ubicación actual
"We couldn't find any locations near you" = No encontramos ubicaciones cercanas a ti
"Enable Geolocation in your browser or mobile device settings and try again, or search above" = Habilita la geolocalización en tu navegador o en la configuración de tu dispositivo móvil e intenta de nuevo, o utiliza la función de búsqueda situada en la parte superior.
@csymlstd
csymlstd / wp-get-current-queried-object.php
Created May 18, 2018 20:20
wp index.php - get current page id instead of first post
<?php
$post = get_queried_object();
$index_id = $post->ID;
?>
@csymlstd
csymlstd / fix-wordpress-permissions.sh
Created May 22, 2018 19:42 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory