Remove vertical tabs? I bought a module on Envato. I've already contacted the developer, but he does not respond. The module outputs some vertical tabs.



They are created with this code.

/**
 * Implements of hook_builder_content_info()
 */
function builder_builder_content_info() {
  $blocks = _block_rehash();
  $contents = array();
  if (!empty($blocks)) {
    foreach ($blocks as $key =&gt; $block) {
      $contents[$block['delta']] = array(
        'info' =&gt; $block['info'],
        'type' =&gt; 'block',
        'group' =&gt; t('Block'),
        // This is name of group to collect contents in a tab
        'block_module' =&gt; $block['module'],
      );
    }
  }

  // node add content
  $contents['node'] = array(
    'info' =&gt; t('Adding existing node'),
    'group' =&gt; t('Node'),
  );

  //Custom text
  $contents['custom_text'] = array(
    'info' =&gt; t('Custom text'),
    'group' =&gt; t('Text'),
  );

  // Custom heading
  $contents['custom_heading'] = array(
    'info' =&gt; t('Custom heading'),
    'group' =&gt; t('Text'),
    'no_title' =&gt; TRUE,
  );
  // Insert image 
  $contents['image'] = array(
    'info' =&gt; t('Insert an image'),
    'group' =&gt; t('Image'),
  );

  $contents['youtube'] = array(
    'info' =&gt; t('Youtube'),
    'group' =&gt; t('Video'),
  );
  $contents['vimeo'] = array(
    'info' =&gt; t('Vimeo'),
    'group' =&gt; t('Video'),
  );

  $contents['icon'] = array(
    'info' =&gt; t('Icon'),
    'group' =&gt; t('Icon'),
  );
  return $contents;
}


I can rewrite them in my own function, but I have no idea how to remove them. I thought through $contents['custom_text'] but I'm not sure. Of course, I can remove the original code, but I do not like it.

It looks like unset($contents['custom_text']) is working, but can I run this from another file/function?

EDIT

/**
 * Implements HOOK_builder_content_info_alter()
 */
function builder_gc_builder_content_info_alter(&amp;$contents) {
    unset($contents['node']);
}
The function you are showing is an implementation of hook_builder_content_info(). Without seeing the code that calls that hook, I cannot answer about removing the vertical tabs, but I can just give some hints.

If the module also invokes hook_builder_content_info_alter(), which is normally done from the majority of the Drupal modules using hooks, you can implement hook_builder_content_info_alter() in a module.

/**
 * Implements hook_builder_content_info_alter()
 */
function builder_gc_builder_content_info_alter(&amp;$contents) {
  unset($contents['node']['group']);
}


The alter hook could get other arguments, but the structure to change is always the first.

If the module doesn't invoke any hook_builder_content_info_alter() you need to:


Avoid Drupal invokes builder_builder_content_info()
Implement hook_builder_content_info() using the same code used by builder_builder_content_info() but without those parts that you don't want


This can be done with the following code.

function builder_gc_module_implements_alter(&amp;$implementations, $hook) {
  if ($hook == 'builder_content_info') {
    // Remove the implementation done from that module.
    unset($implementations['builder']);
  }
}

function builder_gc_builder_content_info() {
  $blocks = _block_rehash();
  $contents = array();
  if (!empty($blocks)) {
    foreach ($blocks as $key =&gt; $block) {
      $contents[$block['delta']] = array(
        'info' =&gt; $block['info'],
        'type' =&gt; 'block',
        'group' =&gt; t('Block'),
        // This is name of group to collect contents in a tab
        'block_module' =&gt; $block['module'],
      );
    }
  }

  // node add content
  $contents['node'] = array(
    'info' =&gt; t('Adding existing node'),
  );

  //Custom text
  $contents['custom_text'] = array(
    'info' =&gt; t('Custom text'),
    'group' =&gt; t('Text'),
  );

  // Custom heading
  $contents['custom_heading'] = array(
    'info' =&gt; t('Custom heading'),
    'group' =&gt; t('Text'),
    'no_title' =&gt; TRUE,
  );
  // Insert image 
  $contents['image'] = array(
    'info' =&gt; t('Insert an image'),
    'group' =&gt; t('Image'),
  );

  $contents['youtube'] = array(
    'info' =&gt; t('Youtube'),
    'group' =&gt; t('Video'),
  );
  $contents['vimeo'] = array(
    'info' =&gt; t('Vimeo'),
    'group' =&gt; t('Video'),
  );

  $contents['icon'] = array(
    'info' =&gt; t('Icon'),
    'group' =&gt; t('Icon'),
  );
  return $contents;
}


