Skip to content

Instantly share code, notes, and snippets.

View interactiveRob's full-sized avatar

Rob Kirkner interactiveRob

View GitHub Profile
@interactiveRob
interactiveRob / register-taxonomy.php
Last active March 31, 2021 13:56
Wordpress register custom taxonomy
<?php
add_action( 'init', 'steam_register_custom_taxonomy_effect');
/**
* Register Custom Taxonomy
*
* @return void
*/
function steam_register_custom_taxonomy_effect()
@interactiveRob
interactiveRob / search.php
Last active February 9, 2021 19:34 — forked from galengidman/search.php
WordPress search form & results for custom post type
<?php
// check to see if there is a post type in the URL
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] ):
$filtered_posts = new WP_Query( array(
'post_type' => $_GET['post_type'],
'posts_per_page' => 12,
'orderby' => 'post_date',
's' => $_GET['s'],
));
@interactiveRob
interactiveRob / wp-on-save-post.php
Last active November 20, 2023 14:12
Wordpress run function when post is saved
<?php
add_action('save_post', function($post_id, $post, $update){
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {// ignore autosave
return;
}
if (!$update) { // ignore Add New post
return;
}
@interactiveRob
interactiveRob / DismissCookie.js
Last active January 29, 2021 17:47
Simple ES6 javascript class to set a cookie that expires after [x] number of days
export default class DismissCookie {
constructor() {
this.cookieName = 'ceg-banner-ad-dismissed';
this.cookie = {
url: this.getDomain(),
expirationDate: this.getExpiration(14),
name: this.cookieName,
value: true,
};
@interactiveRob
interactiveRob / pardot-askerisks.css
Created December 3, 2020 17:00
Pardot add asterisks to required form fields
form.form .required > label:nth-child(1):after {
content: ' *';
color: #ffffff;
font-size: 12px;
}
@interactiveRob
interactiveRob / admin-add-template-class.php
Last active November 24, 2020 14:09
Add Post/Page template to WP Admin area body class
<?php
add_filter('admin_body_class', function ($classes) {
global $post;
$post_type = get_post_type($post->id);
$template_slug = str_replace('.php', '', get_page_template_slug($post->ID));
$template_class = "$post_type-template-$template_slug";
return "$classes $template_class";
});
@interactiveRob
interactiveRob / wordpress-override-instructions.md
Last active October 23, 2020 18:57
Wordpress instructions, how to search and override plugin templates
  1. Inspect the page and look for some really specific CSS class
  2. Use your editor to search all files inside wp-content/plugins/the-events-calendar/src/views for the class
  3. Find the file you want to change
  4. Clone the file and folder structure into your override directory wp-content/themes/westernmarketfull/tribe-events
  5. Make your edits in the cloned file
@interactiveRob
interactiveRob / align_print_login_example
Created October 14, 2020 20:51
print_login function example with should_hide_login() call
<?php
function print_login() {
echo '<div id="login">';
echo '<div class="login-wrapper">';
echo '<div class="label">Login</div>';
echo '<div class="login-container">';
echo '<div id="close"><i class="fa fa-close"></i> Close</div>';
if (should_hide_login()) {
echo '<p class="timesheet-unavailable-msg">We apologize for the inconvenience, but the Self Service portal is closed as this time. Access will resume at 6:00pm EST.</p>';
} else {
@interactiveRob
interactiveRob / max-upload-size.ini
Created September 29, 2020 20:11
PHP Wordpress Max Upload size trick
# create a file called ".user.ini" in the site root
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 64M
max_execution_time = 300
@interactiveRob
interactiveRob / CF7-get-submission-data.php
Created July 30, 2020 18:06
CF7-get-submission-data
<?php
/**
* The file that defines the core plugin class
*
* A class definition that includes attributes and functions used across both the
* public-facing side of the site and the admin area.
*
* @link interactiverob.com
* @since 1.0.0