Skip to content

Instantly share code, notes, and snippets.

@cgrymala
cgrymala / sample-tables.md
Created February 19, 2024 22:12
Sample GitHub Markdown Table
@cgrymala
cgrymala / bad-link.html
Created December 9, 2020 19:01
Bad Link
@cgrymala
cgrymala / add-rand-orderby-to-rest.php
Created November 22, 2018 15:15
Allows you to use `rand` as an `orderby` parameter when querying a custom post type through the WordPress REST API
<?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 February 8, 2018 13:32
Showing how PHP handles inheritance
<?php
class A {
function __construct() {
$this->sample_method();
}
private function sample_method() {
echo "<p>I am inside the parent class 'A'</p>";
}
}

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 16:40
Modifies WordPress Admin Menu to adjust cap used for specific menu
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 January 8, 2016 16:38
Example of PCS usage of custom Views Content Template
<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 December 11, 2015 20:48
Implements the custom header/footer on UMW's Time.ly calendar
<!-- 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 June 23, 2019 06:02
Shows an example of the functions used to remove Views wrapper HTML
<?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 November 6, 2015 17:49
Standard call for Google Analytics
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);