Skip to content

Instantly share code, notes, and snippets.

View ryanemitchell's full-sized avatar
🤘

Ryan E. Mitchell ryanemitchell

🤘
View GitHub Profile
@ryanemitchell
ryanemitchell / blade.xml
Created December 14, 2022 23:03
Sage Blade Directives for PHPStorm - place in projects .idea folder and restart the IDE
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BladeInjectionConfiguration" default="false">
<directives>
<!-- Sage Directives - WordPress - https://log1x.github.io/sage-directives-docs/usage/wordpress.html-->
<data directive="@query" injection="true" prefix="(" suffix=")"/>
<data directive="@posts" injection="true" prefix="(" suffix=")"/>
<data directive="@hasposts" injection="true" prefix="(" suffix=")"/>
<data directive="@noposts" injection="true" prefix="(" suffix=")"/>
<data directive="@titl"/>
@ryanemitchell
ryanemitchell / 3d-slider-converting-to-rmmposts.markdown
Created August 16, 2019 19:18
3d Slider converting to rmmPosts
@ryanemitchell
ryanemitchell / frontend_context.php
Last active March 6, 2019 17:29
For detecting if a the PHP used in a ServerSideRender component is loaded in the frontend or in the editor. Checks the URL serving the file for block-renderer that only appears when loaded in the editor. Useful for conditional display of elements in the php when components are used for these elements in the editor.
function is_frontend_context() {
// Check if page is being loaded in the editor by checking URL structure of the ServerSideRender source for block-renderer
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (strpos($url,'block-renderer') !== false) {
// In wp-admin
return false;
} else {
// front end
window.onload = function() {
if (window.jQuery) {
// jQuery is loaded
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
}
<select name="age.birth_year" required="" data-validate="{&quot;required&quot;:true}"><option value="">YYYY</option><optgroup label="2010s"><option value="2017">2017</option><option value="2016">2016</option><option value="2015">2015</option><option value="2014">2014</option><option value="2013">2013</option><option value="2012">2012</option><option value="2011">2011</option><option value="2010">2010</option></optgroup><optgroup label="2000s"><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option></optgroup><optgroup label="1990s"><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</optio
@ryanemitchell
ryanemitchell / emergency.php
Last active October 5, 2017 20:13
https://codex.wordpress.org/User:MichaelH/Orphaned_Plugins_needing_Adoption/Emergency Warnings Requires you know the administrator username. It updates the administrator password and sends an email to the administrator's email address. If you don't receive the email, the password is still changed. You do not need to be logged in to use it. If yo…
<?php
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
<?php
/*
Template Name: My Awesome Custom Page
*/
browser-sync start --server --files "**/**"
@ryanemitchell
ryanemitchell / between-times.js
Last active September 27, 2017 20:48
Get current hout and minutes and output based on 2 times (open and closed) Use moment.js when need more functionaality than this.
var d = new Date();
var hr = d.getHours();
var min = d.getMinutes();
// combine hours and minutes and convert string to number
var currenttime = parseFloat(""+ hr+min);
//set open and close times
var opentime = 830;
var closetime = 2044;