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 / fcrm_contact_count.php
Created January 25, 2024 14:57
get contact count by tag ids
<?php
/*
* FluentCRM get contact count by tag ids
* Example Usage: fcrmGetContactCountByTagIds([1,2,4]);
* @param array $tagIds
* @return int
*/
function fcrmGetContactCountByTagIds($tagIds = [])
{
@techjewel
techjewel / fluentform-email-attachment.php
Last active December 31, 2023 15:13
Add Attachment to the email notification programatically in Fluent Forms.
<?php
/*
* Add Attachment to the email notification dynamically.
* @param $attachments array - Array of the attachments.
* @param $notification array - Email Notification array
* @param $form object - The Form Object
* @param $data array - The input submission data
* @return array
*/
@techjewel
techjewel / woo-filter-by-payment-gateway.php
Last active December 21, 2023 05:26
Filter WooCommerce orders by payment gateway
<?php // do not include this line in FluentSnippets
add_action('woocommerce_order_list_table_restrict_manage_orders', function($type) {
if ( 'shop_order' !== $type ) {
return;
}
// get all payment methods, even inactive ones
@media (max-width: 767px) {
.fluentform .ff-el-group.ff_list_buttons .ff-el-form-check span {
width: 100% !important;
border-left: 1px solid #dcdfe6 !important;
border-radius: 0 !important;
}
.fluentform .ff-el-group.ff_list_buttons .ff-el-form-check {
margin-top: -1px !important;
display: block !important;
@techjewel
techjewel / NinjaTablesShortcodeUsage.php
Last active November 1, 2023 21:06
Ninja Tables Advanced Shortcode Usage
<?php
// The following Table Shortcode will show 5 rows per page
[ninja_tables id='YOUR TABLE ID HERE' per_page=5]
// The following Table Shortcode will not show search bar
[ninja_tables id='YOUR TABLE ID HERE' search=0]
// The following Table shorcode will disable table sorting
[ninja_tables id='YOUR TABLE ID HERE' sorting=0]
<?php
/*
* Code snippet to make login form with Fluent Forms WordPress Plugins
* Steps:
* 1. make a form with email and password (Make sure the name attribute is 'email' and 'password' for corresponding field)
* 2. Paste the shorcode in a page
* 3. Change the form id in the bellow code (23) with your created fluentform's form id and paste in your theme's functions.php file
* 4. That's it
*
@techjewel
techjewel / fluentform-checkbox-max-restriction.js
Last active October 19, 2023 06:51
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
*
*/
@techjewel
techjewel / ninja-table-snippets.js
Last active October 11, 2023 21:32
Ninja Tables Custom JS Snippets for many functionalities
// By default ninja tables keeps open each row for expanding
// You can add the following js then it will keep expanded one row at a time
var currentExpandRow = false;
$table.on('expanded.ft.row', function (e, ft, selfArg) {
if(currentExpandRow == selfArg) {
return;
}
currentExpandRow = selfArg;
ft.rows.collapse();
selfArg.expand();
@techjewel
techjewel / fluentform-submission-success.js
Last active September 14, 2023 13:42
Form submission success JS Event in Fluent Forms
// Event on form submission success
// You can paste this script to Form's custom JS Box
$form.on('fluentform_submission_success', function() {
// You can run your own JS and will be run on successful form submission
});
@techjewel
techjewel / sream_function.php
Created June 25, 2016 22:15
Stream a mp3 file using php when you need to protect the file
<?php
function zcast_stream($file, $content_type = 'application/octet-stream') {
@error_reporting(0);
// Make sure the files exists, otherwise we are wasting our time
if (!file_exists($file)) {
header("HTTP/1.1 404 Not Found");
exit;
}