function updateSectionsWithPlugins(sections) {
  if (PLUGIN_ADMIN_SETTINGS_UPDATES.length > 0) {
    const reduced = PLUGIN_ADMIN_SETTINGS_UPDATES.reduce(
      (sections, update) => update(sections),
      sections,
    );

    // the update functions may change the key ordering inadvertently
    // see: https://github.com/aearly/icepick/issues/48
    // therefore, re-sort the reduced object according to the original key order
    const reSortFn = ([, aVal], [, bVal]) =>
      aVal && bVal && aVal.order - bVal.order;

    return Object.fromEntries(Object.entries(reduced).sort(reSortFn));
  } else {
    return sections;
  }
}
// This allows plugins to update the settings sections
This allows plugins to update the settings sections
This allows plugins to update the settings sections
function updateSectionsWithPlugins(sections) {
  if (PLUGIN_ADMIN_SETTINGS_UPDATES.length > 0) {
    const reduced = PLUGIN_ADMIN_SETTINGS_UPDATES.reduce(
      (sections, update) => update(sections),
      sections,
    );
    const reSortFn = ([, aVal], [, bVal]) =>
      aVal && bVal && aVal.order - bVal.order;
    return Object.fromEntries(Object.entries(reduced).sort(reSortFn));
  } else {
    return sections;
  }
}
function updateSectionsWithPlugins ( sections ) { if ( PLUGIN_ADMIN_SETTINGS_UPDATES . length > 0 ) { const reduced = PLUGIN_ADMIN_SETTINGS_UPDATES . reduce ( ( sections , update ) => update ( sections ) , sections , ) ; const reSortFn = ( [ , aVal ] , [ , bVal ] ) => aVal && bVal && aVal . order - bVal . order ; return Object . fromEntries ( Object . entries ( reduced ) . sort ( reSortFn ) ) ; } else { return sections ; } }
This allows plugins to update the settings sections
This allows plugins to update the settings sections
// the update functions may change the key ordering inadvertently // see: https://github.com/aearly/icepick/issues/48 // therefore, re-sort the reduced object according to the original key order