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/self/cwd/wp-content/plugins/cornerstone/includes/integration/Twig/src/DCToTwigGrabber.php
<?php

namespace Cornerstone\TwigIntegration;

/**
 * Turns a standard DC group.field grab in twig
 * into a dynamic __call based the internal Dynamic Content filters
 */

class DCToTwigGrabber {
  private $group = null;

  public function __construct($_group = null)
  {
    $this->group = $_group;
  }

  public function __call($field = '', $args = [])
  {
    // No group set this is a {{dc.*}} call
    // Return another twig grabber
    if ($this->group === null) {
      return new DCToTwigGrabber($field);
    }

    // The PHP args are sent individually
    // We are only expecting one arg sent as 'JSON'
    // in twig
    if (isset($args[0])) {
      $args = $args[0];
    }

    // Run Dynamic content filters
    $result = apply_filters( "cs_dynamic_content_{$this->group}", '', $field, $args );
    $result = apply_filters( "cs_dynamic_content_{$this->group}_{$field}", $result, $args );

    return $result;
  }

  public function __toString()
  {
    return "dc." . $this->group;
  }
}