HEX
Server: Apache
System: Linux cpanelx.inxs.ro 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: crowdandsafety (1041)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/thread-self/cwd/wp-content/plugins/cornerstone/includes/classes/Controllers/Fonts.php
<?php

/**
 * Font Rest API
 */

namespace Themeco\Cornerstone\Controllers;

use DomainException;
use Themeco\Cornerstone\Services\GlobalFonts;
use Themeco\Cornerstone\Services\Routes;

class Fonts {
  protected $routes;
  private $globalFonts;

  public function __construct(Routes $routes, GlobalFonts $globalFonts) {
    $this->routes = $routes;
    $this->globalFonts = $globalFonts;
  }

  public function setup() {
    $this->routes->add_route('get', 'custom-font-css', [$this, 'getCustomFontCSS']);
  }

  /**
   * Custom Font CSS loading style content
   * @see ControlFontFamily
   */
  public function getCustomFontCSS($data) {

    if ( !isset( $data['id'] ) ) {
      return new \WP_Error( 'cornerstone', 'ID missing' );
    }

    $id = $data['id'];

    $customFonts = $this->globalFonts->get_font_config()['customFontItems'];

    foreach ($customFonts as $font) {
      if ($font['_id'] !== $id) {
        continue;
      }

      // Load CSS
      $config = $this->globalFonts->getCustomFontConfig();
      $css = $this->globalFonts->make_custom_font_css($font, $config);

      return [ 'css' => $css ];
    }

    throw new DomainException('Could not load Custom Font CSS for ID : ' . $id);
  }
}