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 / corg.php
Created March 18, 2013 16:46
Code organization
// sth above
<?php if ( $related_posts->have_posts() ): ?>
<h3> Related Posts</h3>
<ul>
<?php while ( $related_posts->have_posts() ): $related_posts->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
@gicolek
gicolek / blah.php
Created February 6, 2013 16:47
Handle ajax requests (omitting admin-ajax.php)
<?php
function _foo_handle_ajax_request_for_db_data() {
$path = parse_url (site_url());
if ( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) === $path['path'] . '/sth' ) {
status_header(200);
// do sth
exit ;
@gicolek
gicolek / gf-ldtable.php
Last active September 2, 2017 16:31
Gravity Forms modify lead detail table
<?php
function update() {
global $wpdb;
// get the lead detail table name
$lead_details_table_name = RGFormsModel::get_lead_details_table_name();
// as stored in the $lead_details_table_name * 10
@gicolek
gicolek / gf.php
Created January 14, 2013 12:11
Gravity Form filters
<?php
static function _modify_gravity_form_lead_detail_table($cat_id) {
global $wpdb;
$lead_details_table_name = RGFormsModel::get_lead_details_table_name();
// get new category name
$new_name = $_POST['name'];
// get db category name
@gicolek
gicolek / TinyMCE filter - add buttons
Created January 14, 2013 08:09
TinyMCE filter adding buttons
<?php
/**
* Filter TinyMCE styleselect dropdown
*
* @link http://codex.wordpress.org/TinyMCE_Custom_Styles
* @param array $init_array
* @return type
* @hook tiny_mce_before_init
*/
function wp_light_mce_before_init_insert_formats($init_array) {
@gicolek
gicolek / tinymce.php
Last active December 11, 2015 02:08
tinymce.
<?php
// alter tinymce body classes
function mss_tiny_mce_before_init($init_array) {
// accessing global variable post
global $post;
$title = strtolower ($post->post_title);
if($title=='home'){
$init_array['body_class'] = $post->post_title;
}
@gicolek
gicolek / artur.js
Created January 7, 2013 18:35
Arturos
<script>
{"st_editor":"Score - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.","ALL":600,"AL":"600","AK":"600","AZ":"600","AR":"600","CA":"600","CO":"600","CT":"600","DE":"600","DC":"600","FL":"600","GA":"600","HI":"600","ID":"600","IL":"600","IN":"600","IA":"600","KS":"600","KY":"600","LA":"600","ME":"600","MD":"600","MA":"600","MI":"600","MN":"600","MS":"600","MO":"600","MT":"600","NE":"600","NV":"600","NH":"600","NJ":"600","NM":"600","NY":"600","NC":"600","ND":"600","OH":"600","OK":"600","OR":"600","PA":"600","RI":"600","SC":"600","SD":"600","TN":"600","TX":"600","UT":"600","VT":"600","VA":"600","WA":"600","WV":
<?php
/**
* Template name: Dla Arturq <3
*/
get_header() ?>
<?php the_post() ?>
<?php wpized_load_partial('breadcrumbs') ?>
@gicolek
gicolek / meta-box-sample.php
Last active December 11, 2019 01:41
Sample Meta Box
<?php
/* 1. Back End Usage
---------------------------------------------------------------------*/
// add neccessary actions
// @see http://codex.wordpress.org/Function_Reference/add_action
add_action( 'add_meta_boxes', 'rg_add_custom_box' );
add_action( 'save_post', 'rg_save_postdata', 10, 1 );
@gicolek
gicolek / the_time.php
Created December 13, 2012 14:04
the_time() usage example
<?php
// bah
?>
<a href="#" title="<?php the_time('h:i a'); ?>" rel="bookmark">
<time class="entry-date" datetime="<?php the_time('c'); ?>"><?php the_time( 'jS F Y' ); ?></time>
</a>