Skip to content

Instantly share code, notes, and snippets.

View mattonomics's full-sized avatar

Matt Gross mattonomics

  • Bonsai.io (OMC)
  • Lexington, KY
View GitHub Profile
function adjust_caption() {
var captions = document.getElementsByClassName('wp-caption');
for (var i = 0; i < captions.length; i++) {
// set wrap to auto
captions[i].style.width = 'auto';
// will set the width of the p to the same as the image. comment out if you don't want/need
captions[i].getElementsByTagName('p')[0].style.width = captions[i].getElementsByTagName('img')[0].width + 'px';
}
}
@mattonomics
mattonomics / prying-eyes.php
Last active December 12, 2015 12:39
This will make sure that only logged in users can view ANY content on the site. Drop it at the tip top of your functions.php file.
<?php
// fancy PHP 5.3+ style
add_action( 'template_redirect', function() {
if ( ! is_user_logged_in() ) {
wp_redirect( wp_login_url() );
exit;
}
} );
<?php
// add filter to allow for new weekly schedule
add_filter( 'cron_schedules', 'rkv_weekly_cron' );
function rkv_weekly_cron( $schedules ) {
// Adds once weekly to the existing schedules.
$schedules['weekly'] = array(
'interval' => 604800,
'display' => __( 'Once Weekly' )
);
<?php
function get_api_key($key) {
global $API_Key_Manager;
return $API_Ket_Manager->get_key($key);
}
<?php
class super_kewl {
// can be public or no visibility declaration (which defaults to public)
public function matt($param = false) {
echo $param ? esc_attr($param) : 'Hello!';
}
}
// will output Hello
@mattonomics
mattonomics / gist:4079235
Created November 15, 2012 15:38
New html method parameter
<?php
/*
Name: Box Name
Author: Author Name
Description: A good description of this box
Version: Box version
Class: box_class_with_underscore
*/
class box_class_with_underscore extends thesis_box {
@mattonomics
mattonomics / gist:3936783
Created October 23, 2012 05:01
P2 Theme Mods
<?php
// find out if they're logged in and send them to the login form if not
add_action('template_redirect', 'deny_phonies');
function deny_phonies() {
if (!is_user_logged_in() && $GLOBALS['pagenow'] !== 'wp-login.php') {
wp_redirect(get_site_url($GLOBALS['blog_id'], 'wp-login.php'));
exit;
}
}
@mattonomics
mattonomics / gist:3912424
Created October 18, 2012 15:04
Add CSS to Thesis via the CSS filter
<?php
// add css using the thesis_css filter
class your_skin_class extends thesis_skin {
function construct() {
add_filter('thesis_css', array($this, 'add_css'));
}
@mattonomics
mattonomics / skin-sample.php
Created October 9, 2012 21:38
Adding a skin specific box to the boxes queue
<?php
class example_skin_class extends thesis_skin {
// list of box classes you want to add to the queue
// do not give these strings for keys or everything will blow up
public $boxes_class_list = array(
'box_class_one',
'box_class_two',
'box_class_three',
'box_class_four',
@mattonomics
mattonomics / pwnership.php
Created October 7, 2012 22:50
Check a few ownership deets
<?php
echo "get_current_user: " . (function_exists('get_current_user') ? get_current_user() : 'get_current_user() does not exist');
echo "<br>";
echo "getmyuid: " . (function_exists('getmyuid') ? getmyuid() : 'getmyuid() does not exist');
echo "<br>";
echo "fileowner(seed.php): " . (function_exists('fileowner') ? fileowner(dirname(__FILE__) . '/seed.php') : 'fileowner() does not exist');
echo "<br>";
echo "fileowner(". basename(__FILE__) ."): " . (function_exists('fileowner') ? fileowner(__FILE__) : 'fileowner() does not exist');
echo "<br>";