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 / ls.php
Created July 28, 2014 09:09
LikeSaveIt
<?php
require_once(__DIR__ . '/includes/class-like-saveit-db.php');
require_once(__DIR__ . '/includes/class-session-db.php');
/**
* Plugin Name.
*
* @package Plugin_Name
* @author Your Name <[email protected]>
* @license GPL-2.0+
* @link http://example.com
@gicolek
gicolek / db_session.php
Created July 28, 2014 09:08
DB Session Storage
<?php
/**
* Simple Class which overwrites the session storage
*/
class Like_Saveit_Session_Handler {
/**
* Store the db
* @var object
@gicolek
gicolek / trigger_view.php
Created April 22, 2014 12:13
Trigger View
<script>
function trigger_view(id) {
jQuery.post(
<?php echo json_encode( 'some_url' ) ?>,
{
// a post id, fetched before
"cp_post_id": id,
// wordpress nonce for safety reason
"nonce": '<?php echo wp_create_nonce( 'view' ); ?>'
}
@gicolek
gicolek / wp-mediaelement.js
Last active August 29, 2015 14:00
MJ Handler
/* global mejs, _wpmejsSettings */
(function($) {
// add mime-type aliases to MediaElement plugin support
mejs.plugins.silverlight[0].types.push('video/x-ms-wmv');
mejs.plugins.silverlight[0].types.push('audio/x-ms-wma');
$(function() {
var currentID,
settings = {
success: function(media, node, player) {
@gicolek
gicolek / mj.php
Created April 22, 2014 11:58
Media Element js hook
add_action( 'init', 'rg_deregister' );
function rg_deregister() {
wp_deregister_script( 'mediaelement' );
wp_register_script( 'mediaelement', get_template_directory_uri() . '/_ui/js/mediaelement-and-player.min.js', array( 'jquery' ) );
wp_register_script( 'mediaelement-featuredection', get_template_directory_uri() . '/_ui/js/me-featuredetection.js', array( 'mediaelement' ) );
wp_enqueue_script( 'mediaelement-featuredection' );
@gicolek
gicolek / sample.html
Created April 15, 2014 14:26
gf sample
<form method="post" enctype="multipart/form-data" id="gform_1" action="/beantown/wp/contact-us/">
<div class="gform_body">
<ul id="gform_fields_1" class="gform_fields left_label description_below"><li id="field_1_11" class="gfield gsection"><h2 class="gsection_title">We'd love to hear from you!</h2><div class="gsection_description"><div class="vcard"><span class="fn">Erica Voigt</span>
<span>Proprietor</span><a class="email" href="mailto:[email protected]">[email protected]</a>
<a class="tel" href="tel:+16179369047">617.936.9047</a>
</div></div></li><li id="field_1_12" class="gfield"><label class="gfield_label" for="input_1_12">First name</label><div class="ginput_container"><input name="input_12" id="input_1_12" type="text" value="" class="medium" tabindex="1"></div></li><li id="field_1_13" class="gfield"><label class="gfield_label" for="input_1_13">Last name</label><div class="ginput_container"><input name="input_13" id="input_1_13" ty
@gicolek
gicolek / full.php
Created March 4, 2014 14:59
Full Code
<?php
add_filter( 'gform_field_input', 'gf_field_input', 10, 5 );
wp_enqueue_script( 'jquery-ui-datepicker' );
/**
* Overwrite gravity forms input field
*
* @hook gform_field_input
<?php
add_action( 'gform_pre_submission_1', 'gf_form_pre_submission' );
/**
* Presubmission form handler
*
* @hook gform_pre_submission
*/
function gf_form_pre_submission($form) {
@gicolek
gicolek / gf_inlinejs.php
Created March 4, 2014 14:57
WordPress Head Inline js
<?php
add_action( 'wp_head', 'gf_trigger_picker' );
/**
* Inject js code into the head, used with ACF
* @hook wp_head
*/
function gf_trigger_picker() {
@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