Skip to content

Instantly share code, notes, and snippets.

View jentanbernardus's full-sized avatar
:shipit:
Coding everyday keeps the doctor away!

Jentan Bernardus jentanbernardus

:shipit:
Coding everyday keeps the doctor away!
View GitHub Profile
// ==UserScript==
// @name Harvest Timer Growl Reminder
// @namespace http://harvestapp.com
// @description Displays Growl notifications at a user defined interval, reminding you to track your time.
// @include *
// @author Mike Green
// @version 0.1.1
// ==/UserScript==
(function () {
@jentanbernardus
jentanbernardus / functions.php
Created October 12, 2013 15:50
WordPress: Change the author slug, URL base
add_action('init', 'kp_author_base');
function kp_author_base() {
global $wp_rewrite;
$author_slug = 'profile'; // change slug name
$wp_rewrite->author_base = $author_slug;
}
@jentanbernardus
jentanbernardus / function.php
Created October 12, 2013 15:31
Post is older than: Adding this first block of code to your functions.php will allow you to check the age of a post to see if it is older than a set number of days. Great if you want to display some some information related to the post after set number of days or even stop displaying the post altogether.
function is_old_post($days = 5) {
$days = (int) $days;
$offset = $days*60*60*24;
if ( get_post_time() < date('U') - $offset )
return true;
return false;
}
<div class="author-box">
<div class="author-pic"><?php echo get_avatar( get_the_author_email(), '80' ); ?></div>
<div class="author-name"><?php the_author_meta( "display_name" ); ?></div>
<div class="author-bio"><?php the_author_meta( "user_description" ); ?></div>
</div>
<?php
$author_posts = new WP_Query( array(
'posts_per_page' => 3,
'author' => get_the_author_meta( 'ID' )
) );
if ( $author_posts->have_posts() ) while ( $author_posts->have_posts() ) : $author_posts->the_post();
// loop
endwhile;
wp_reset_query();
@jentanbernardus
jentanbernardus / functions.php
Created August 4, 2013 02:57
WordPress Functions: Show error message in dashboard
function showMessage($message, $errormsg = false)
{
if ($errormsg) {
echo '
<div id="message" class="error">';
}
else {
echo '
<div id="message" class="updated fade">';
}
<?php
/**
* Enqueue scripts and styles
*/
function load_scripts() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' );
$dir = get_stylesheet_directory_uri();
wp_enqueue_script( 'jquery-masonry', $dir.'/js/jquery.masonry.min.js', array('jquery'), false, true );
@jentanbernardus
jentanbernardus / README.md
Created August 1, 2013 05:27
Unzip an uploaded file using php

Unzip an uploaded file using php


If you dont have shell access to your server and need to unzip a file on your php server you can use this script. It basically extracts the zip file into the directory you specify. Make sure the directory you want to extract it to has write permissions.

@jentanbernardus
jentanbernardus / snippet.php
Last active January 6, 2023 14:18
WordPress: Disable new user and password change notification
<?php
if ( !function_exists('wp_new_user_notification') ) {
function wp_new_user_notification( ) {}
}
if ( !function_exists( 'wp_password_change_notification' ) ) {
function wp_password_change_notification() {}
@jentanbernardus
jentanbernardus / functions.php
Created July 16, 2013 13:44
WordPress: Changing default wordpres email settings
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from($old) {
return 'your email address';
}
function new_mail_from_name($old) {
return 'your name or your website';
}