Skip to content

Instantly share code, notes, and snippets.

View robwent's full-sized avatar
💭
Doing 'stuff'

Robert Went robwent

💭
Doing 'stuff'
View GitHub Profile
@robwent
robwent / isotope-filter-no-layout-hash.js
Created March 13, 2019 14:24
Filters list of items from select using url hash and no layout
jQuery(document).ready(function ($) {
Isotope.Item.prototype._create = function () {
// assign id, used for original-order sorting
this.id = this.layout.itemGUID++;
// transition objects
this._transn = {
ingProperties: {},
clean: {},
onEnd: {}
@robwent
robwent / check-upload-filename.php
Created March 17, 2019 16:29
Stops WordPress uploading images if the filename contains certain words.
<?php
/*
Plugin Name: Check Upload Filename
Plugin URI: https://www.robertwent.com/
Description: Prevents image uploads by filename
Version: 1.0
Author: Robert Went
*/
add_filter('wp_handle_upload_prefilter', 'check_for_lazy_people_uploads' );
@robwent
robwent / add-joomla-article-layout-as-class-to-body.php
Last active March 30, 2019 17:16
Adds Joomla article alternative layout information as a class to the body tag. Use in your templates index.php file.
<?php
$app = JFactory::getApplication();
$view = $app->input->getCmd( 'view', '' );
$body_class = '';
if ( $view === 'article' ) {
$article = JTable::getInstance( "content" );
@robwent
robwent / functions.php
Created April 17, 2019 19:16
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin” with Yoast v11
//Remove Yoast HTML Comments
//https://gist.github.com/robwent/f36e97fdd648a40775379a86bd97b332
function go_yoast() {
if (defined('WPSEO_VERSION')){
add_action('get_header',function (){ ob_start(function ($o){
return preg_replace('/\n?<.*?Yoast SEO plugin.*?>/mi','',$o); }); });
add_action('wp_head',function (){ ob_end_flush(); }, 999);
}
}
@robwent
robwent / Schema_Event.php
Last active April 23, 2023 19:14
Extends Yoast schema data to add events
<?php
use \Yoast\WP\SEO\Generators\Schema\Abstract_Schema_Piece;
class Schema_Event extends Abstract_Schema_Piece {
/**
* Determines whether or not a piece should be added to the graph.
*
* @return bool
@robwent
robwent / yoast-schema.php
Created April 24, 2019 21:28
Extends Yoast schema to add event data
<?php
include ("classes/Schema_Event.php");
add_filter( 'wpseo_schema_graph_pieces', 'PREFIX_add_graph_pieces', 11, 2 );
/**
* Adds Schema pieces to our output.
*
* @param array $pieces Graph pieces to output.
<wpml-config>
<admin-texts>
<key name="wp_2fa_email_settings">
<key name="enforced_email_subject"/>
<key name="enforced_email_body"/>
<key name="login_code_email_subject"/>
<key name="login_code_email_body"/>
<key name="user_account_locked_email_subject"/>
<key name="user_account_locked_email_body"/>
<key name="user_account_unlocked_email_subject"/>
<?php
/**
* Change min password strength.
*
* @author James Kemp (Iconic)
* @link http://iconicwp.com/decrease-strength-required-woocommerce-passwords/
* @param int $strength
* @return int
*/
function myclass_min_password_strength( $strength ) {
@robwent
robwent / wp-change-posts-to-projects.php
Created November 29, 2021 17:55
Changes WordPress Post labels to Projects
<?php
/**
* Change the label of posts
*/
function prefix_change_post_object() {
$get_post_type = get_post_type_object('post');
$labels = $get_post_type->labels;
$labels->name = 'Projects';
$labels->singular_name = 'Projects';
$labels->add_new = 'Add Projects';
@robwent
robwent / forcing-w3-total-cache-to-clear-parent-category-listing-pages-on-post-save.php
Last active May 13, 2024 13:26
Forcing W3 Total Cache to Clear Parent Category Listing Pages on Post Save
<?php
/**
* Clear Total Cache term listing pages for a post
* @param $post_id
* @param $post
*
* @return void
*/
function rw_clear_total_cache_terms_pages( $post_id, $post ) {
if ( function_exists( 'w3tc_flush_url' ) ) {