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 / gf_input.php
Last active November 12, 2021 06:37
Gravity Forms overwrite the input
<?php
add_filter( 'gform_field_input', 'gf_field_input', 10, 5 );
function gf_field_input($input, $field, $value, $lead_id, $form_id) {
// we don't want to change the admin look behavior of the form field
if ( IS_ADMIN )
return $input;
// lets create custom form html in case it had the css class assigned
@gicolek
gicolek / shit.css
Created November 27, 2013 17:39
shit.css
* {
color: blue;
}
@gicolek
gicolek / add-to-cart.php
Created November 23, 2013 21:33
Woo Commerce loop add to cart
<?php
/**
* Loop Add to Cart
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@gicolek
gicolek / prefix-woo-ajax.js
Created November 23, 2013 21:03
JavaScript handler for custom WooCommerce ajax cart data.
$('body').on('adding_to_cart', function(event, param1, param2) {
// pick the data from somewhere and define extra product_data parameter
// event and param1 parameteres serve no need in that case
param2.logo_text = 'My great logo!';
});
@gicolek
gicolek / prefix-woo-ajax.php
Created November 23, 2013 20:57
Woo Commerce custom add to cart ajax handler
<?php
add_action( 'woocommerce_ajax_added_to_cart', 'ac_add_product_custom_field' );
/**
*
* @hook woocommerce_ajax_added_to_cart
*/
function ac_add_product_custom_field($product_id) {
@gicolek
gicolek / gtps.php
Created November 6, 2013 14:32
Get post id from shortcode
<?php
add_shortcode( 'table', 'ssl_table_shortcode' );
/**
* Render ACF table shortcode given several parameters
*/
function ssl_table_shortcode($atts) {
global $post;
// extract the necessary attributes
@gicolek
gicolek / fancy.js
Created April 29, 2013 18:46
Powelek
(function($) {
"use strict";
var Site = {
basePrice: 0, //$('.ginput_amount').val(),
gfield_original_title: "",
gformId: 22,
init: function() {
Site.selectChangeEvents();
@gicolek
gicolek / paginacja.php
Created April 15, 2013 12:36
paginacj
<?php
/**
* Generate the navigation for blog listing pages
*
* @global obj $wp_query
*/
function bg_page_navi($query = null, $paged = null) {
?>
<ul class="page-navi">
<?php
@gicolek
gicolek / ajax-form-wp.php
Created March 21, 2013 12:56
Sample Ajax Form WP
<?php
/**
* Validate data and send mail.
*
* @see http://codex.wordpress.org/Function_Reference/wp_mail
* @return {int} Status of message:
* -2 => Invalid data
* -1 => Failed to send
* 1 => OK
@gicolek
gicolek / bcwpsc.php
Created March 18, 2013 17:02
How not to code WP shortcodes
<?php
$output = '';
if ( $related_posts->have_posts() ){
$out .= '<h3> Related Posts</h3>';
$out .= '<ul>';
while ( $related_posts->have_posts() ){
$related_posts->the_post();
$out .= '<li><a href="'.the_permalink().'">'.get_the_title().'</a></li>';