Skip to content

Instantly share code, notes, and snippets.

View mlbd's full-sized avatar
🏠
Working from home

Mohammad Limon mlbd

🏠
Working from home
View GitHub Profile
@mlbd
mlbd / gist:8d8bc2561d67f00993719eb2f3f8aa93
Created September 3, 2025 21:35
Auto-reject after one, send an email after each assignment is completed, and add a ‘Last Signed Off’ placeholder.
add_filter('owf_review_step_total_reviews', function ($total_reviews, $review_setting, $action_history_id, $step_id) {
global $wpdb;
/**
* NEW: For steps requiring "everyone" to approve, if ANY reviewer has rejected (unable),
* auto-reject all remaining "assignment" reviews immediately so the failure branch proceeds now.
* We also persist these changes so inbox/reminders are cleaned up.
*/
if ( ! empty( $total_reviews ) ) {
@mlbd
mlbd / gist:29a0d2f9b38d539d25cf2e8eea423f5f
Created September 3, 2025 21:34
Automatically reject the task for all assignees if any one assignee rejects or disapproves it.
add_filter('owf_review_step_total_reviews', function ($total_reviews, $review_setting, $action_history_id, $step_id) {
global $wpdb;
/**
* NEW: For steps requiring "everyone" to approve, if ANY reviewer has rejected (unable),
* auto-reject all remaining "assignment" reviews immediately so the failure branch proceeds now.
* We also persist these changes so inbox/reminders are cleaned up.
*/
if ( ! empty( $total_reviews ) ) {
@mlbd
mlbd / gist:2f25beb3a32f68eb69baa32b886c63c1
Created September 3, 2025 21:31
Per-assignee approval email that is sent immediately after an assignment is completed.
// [NEW] Per-assignee approval email
add_action( 'owf_individual_signoff_approved', 'send_individual_signoff_email', 10, 7 );
/**
* [NEW] Send "assignment-style" email when an individual assignee approves a review step.
* Reuses the Assignment Email template via get_step_mail_content(), without needing the next action_id.
*
* @param int $post_id
* @param int $action_history_id Current step action_history_id
* @param int $actor_id Approver user ID
@mlbd
mlbd / gist:dff12f2330c04ec726b0415f86be7de3
Created September 3, 2025 21:30
Add ‘Last Signed Off By’ to show who performed the most recent sign-off.
// [PATCH] Added custom placeholder "%last_signed_off_by%" for emails and its runtime resolver.
if ( ! function_exists( 'owf_register_last_signed_off_by_placeholder' ) ) {
function owf_register_last_signed_off_by_placeholder() {
// Show the placeholder label in the Step Info email editor (step-info-content.php)
add_filter( 'oasiswf_custom_placeholders', function( $placeholders ) {
if ( ! is_array( $placeholders ) ) {
$placeholders = array();
}
// [PATCH] Added new placeholder label so it appears in the dropdown
$placeholders['%last_signed_off_by%'] = esc_html__( 'Last Signed off by', 'oasisworkflow' );
@mlbd
mlbd / submit-workflow.js
Created September 2, 2025 03:58
Replace this "submit-workflow.js" with "/plugins/oasis-workflow/js/pages/subpages/submit-workflow.js"
jQuery( document ).ready( function () {
var stepProcess = "";
//------main function-------------
function load_setting() {
var allowed_post_types = jQuery.parseJSON( owf_submit_workflow_vars.allowedPostTypes );
var current_post_type = jQuery( '#post_type' ).val();
// check if role is applicable to submit to workflow
if ( current_post_type !== undefined ) {
var check_is_role_applicable = {
/**
* A) Regenerate Elementor CSS for a specific post.
*
* Safe on Elementor 3.31.x. Only runs if the post is built with Elementor.
*/
function ml_el_regenerate_post_css( $post_id ) {
if ( empty( $post_id ) || wp_is_post_revision( $post_id ) ) return;
if ( ! class_exists( '\Elementor\Plugin' ) ) return;
$run = function() use ( $post_id ) {
@mlbd
mlbd / gist:bf2572ffce9b2e5c8f52a029eab71d37
Created August 17, 2025 13:08
Fix Missing Elementor Repeater Images After OCDI Import (Multisite-Safe Reconciler)
<?php
/**
* Run the Elementor media reconciliation AFTER One Click Demo Import finishes.
*
* Why priority 30?
* - Ensures your own after-import tasks (menus, front/blog pages, Replace URL, etc.)
* have already completed, so media IDs/URLs are normalized last.
*
* Hook names:
/**
* Get the team_id for a user from the {prefix}fc_team_members table.
*
* @param int $user_id User ID.
* @return int|false Team ID or false if none.
*/
function owf_helmy_get_user_team_id( $user_id ) {
global $wpdb;
$table = $wpdb->prefix . 'fc_team_members';
@mlbd
mlbd / Oasis Workflow: Per-Team Post Visibility & Admin Columns for WordPress
Created August 8, 2025 08:20
This snippet restricts post visibility in the WordPress admin based on the user’s team (using Oasis Workflow Pro Teams table), and automatically tags posts with the creator’s team.
/**
* Oasis Workflow: Per-Team Post Visibility & Admin Columns
* ---------------------------------------------------------
* - Restricts admin post list to show only posts for user's team (editors/authors)
* - Sets _team_id meta on new posts for configured post types
* - Shows "Team" column (with name) in admin for each Oasis-enabled post type
*
* @author Your Name
* @license GPL-2.0+
/**
* Change Elementor Editor "Submit" Button Text for Non-Publish Users
*
* Replaces the "Submit" button label with "Send for Review" in the Elementor editor UI
* for users who lack the 'publish' capability. Useful for Contributor roles or
* custom workflow permissions.
*
* Add to your theme's functions.php or as a small plugin.
*
* @author OpenAI ChatGPT (2025)