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 / 0_reuse_code.js
Created March 4, 2014 00:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@robwent
robwent / k2commentexport.php
Last active August 29, 2015 14:19
Exports K2 comments to be imported into Disqus (Wordpress format)
<?php
// Turn off all error reporting
error_reporting(0);
/**
* Constant that is checked in included files to prevent direct access.
* define() is used in the installation folder rather than "const" to not error for PHP 5.2 and lower
*/
define('_JEXEC', 1);
@robwent
robwent / clean_wordpress_head.php
Last active October 21, 2022 02:38
A collection of snippets for a Wordpress theme's function.php file to clean up the output
<?php
/**
* Core output
**/
//Remove the generator tag
remove_action('wp_head', 'wp_generator');
//Remove the frontend admin bar while in development
@robwent
robwent / .less
Created April 3, 2016 19:34
referencing in less imports
@import (less) "pure/base.css";
@import (reference,less) 'pure/grids.css';
@import (reference,less) 'pure/grids-responsive.css';
@import (reference,less) 'pure/buttons.css';
@import (reference,less) 'pure/menus.css';
@import (reference,less) 'pure/forms.css';
@import (reference,less) 'pure/tables.css';
//@import 'theme/global.less';
@robwent
robwent / search-wp-posts.sql
Created April 6, 2016 21:16
Select Wordpress posts that contain a string in PhpMyAdmin
-- Change wp_ to your database prefix
-- Change domain.com to your domain
-- Change string to the text you want to search for
SELECT
ID as 'Post ID',
post_title as 'Title',
CONCAT('http://www.domain.com/',post_name) as 'URL'
FROM `wp_posts`
WHERE post_type = 'post'
@robwent
robwent / wordpress-custom-mime-types.php
Created April 6, 2016 21:52
Add custom mime types to Wordpress
//The following goes in a themes functions file or a custom hooks plugin
function custom_upload_mimes ( $existing_mimes ) {
$existing_mimes['epub'] = 'application/epub+zip';
$existing_mimes['mobi'] = 'application/x-mobipocket-ebook';
return $existing_mimes;
}
add_filter('upload_mimes', 'custom_upload_mimes');
@robwent
robwent / disqus-loaded.js
Created June 2, 2016 22:18
Checks if the joomlaworks disqus plugin is loaded on the page and triggers a window resize event when the content has loaded. For any template that uses an equal heights script where the comments show over the footer.
jQuery(document).ready(function(){
if(jQuery('.jwDisqusForm')){
var interval = setInterval(function() {
var disqusHeight = jQuery('#disqus_thread').height();
if ( disqusHeight > 52 ) { //The header is 52px high so any higher and the content is loaded
jQuery(window).trigger('resize');
clearInterval(interval);
}
}, 100);
}
@robwent
robwent / joomla-json-db-check.php
Last active December 3, 2016 15:42
Updates params and rules with invalid default json entries. This will not fix errors from extensions which add invalid parameters.
<?php
//Initiate Joomla so we can use it's functions
/**
* Constant that is checked in included files to prevent direct access.
* define() is used in the installation folder rather than "const" to not error for PHP 5.2 and lower
*/
define('_JEXEC', 1);
define( 'DS', DIRECTORY_SEPARATOR );
@robwent
robwent / wp-auto-featured-image.php
Last active April 9, 2017 20:19
Sets an image associated with a post as featured if nothing is set
@robwent
robwent / opentabs.html
Created February 18, 2017 01:16
Open a list of links in new browser tabs
<!doctype html>
<html>
<head>
<title>Open Tas</title>
<script>
function openWindow(){
var x = document.getElementById('a').value.split('\n');
for (var i = 0; i < x.length; i++)
if (x[i].indexOf('.') > 0)
if (x[i].indexOf('://') < 0)