Skip to content

Instantly share code, notes, and snippets.

@alex-authlab
alex-authlab / fluentform-checkbox-max-restriction.js
Created April 2, 2021 04:07 — forked from techjewel/fluentform-checkbox-max-restriction.js
prevent users to check max 3/x items from a checkbox group - Fluent Forms
/**
* Function to prevent users mark more than expected items.
* This code must need to be placed in custom JS of your form
* @param: containerClass String - The contaner class of the target checkbox block.
* You can add a custom container class in the form settings
*
* @param: maxChecked Integer - Max Number of items user can mark
* @return: void
*
*/
add_action('recaptcha_custom_function', 'recaptcha_custom_function_callback', 10, 1 );
function recaptcha_custom_function_callback( $form) {
echo '
<script type="text/javascript">
jQuery( document ).ready(function() {
jQuery(".ff-btn-submit").attr("disabled", "true");
});
function enableBtn(){
jQuery(".ff-btn-submit").removeAttr("disabled");
}
add_filter('ninja_table_raw_sql_placeholders', function ($value) {
$value['{name}'] = 'kamrul';
return $value;
});
/*
* The following functions will add additional file types option to your file upload element
* In this case, You can enable .dwg file format
* Just add this snippet to your theme's functions.php file or relevant place.
*/
add_filter('fluentform_file_type_options', function ($types) {
$types[] = [
'label' => __('Autocad Files (dwg)', 'fluentform'),
'value' => 'dwg',
@alex-authlab
alex-authlab / dynamic_data.php
Created December 5, 2020 10:14 — forked from techjewel/dynamic_data.php
Dynamic Data Manipulation in Ninja Tables
<?php
/*
* Say we want to change data of table id 1477 then you can write the following
* code.
* $data is the array of frontend data
*/
add_filter('ninja_tables_get_public_data', function ($data, $tableId) {
if ($tableId == 1477) {
$data[] = [
'name' => 'Dynaic Name',
<?php
function distance($lat1, $lng1, $lat2, $lng2)
{
// convert latitude/longitude degrees for both coordinates
// to radians: radian = degree * π / 180
$lat1 = deg2rad($lat1);
$lng1 = deg2rad($lng1);
$lat2 = deg2rad($lat2);
$lng2 = deg2rad($lng2);
<?php
add_filter('fluenform_rendering_field_data_select', function ($data, $form) {
if ($form->id != 91) {
return $data;
}
// do the dynamic part if and only the name attriibute is 'dynamic_dropdown'
// Please use the corresponding field name for your case.
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'dynamic_dropdown') {
return $data;