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: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)
/**
* Action hook triggered when a user submits a post/page to workflow or completes a step.
*
* Updates the due date of the action history record to the global default due date set in
* the Workflow Settings tab, if the default due date is set.
*
* @param int $post_id The ID of the post/page being submitted.
* @param int $action_history_id The ID of the action history record being updated.
*/
function custom_modify_due_date_on_submit($post_id, $action_history_id) {
/**
* Enable support for post tags on pages.
*/
function owf_add_tags_to_pages() {
register_taxonomy_for_object_type( 'post_tag', 'page' );
}
add_action( 'init', 'owf_add_tags_to_pages' );
// Add action to both front-end and admin to conditionally hide the Beaver Builder publish button.
add_action( 'admin_head', 'owf_hide_bb_publish_button' );
@mlbd
mlbd / Hide the publish button in Beaver Builder based on the user's role.
Created July 11, 2025 06:15
Hide the publish button in the Beaver Builder editor for users who do not have the ow_sign_off_step capability. Users who have the ow_sign_off_step capability should still be able to see the publish button.
add_action('admin_head', 'hide_bb_publish_button');
add_action('wp_head', 'hide_bb_publish_button');
function hide_bb_publish_button() {
if (!current_user_can('ow_sign_off_step')) {
echo '<style>
.fl-builder-actions .fl-builder-button.fl-builder-publish-button,
.fl-builder-button-group span.fl-builder-button[data-action="publish"] {
display: none;
}
/**
* Validate the editorial checklist condition.
*
* @param array $validation_result The validation result array passed by the filter.
* @param array $workflow_action_params The workflow action parameters array passed by the filter.
*
* @return array The validation result array with the error message and type.
*/
function owf_ediotrial_checklist_validate_condition( $validation_result, $workflow_action_params ) {