HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/fabricas.colombiatrade.com.co/web_https/core/themes/stable/stable.theme
<?php

/**
 * @file
 * Functions to support theming in the Stable theme.
 */

use Drupal\Component\Utility\Html;

/**
 * Implements hook_library_info_alter().
 */
function stable_library_info_alter(&$libraries, $extension) {
  // Add removed css/filter.admin.css file back so that themes overriding
  // this file continue getting same behavior until Drupal 9.
  if ($extension === 'filter') {
    if (isset($libraries['drupal.filter.admin'])) {
      $libraries['drupal.filter.admin']['css']['theme']['css/filter.admin.css'] = [];
    }
    if (isset($libraries['drupal.filter'])) {
      $libraries['drupal.filter']['css']['theme']['css/filter.admin.css'] = [];
    }
  }
}

/**
 * Implements template_preprocess_links().
 */
function stable_preprocess_links(&$variables) {
  // @deprecated in Drupal 8.0.x and will be removed before 9.0.0. This feature
  // of adding a class based on the associative key can cause CSS class name
  // conflicts.
  if (!empty($variables['links'])) {
    foreach ($variables['links'] as $key => $value) {
      if (!is_numeric($key)) {
        $class = Html::getClass($key);
        $variables['links'][$key]['attributes']->addClass($class);
      }
    }
  }
}

/**
 * Implements hook_element_info_alter().
 */
function stable_element_info_alter(array &$info) {
  if (array_key_exists('text_format', $info)) {
    $info['text_format']['#process'][] = 'stable_process_text_format';
  }
}

/**
 * #process callback, for adding classes to filter components.
 *
 * @param array $element
 *   Render array for the text_format element.
 *
 * @return array
 *   Text_format element with the filter classes added.
 */
function stable_process_text_format(array $element) {
  $element['format']['#attributes']['class'][] = 'filter-wrapper';
  $element['format']['guidelines']['#attributes']['class'][] = 'filter-guidelines';
  $element['format']['format']['#attributes']['class'][] = 'filter-list';
  $element['format']['help']['#attributes']['class'][] = 'filter-help';

  return $element;
}

/**
 * Implements hook_preprocess_image_widget().
 */
function stable_preprocess_image_widget(&$variables) {
  if (!empty($variables['element']['fids']['#value'])) {
    $file = reset($variables['element']['#files']);
    $variables['data']['file_' . $file->id()]['filename']['#suffix'] = ' <span class="file-size">(' . format_size($file->getSize()) . ')</span> ';
  }
}