Skip to content

Instantly share code, notes, and snippets.

View pixelwatt's full-sized avatar
✏️
Documenting all the things

Rob Clark pixelwatt

✏️
Documenting all the things
View GitHub Profile
@pixelwatt
pixelwatt / .gitlab-ci.yml
Created May 2, 2021 10:11
GitLab CI Deployment Script for WPEngine
stages:
- deploy
deploy_production:
stage: deploy
image: tetraweb/php:7.1
when: manual
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
@pixelwatt
pixelwatt / style.css
Created October 21, 2020 19:05
CSS Overrides for IE 10+ and Pre-Chromium Edge
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
/* IE 10+ CSS Overides Here */
}
@supports (-ms-ime-align: auto) {
/* Pre-Chromium MS Edge Overides Here */
}
@pixelwatt
pixelwatt / wordpress-associated-post-sync.php
Last active February 18, 2020 21:47
Associate Wordpress Posts from Two Different Custom Post Types
<?php
// For the custom post type 'communities', a custom option exists to allow editors to select 'plans' (from another custom post type) that are associated with the community post. Depending on data being displayed on the frontend, storing this data with 'plans' can potentially eliminate expensive database queries from being neccessary, especially in reguards to AJAX search. The function below syncs data with associated 'plan' posts once a community is saved or updated. This does not take into account certain scenarios, such as plans being trashed or restored. Ideally, you'd take those into account and also add a cleanup task to wp_cron to occasionally unset and rebuild the associations.
function sync_community_data( $id, $post ) {
if ( ( 'communities' == $post->post_type ) && ( $id ) ) {
$associated = get_post_meta( $id, 'plans', true );
$associated = ( is_array( $associated ) ? $associated : array() );
// First, find plans currently tied to the community, and remove the community ID if the plan
@pixelwatt
pixelwatt / functions.php
Last active November 9, 2021 22:06
Exclude past events from Modern Tribe's Events Calendar plugin when rebuilding Relevanssi's search index
add_filter('relevanssi_do_not_index', 'mytheme_noindex_old_events', 10, 2);
function mytheme_noindex_old_events($block, $post_id) {
$events_to_exclude;
$result = wp_cache_get( 'old_events' );
if ( false === $result ) {
$events = tribe_get_events( array(
'start_date' => date( 'Y-m-d H:i:s', strtotime( '-5 years' ) ),
'end_date' => date( 'Y-m-d H:i:s', strtotime( '-1 day' ) ),
'eventDisplay' => 'custom',
'posts_per_page' => 99999
@pixelwatt
pixelwatt / use_wp_oembed.php
Last active June 2, 2017 20:01
Use the built-in Wordpress oEmbed class to get a full object back instead of just the embed code
<?php
/**
* Import the Wordpress oEmbed class into a function in functions.php to retreive a full object instead of just the source code
* @author Rob Clark
*
*
* What's returned: (May vary by API)
*
* $embed_data->author_url
* $embed_data->author_name
@pixelwatt
pixelwatt / cmb2_metabox_include_default_page.php
Last active June 2, 2017 08:27
CMB2 show_on Filter for Default Page Template
<?php
/**
* Include metabox only on the default page template (page.php). Heavily based of Ed Townend's front-page solution
* @author Rob Clark
*
* @param bool $display
* @param array $meta_box
* @return bool display metabox
*/
function cmb2_metabox_include_default_page( $display, $meta_box ) {