Skip to content

Instantly share code, notes, and snippets.

@annuman97
annuman97 / autoserialnumber.php
Created May 7, 2024 11:27
Auto Serial Number column to a Table in NT
// Auto serial number
add_filter('ninja_table_rendering_table_vars', function($table_vars, $table_id, $tableArray){
$target_id = 1320;
if ($tableArray['table_id'] != $target_id) {
return $table_vars;
}
$counter_column = [
'name' => 'serial',
'key' => 'serial',
@annuman97
annuman97 / NTReadMoreLessButton.js
Created April 8, 2024 10:09
NTReadMoreLessButtonForMultipleColumns
/*Read More text on a table cell */
$(document).ready(function(){
var maxLength = 15; // give character length here
var colNames = ['title','citation', 'summary']; // give your column key here
var readMoreText = "read more..."; // give read more text here
var readLessText = "read less..."; //give read less text here
function limitChar(){
for(i = 0 ; i<colNames.length; i++){
@annuman97
annuman97 / Fluent Form File Upload extensions
Created April 7, 2024 09:02
Fluent Form File Upload extensions
add_filter('fluentform/file_type_options', function ($types) {
$types[] = [
'label' => __('3d files - DWG, STL, STEP, STP, SKP, MAX, FBX, 3DS, IGES, OBJ', 'fluentform'),
'value' => 'dwg|stp|stl|STEP|skp|max|fbx|3ds|iges|obj',
];
return $types;
});
add_filter('upload_mimes', function ($mime_types) {
$mime_types ['dwg'] = 'image/vnd.dwg';
@annuman97
annuman97 / ffAddressAutoCompleteRestrictFeilds.js
Created December 30, 2023 10:56
Fluent From address field with Geolocation enabled. Where when users enter the Address Line 1 field all the other field will be filled and disabled for editing.
$(".ff-name-address-wrapper.fluent-address.ff_map_autocomplete input").on('input', function() {
$(".fluent-address :input:not(:focus)").prop("disabled", this.value.length);
});
@annuman97
annuman97 / MakeAllLinksandMailAddressClickable.js
Created October 6, 2023 06:46
MakeAllLinksandMailAddressClickable
let desc = Array.from(document.querySelectorAll('td.link'));
desc.forEach((cell) => {
let cellVal = cell.innerText.split(' ');
cellVal.find((val)=>{
if(val.includes('@')){
let replaceText = cell.innerHTML.replace(val, `<a href="mailto:${val}">${val}</a>`);
cell.innerHTML = replaceText;
}else if(val.includes('http')){
let replaceText = cell.innerHTML.replace(val, `<a href="${val}">${val}</a>`);
@annuman97
annuman97 / ninjaTablesAutoSerialNumberforMultipleTables.php
Last active May 7, 2024 11:26
Auto Serial Number to multiple ninja tables
add_filter('ninja_table_rendering_table_vars',function($table_vars, $table_id, $tableArray){
$target_id = [2607,2608];//add all tables ID here
$tableId = 0;
foreach($target_id as $id){
if($table_id == $id){
$tableId = $id;
}
}
@annuman97
annuman97 / gist:c7f7e49068f52abfbe7693e2f79cf6fe
Created July 24, 2023 09:31
Randomize/shuffle the table rows each time after refresh the page
(function($){
//Shuffle all rows, while keeping the first column
//Requires: Shuffle
$.fn.shuffleRows = function(){
return this.each(function(){
var main = $(/table/i.test(this.tagName) ? this.tBodies[0] : this);
var firstElem = [], counter=0;
main.children().each(function(){
firstElem.push(this.firstChild);
});
@annuman97
annuman97 / ninjaTablesNumbertoStar.php
Created May 4, 2023 06:54
Replace Numbers to Star in ninja table column
add_filter('ninja_tables_get_public_data', function ($data, $tableId) {
if ($tableId == 3156) {
for($i = 0; $i < count($data); $i++){
$val = $data[$i]['player_ranking'];
$arr = [];
$icon = '[nt_icon icon="star" color="orange"]';
for($j = 1; $j<= $val; $j++){
array_push($arr, $icon);
add_filter('fluentform_validate_input_item_input_email', function($errorMessage, $field, $formData, $fields, $form) {
$target_id = [59,60];
$target_form_id = 0;
foreach($target_id as $id){
if($form->id == $id){
var btnn = document.querySelector('.footable-filtering');
let btn = document.createElement("button");
btn.classList.add('mybtn');
btn.innerHTML = "DISPLAY TABLE BODY";
btnn.append(btn);
$('.footable tbody').hide();
document.querySelector('button.mybtn').addEventListener('click', function(){