Skip to content

Instantly share code, notes, and snippets.

View gicolek's full-sized avatar

Rafał Gicgier - Certified Codeable Expert Developer gicolek

View GitHub Profile
@gicolek
gicolek / test.php
Created September 13, 2012 14:37
Json Callback
// inside the .php file
{
//$mail = $_POST['mail'];
$date = $_POST['date'];
$success = true;
$response = json_encode(
array( 'success' => $success,
'mail' => 'mail',
'message' => 'test',
'date' => $date
@gicolek
gicolek / kupa.php
Created September 16, 2012 21:15
Sample Code
<?php
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
/* geoip.inc
*
* Copyright (C) 2007 MaxMind LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@gicolek
gicolek / walker.php
Created October 9, 2012 11:27
Menu Walker with Parent Marking
class Walker_Header extends Walker_Nav_Menu {
/**
* @see Walker::$tree_type
* @since 3.0.0
* @var string
*/
var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
/**
@gicolek
gicolek / settings.php
Created October 9, 2012 14:51
Faciilitate creation of settings page.
<?php
/**
* This class facilitates creation of settings field to the theme options
* through, default pre-made boxes
*
* @todo example usage
*
* @author Rafal Gicgier <gicolek@gmail.com>
*/
@gicolek
gicolek / gist:3859316
Created October 9, 2012 14:51
Usage of examples of Settings class
require_once STYLESHEETPATH . '/skeleton/settings.class';
if ( class_exists( 'Skeleton_Settings' ) ) {
$args = array(
'opt1' => array(
'type' => 'text',
'name' => 'input-text-1',
'desc' => 'Input type text test',
),
@gicolek
gicolek / pagination.php
Created October 9, 2012 16:48
Pagination
<div class="pagination">
<ul class="page-numbers">
<li><span class="page-numbers current">1</span></li>
<li><a class="page-numbers" href="http://localhost/junelabs/WP/blog/page/2/">2</a></li>
<li><a class="page-numbers" href="http://localhost/junelabs/WP/blog/page/3/">3</a></li>
<li><a class="next page-numbers" href="http://localhost/junelabs/WP/blog/page/2/">▶</a></li>
</ul>
</div>
@gicolek
gicolek / posts.class.php
Created October 10, 2012 10:57
Facilitate creation of post types
<?php
/**
* This class facilitates creation of custom post types
* @author Rafal Gicgier <gicolek@gmail.com>
*/
class Skeleton_Posts {
private $posts = array( );
@gicolek
gicolek / posts-init.php
Created October 11, 2012 19:14
Custom Posts initialization
require_once STYLESHEETPATH . '/skeleton/posts.class';
if ( class_exists( 'Skeleton_Posts' ) ) {
$args = array(
'post1' => array(
'name' => 'Slider',
'labels' => array(
'singular' => 'Slider',
'plural' => 'Slider entries',
),
@gicolek
gicolek / wp_q_pagination.php
Created October 11, 2012 23:16
Pagination eith WP_QUERY
<?php
/**
* Generates the user pagination for custom and default queries
*
* @global object $wp_query
* @param object $query used within a custom loop
*/
function skeleton_pagination($query = null) {
if ( !$query ) {
@gicolek
gicolek / cpt_f_img.php
Created October 31, 2012 23:00
Custom Post Type Featured Images
// w functions.php
// upewniamy się, że szablon pozwala na featured image
add_theme_support( 'post-thumbnails' );
// dodajemy automatycznie cięty obrazek o rozmiaracah 209 na 203 o nazwie thumb-course
add_image_size( 'thumb-course', 209, 203, true );
// dodajemy posty podczas jednej z pierwszych akcji WordPressa
add_action( 'init', 'raf_cpt_init' );