Skip to content

Instantly share code, notes, and snippets.

Avatar

Curtiss Grymala cgrymala

  • Ten-321 Enterprises
View GitHub Profile
@cgrymala
cgrymala / add-rand-orderby-to-rest.php
Created Nov 22, 2018
Allows you to use `rand` as an `orderby` parameter when querying a custom post type through the WordPress REST API
View add-rand-orderby-to-rest.php
<?php
class Add_Rand_to_OrderBy {
public function __construct() {
add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
}
/**
* Set up any custom REST API handlers
*
* @access public
@cgrymala
cgrymala / inheritance.php
Created Feb 8, 2018
Showing how PHP handles inheritance
View inheritance.php
<?php
class A {
function __construct() {
$this->sample_method();
}
private function sample_method() {
echo "<p>I am inside the parent class 'A'</p>";
}
}
View keybase.md

Keybase proof

I hereby claim:

  • I am cgrymala on github.
  • I am cgrymala (https://keybase.io/cgrymala) on keybase.
  • I have a public key whose fingerprint is 3B6A D380 4C78 7EF0 F88B FB54 7726 1A30 1ED3 F998

To claim this, I am signing this object:

@cgrymala
cgrymala / adjust-wp-admin-menu.php
Created May 18, 2016
Modifies WordPress Admin Menu to adjust cap used for specific menu
View adjust-wp-admin-menu.php
add_action( 'admin_menu', 'adjust_admin_menu', 11 );
function adjust_admin_menu() {
$test_slug = 'my-menu-slug';
$new_cap = 'edit_posts';
global $menu;
foreach ( $menu as $k=>$v ) {
if ( $test_slug == $v[2] ) {
$menu[$k][1] = $new_cap;
@cgrymala
cgrymala / pcs-sample-views-content-template.html
Created Jan 8, 2016
Example of PCS usage of custom Views Content Template
View pcs-sample-views-content-template.html
<article class="[pcs-entry-classes classes='pcs-entry one-fourth' columns=4]">
<header>
<figure class="pcs-featured-image">
[pcs-thumbnail]
</figure>
<h1 class="pcs-post-title">
<a href="[pcs-post-url]">[wpv-post-title]</a>
</h1>
</header>
<footer>
@cgrymala
cgrymala / umw-timely-customizer.html
Last active Dec 11, 2015
Implements the custom header/footer on UMW's Time.ly calendar
View umw-timely-customizer.html
<!-- Custom Head Code -->
<link rel='stylesheet' id='genericons-css' href='//www.umw.edu/wp-content/plugins/jetpack/_inc/genericons/genericons/genericons.css?ver=3.1' type='text/css' media='all' />
<link rel='stylesheet' id='umw-fonts-css' href='//www.umw.edu/wp-content/plugins/umw-fonts/fonts.css?ver=0.2' type='text/css' media='all' />
<link rel='stylesheet' id='umw-online-tools-font-css' href='//www.umw.edu/wp-content/plugins/online-tools/images/icons/svg-online-tools/icon-font/style.css?ver=0.5.2' type='text/css' media='all' />
<link rel='stylesheet' id='umw-online-tools-css' href='//www.umw.edu/wp-content/plugins/online-tools/styles/umw-online-tools.css?ver=0.5.2' type='text/css' media='all' />
<link rel='stylesheet' id='outreach-pro-css' href='//www.umw.edu/wp-content/mu-plugins/styles/outreach-pro.css?ver=1.0.20' type='text/css' media='all' />
<link rel='stylesheet' id='umw-outreach-mods-css' href='//www.umw.edu/wp-content/mu-plugins/styles/umw-outreach-mods.css?ver=1.0.20' type='text/css' media='
@cgrymala
cgrymala / views-custom-feed-sample.php
Last active Jun 23, 2019
Shows an example of the functions used to remove Views wrapper HTML
View views-custom-feed-sample.php
<?php
/**
* Override the extra HTML that Views uses to wrap its output
*/
remove_shortcode( 'wpv-layout-start' );
remove_shortcode( 'wpv-layout-end' );
add_shortcode( 'wpv-layout-start', array( $this, '__blank' ) );
add_shortcode( 'wpv-layout-end', array( $this, '__blank' ) );
@cgrymala
cgrymala / analytics-head.js
Created Nov 6, 2015
Standard call for Google Analytics
View analytics-head.js
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-[your-analytics-id]-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
@cgrymala
cgrymala / gf-a11y-sample-complex-fields.html
Created Sep 4, 2015
Proposed re-structuring of Gravity Forms complex fields for a11y
View gf-a11y-sample-complex-fields.html
<ul>
<!-- Original First Name/Last Name Complex Field -->
<li id="field_6_13" class="gfield field_sublabel_below field_description_above">
<label class="gfield_label" for="input_6_13_3">Name</label>
<div class="ginput_complex ginput_container no_prefix has_first_name no_middle_name has_last_name no_suffix" id="input_6_13">
<span id="input_6_13_3_container" class="name_first">
<input type="text" name="input_13.3" id="input_6_13_3" value="" aria-label="First name" vk_1cc20="subscribed" data-cip-id="input_6_13_3">
<label for="input_6_13_3">First</label>
</span>
<span id="input_6_13_6_container" class="name_last">
@cgrymala
cgrymala / customizer-custom-image-sizes.php
Created Sep 4, 2015
Pulls Resized Images From Customizer Settings in WordPress
View customizer-custom-image-sizes.php
<?php
if ( ! class_exists( 'My_Customizer_Theme_Mods' ) ) {
class My_Customizer_Theme {
var $version = '0.1';
function __construct() {
/**
* We have two basic sizes of images used from the images set in the Customizer
* One of them is full-width of the browser, so let's make it large, but not unlimited
* The other is a 125x125 icon, but, just in case it needs to be a bit larger on mobile or
You can’t perform that action at this time.