Skip to content

Instantly share code, notes, and snippets.

@mirzap
mirzap / functions.php
Created September 20, 2012 18:20 — forked from jubalm/functions.php
Useful Wordpress Functions
<?php
// Useful Shortcodes
add_shortcode('home_url', 'return_home_url');
add_filter('widget_text', 'do_shortcode'); // enable shortcodes on widgets
function return_home_url() {
return home_url();
}
add_shortcode('theme_url', 'return_theme_url');
function return_theme_url() {
@mirzap
mirzap / Get thumbnail src
Created September 20, 2012 18:22 — forked from paulgosnell/Get thumbnail src
commonly used snippets of WP code
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<div class="bgImg" style="background:url(<?php echo $image[0]; ?>) no-repeat 50% 50%;"></div>
<?php endif; ?>
@mirzap
mirzap / foundation-menu.php
Created November 9, 2012 14:32 — forked from awshout/foundation4-topbar-menu.php
WordPress Walker for ZURB's Foundation Top Bar
add_theme_support('menus');
/*
http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
*/
register_nav_menus(array(
'top-bar-l' => 'Left Top Bar', // registers the menu in the WordPress admin menu editor
'top-bar-r' => 'Right Top Bar'
));
@mirzap
mirzap / gist:4051438
Created November 10, 2012 15:48 — forked from CodeNegar/gist:4030888
PHP: Wordpress last blog update jdate
<?php
function last_update() {
global $wpdb;
$date = $wpdb->get_var("SELECT DISTINCT post_date FROM $wpdb->posts WHERE post_date < '".current_time('mysql')."' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
return jdate('l d M Y', strtotime($date));
}
?>
@mirzap
mirzap / auth.php
Created January 20, 2013 20:15 — forked from mwesten/auth.php
<?php
class Auth_Controller extends Base_Controller {
public $restful = true;
public function __construct() {
$this->filter( 'before', 'guest' )->except( array( 'logout', 'validate' ) );
// Note: We may not always require CSRF on login for system based logins so ignore it here.
$this->filter( 'before', 'csrf' )->on( 'post' )->except( array( 'login' ) );
}

There's no shortage of good resources for learning laravel. So instead of the usual introductory tutorial were just gonna learn Laravel by building a project from scratch and that's gonna be a User Management System.

I don't know if my definition of a User Management System is correct but here's my idea of what's it's capable of doing:

  • Register Roles
  • Register Users
  • Update Users
<?php
// Resizer and Image Manipulation
// Based on: http://forums.laravel.com/viewtopic.php?id=2648
public function post_edit_logo($id)
{
$rules = array(
'image' => 'image',
);
<?php
// Resizer and Image Manipulation
// Based on: http://forums.laravel.com/viewtopic.php?id=2648
public function post_edit_logo($id)
{
$rules = array(
'image' => 'image',
);
<?php
/**
* TestClass
*
* This is just a test class for the Annotated\ReflectionClass
* to use.
*
* Foo::bar();
*
@mirzap
mirzap / rc4.js
Created March 11, 2013 21:42 — forked from farhadi/rc4.js
/*
* RC4 symmetric cipher encryption/decryption
*
* @license Public Domain
* @param string key - secret key for encryption/decryption
* @param string str - string to be encrypted/decrypted
* @return string
*/
function rc4(key, str) {
var s = [], j = 0, x, res = '';