Skip to content

Instantly share code, notes, and snippets.

View techjewel's full-sized avatar
🎯
Focusing

Shahjahan Jewel techjewel

🎯
Focusing
View GitHub Profile
@techjewel
techjewel / us_zip_cdes.json
Last active August 4, 2017 13:39
ZIP codes of USA in json format including city name, State, lat and long
[
{
"country": "US",
"zip": 34034,
"city": "APO",
"FIELD4": "",
"state": "AA",
"state_name": "Dillon",
"code": 33,
"FIELD8": "",
@techjewel
techjewel / stripeCurrencies.php
Created July 20, 2017 06:44
Supported Stripe Currencies
<?php
/*
* Stripe Supported Currencies
* - JCB, Discover, and Diners Club cards can only be charged in USD
* - Currencies marked with * are not supported by American Express
* - Most alternative payment methods can only be used with a single currency
* - Brazilian Stripe accounts (currently in Preview) can only charge in Brazilian Real
* - Mexican Stripe accounts (currently in Preview) can only charge in Mexican Peso
* - Data from https://stripe.com/docs/currencies#charge-currencies
* - Last Update: July 20, 2017

WordPress Class Schedules

Introduction to WordPress Core

  • Installing WordPress
  • Basic Usage of WordPress
  • File Structure
  • Database Schema
  • Request Life-Cycle
<?php
function ninjaSanitizeTextOrArray( $array_or_string ) {
if ( is_string( $array_or_string ) ) {
$array_or_string = sanitize_text_field( $array_or_string );
} elseif ( is_array( $array_or_string ) ) {
foreach ( $array_or_string as $key => &$value ) {
if ( is_array( $value ) ) {
$value = ninjaSanitizeTextOrArray( $value );
} else {
<?php
function addInlineVars($vars, $table_id) {
if(function_exists('wp_add_inline_script')) {
wp_add_inline_script( 'script_handle', 'window.ninja_footables.tables["table_'.$table_id.'"] = '.$vars.';');
} else {
add_action('wp_footer', function () use ($vars, $table_id) {
?>
<script type="text/javascript">
window.ninja_footables.tables["table_<?php echo $table_id;?>"] = <?php echo $vars ?>;
@techjewel
techjewel / scroll_to_top.js
Created March 21, 2018 08:12
Paging number click event and scroll to ninja tables beginning - WordPress Ninja Tables
/*
Change the offset value based on your theme. If you have fixed with header then you may need to increase the value
This code snippet only work on https://wordpress.org/plugins/ninja-tables/
*/
jQuery(document).ready(function() {
jQuery('table.ninja_footable').on('click', '.footable-page-link', function (e) {
var offset = 50;
jQuery('html, body').animate({
scrollTop: jQuery(this).closest('table.ninja_footable').offset().top - offset
<div id="footable_parent_353" class="ninja_table_wrapper">
<table class="ninja_table_pro">
<thead>
<tr class="footable-filtering">
<!-- Filtering Markup here -->
</tr>
<tr class="footable-header">
<th class="ninja_column_0">Column 1</th>
<th class="ninja_column_1">Another Column</th>
</tr>
<?php
// Add the following code snippet in your theme's function.php file to enable exact match for ninja table search
add_filter('ninja_table_attributes', function ($atts, $tableId) {
$targetTableId = 1; // change value "1" with your table id that you want to match exact
if($targetTableId == $tableId) {
$atts['data-filter-exact-match'] = "true";
}
return $atts;
<?php
/*
Plugin Name: Ninja Table Dynamic Data
Description: Dynamic Data Example For Ninja Tables
Version: 1.0.0
Author: WPManageNinja
Author URI: https://wpmanageninja.com/
Plugin URI: https://wpmanageninja.com/downloads/ninja-tables-pro-add-on/
License: GPLv2 or later
Text Domain: ninja_table_dynamic_data
<?php
/*
* Say you have table which table id is 101 and you want to filter some data
* Please disable caching for this table and load using ajax renderer
*/
add_filter('ninja_tables_get_public_data', function ($data, $tableId) {
if($tableId != 101) {
return $data; // Return if this is not our target table
}