The code I am showing should avoid the information is shown in vertical tabs, but it doesn't avoid the vertical tabs are created. The only way to be sure is to alter the function that invokes hook_builder_content_info(). Using hook_builder_content_info_alter(), you are sure to alter the value returned from all the hook_builder_content_info() implementations, while the other snippet I shown just alters the value returned from a module. If there are two modules passing 'node' as group, the vertical tab will be created, since I am not altering what returned from the other module.

Also, the code I am showing removes the 'group' property, which I am guessing sets the vertical tab where the information is shown, similarly to the #group property used by fieldsets.

Alternatively, you can use the following code, which removes completely the information about the part you don't want to see.

// Case 1.

/**
 * Implements hook_builder_content_info_alter()
 */
function builder_gc_builder_content_info_alter(&amp;$contents) {
  unset($contents['node']);
}




// Case 2. 

function builder_gc_module_implements_alter(&amp;$implementations, $hook) {
  if ($hook == 'builder_content_info') {
    // Remove the implementation done from that module.
    unset($implementations['builder']);
  }
}

function builder_gc_builder_content_info() {
  $blocks = _block_rehash();
  $contents = array();
  if (!empty($blocks)) {
    foreach ($blocks as $key =&gt; $block) {
      $contents[$block['delta']] = array(
        'info' =&gt; $block['info'],
        'type' =&gt; 'block',
        'group' =&gt; t('Block'),
        // This is name of group to collect contents in a tab
        'block_module' =&gt; $block['module'],
      );
    }
  }

  //Custom text
  $contents['custom_text'] = array(
    'info' =&gt; t('Custom text'),
    'group' =&gt; t('Text'),
  );

  // Custom heading
  $contents['custom_heading'] = array(
    'info' =&gt; t('Custom heading'),
    'group' =&gt; t('Text'),
    'no_title' =&gt; TRUE,
  );
  // Insert image 
  $contents['image'] = array(
    'info' =&gt; t('Insert an image'),
    'group' =&gt; t('Image'),
  );

  $contents['youtube'] = array(
    'info' =&gt; t('Youtube'),
    'group' =&gt; t('Video'),
  );
  $contents['vimeo'] = array(
    'info' =&gt; t('Vimeo'),
    'group' =&gt; t('Video'),
  );

  $contents['icon'] = array(
    'info' =&gt; t('Icon'),
    'group' =&gt; t('Icon'),
  );
  return $contents;
}


If this code doesn't work, you could follow the following steps, in order to change the module behavior:


Check which function is invoking hook_builder_content_info()
Verify if there is a reference to that function in one of the hooks Drupal uses (e.g. hook_menu()); the reference could be either direct or indirect (i.e., the reference is for a function that calls the function invoking hook_builder_content_info())
If this is the case, using the alter hook Drupal uses (e.g. hook_menu_alter()), you can change that reference with a reference to a function you write, which uses the code the original function uses, without the part you don't want.


In this way, you aren't directly altering the values returned from hook_builder_content_info(), and you need to copy more of the code used from the module for which you are altering the behavior; this is also means that, for every minimal change in the module you bought, you need to check your code to be sure it doesn't alter the expected behaviour.