Skip to content

Commit

Permalink
Fix(Core): fix js/css injection conflict with other plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz authored Jul 10, 2024
1 parent 70fe3ca commit b7eec9e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
3 changes: 0 additions & 3 deletions css/fields.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,3 @@ div.fields_clear {
clear: both;
width:100%;
}
.drag {
background: none !important;
}
32 changes: 27 additions & 5 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,16 @@ function plugin_init_fields()
$PLUGIN_HOOKS['pre_item_purge']['fields']['Profile'] = ["PluginFieldsProfile", "deleteProfile"];

//load drag and drop javascript library on Package Interface
$PLUGIN_HOOKS['add_javascript']['fields'][] = "lib/redips-drag-min.js";
if (!$debug && file_exists(__DIR__ . '/js/drag-field-row.min.js')) {
$PLUGIN_HOOKS['add_javascript']['fields'][] = 'js/drag-field-row.min.js';
} else {
$PLUGIN_HOOKS['add_javascript']['fields'][] = 'js/drag-field-row.js';

if (
plugin_fields_script_endswith("container.form.php")
) {
$PLUGIN_HOOKS['add_javascript']['fields'][] = "lib/redips-drag-min.js";
if (!$debug && file_exists(__DIR__ . '/js/drag-field-row.min.js')) {
$PLUGIN_HOOKS['add_javascript']['fields'][] = 'js/drag-field-row.min.js';
} else {
$PLUGIN_HOOKS['add_javascript']['fields'][] = 'js/drag-field-row.js';
}
}
}

Expand Down Expand Up @@ -189,6 +194,23 @@ function plugin_init_fields()
}


/**
* Check if the script name finish by
*
* @param string $scriptname
* @return boolean
*/
function plugin_fields_script_endswith($scriptname)
{
//append plugin directory to avoid dumb errors...
$scriptname = 'fields/front/' . $scriptname;
$script_name = $_SERVER['SCRIPT_NAME'];

return substr($script_name, -strlen($scriptname)) === $scriptname;
}



/**
* Get the name and the version of the plugin
* REQUIRED
Expand Down

0 comments on commit b7eec9e

Please sign in to comment.