Skip to content

Instantly share code, notes, and snippets.

View nkb-bd's full-sized avatar

Lukman Nakib nkb-bd

  • Authlab Limited
  • Bangladesh
View GitHub Profile
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@nkb-bd
nkb-bd / client.js
Created March 1, 2024 09:12 — forked from georgestephanis/client.js
This is an example client app to integrate with the WordPress 5.6 Application Passwords system. It walks the user through authenticating, and then queries and enumerates all users on the site.
(function($){
const $root = $( '#root' );
const $stage1 = $( '.stage-1', $root );
const $stage2 = $( '.stage-2', $root );
// If there's no GET string, then no credentials have been passed back. Let's get them.
if ( ! window.location.href.includes('?') ) {
// Stage 1: Get the WordPress Site URL, Validate the REST API, and Send to the Authentication Flow
const $urlInput = $( 'input[type=url]', $stage1 );
@nkb-bd
nkb-bd / semantic-commit-messages.md
Created January 11, 2024 11:48 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@nkb-bd
nkb-bd / ff-numeric-addon-bttns.php
Created October 4, 2023 17:38
Fluent Forms : Number field with buttons
/*
* Fluent Form : Creating a Number field with + / - Button embeded with the input field
* Take a Numeric Field then add element class 'incremental-input', thats it
*/
add_filter('fluentform/rendering_field_data_input_number', function ($data) {
if ($data['attributes']['class'] == 'incremental-input') {
$data['settings']['prefix_label'] = '<button class="ff-btn-step-plus">+</button>';
$data['settings']['suffix_label'] = '<button class="ff-btn-step-minus">-</button>';
}
return $data;
@nkb-bd
nkb-bd / ff_email_validation.php
Last active January 9, 2024 08:34
Email Validation using wp fluent form
add_filter('fluentform/validate_input_item_input_email', function ($default, $field, $formData, $fields, $form) {
// You may change the following 3 lines
$targetFormIds = [140,141];
$errorMessage = 'Looks like email is not correct'; // You may change here
$emailableApiKey = 'live_b67c9cb0585e27dd256c';
if (!in_array($form->id, $targetFormIds)){
return $default;
}
<!--
hero: https://bulma.io/documentation/layout/hero/
section: https://bulma.io/documentation/layout/section/
image: https://bulma.io/documentation/elements/image/
columns: https://bulma.io/documentation/columns/basics/
media: https://bulma.io/documentation/layout/media-object/
icon: https://bulma.io/documentation/elements/icon/
breadcrumb: https://bulma.io/documentation/components/breadcrumb/
level: https://bulma.io/documentation/layout/level/
-->
@nkb-bd
nkb-bd / file-upload-issue.php
Created March 17, 2023 10:38
ff file upload issue fix
// Please remove and add the file input again to work properly.
add_filter('fluentform_file_type_options', function ($options) {
$options[2]['value'] = 'avi|divx|flv|mov|ogv|mkv|mp4|m4v|divx|mpg|mpeg|mpe|qt';
return $options;
});
@nkb-bd
nkb-bd / gist:b0968c015b34287e7687257820154637
Created March 14, 2023 12:21
Single Form Admin Access for Fluent Form
//First Set all permission for the user from the settings
add_action('init',function (){
$userId = 18; //Enter User ID (except admin)
$formId = 11; //Fluent Form ID
customPermissionRule($userId,$formId);
});
function customPermissionRule($userId,$formId){
if($userId != get_current_user_id()){
return;
@nkb-bd
nkb-bd / random.php
Created March 6, 2023 06:45
Random WordPress Filter & Hooks
//adding nonce in extra js inline script
add_filter('script_loader_tag', function ($tag, $handle) {
if ('script-handler' === $handle) {
$nonce = wp_create_nonce();
$tag = str_replace('<script ', "<script nonce='$nonce' ", $tag);
}
return $tag;
}, 10, 2);
@nkb-bd
nkb-bd / wp-config.php
Last active February 19, 2024 07:27
Valet Share for WordPress using ngrok
//Share a public live url of you local site
// First setup ngork you will need an account
//add these to wp-config.php
$_SERVER['HTTPS'] = 'on';
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_X_ORIGINAL_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_X_ORIGINAL_HOST']);
$_SERVER['HTTP_HOST'] = $_SERVER["HTTP_X_ORIGINAL_HOST"]; // Valet share hack