Skip to content

Instantly share code, notes, and snippets.

View imknight's full-sized avatar
🏠
Working from home

Knight imknight

🏠
Working from home
View GitHub Profile
@imknight
imknight / operation_fuel_modules.php
Created October 24, 2011 01:34
Create a dropdown filter on item listing page [FUELCMS]
$config['modules']['operation_queue'] = array(
'module_name' => 'Queue Management',
'module_uri' => 'operation/queue',
'model_name' => 'queue_model',
'model_location' => 'operation',
'permission' => 'operation/queue',
'nav_selected' => 'operation/queue',
'default_col' => 'date_added',
'display_field' => 'id',
'filters' => array('date_added' => array('default' => date('Y-m-d',time()), 'label' => 'Queue Day', 'type' => 'select')),
@imknight
imknight / parsley.js
Last active December 20, 2015 07:39
custom function for Parsley before submit
$('#contactform').parsley({
//exclude input type , file ?
excluded: 'input[type=hidden]',
validators: {
// for #3 ,checking the input must have value , example dropdown list with "Select this" kind of option should be no value so that it can be skipped
checkdefault: function (val, checkdefault) {
if (val[0] === '') return false;
else return true;
}
},
@imknight
imknight / post order
Last active December 23, 2015 00:19
Sort the posts order in page
add_filter('pre_get_posts', 'pre_get_posts_hook' );
function pre_get_posts_hook($wp_query) {
if (is_page())
{
$wp_query->set( 'orderby', 'title' );
$wp_query->set( 'order', 'ASC' );
return $wp_query;
}
}
@imknight
imknight / 0_reuse_code.js
Created October 15, 2013 02:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@imknight
imknight / gravity-form-save-acf
Last active November 22, 2017 21:29
WordPress Gravity Form Save Custom Meta Field for Advanced Custom Fields
add_action("gform_after_submission_1", "acf_post_submission", 10, 2);
function acf_post_submission ($entry, $form)
{
$post_id = $entry["post_id"];
update_field('address1', $entry['29.1'], $post_id);
update_field('address2', $entry['29.2'], $post_id);
update_field('address3', $entry['29.3'], $post_id);
}
@imknight
imknight / functions.php
Created February 28, 2016 07:25
Cleaning redis cache for qtranslate-X on Woocommerce Site
add_action( 'clean_post_cache', 'clean_qtranslatex_cache', 10, 2 );
function clean_qtranslatex_cache( $post_id, $post) {
//depends on what language you have turn on for your site.
wp_cache_delete( $post_id, 'post_metazh' );
}
@imknight
imknight / woocommerce-processing-order-email.php
Last active October 20, 2018 22:09
Custom Email for Woocommerce
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WC_Process_Order_Email' ) ) :
/**
* Factory Completed Order Email
*
* An email sent to the factory when a new order is completed.
*
@imknight
imknight / ApiAuthController.php
Last active April 19, 2021 10:13
API Controller + API Route for Integrate Jetstream + Adalo
<?php
namespace App\Http\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use App\Models\User;
class ApiAuthController extends Controller