<commit_before><?php

// Exit if accessed directly
if (!defined('ABSPATH')) exit;

/**
 * Page Type Builder Property class.
 */

abstract class PTB_Property {

  /**
   * Page Type Builder properties array.
   *
   * @var array
   * @since 1.0
   * @access private
   */

  private static $properties = array(
    'PropertyString',
    'PropertyBoolean',
    'PropertyEmail',
    'PropertyUrl',
    'PropertyNumber',
    'PropertyDate',
    'PropertyDivider',
    'PropertyMap',
    'PropertyText',
    'PropertyImage'
  );

  /**
   * Current property options object that is used to generate a property.
   *
   * @var object
   * @since 1.0
   * @access private
   */

  private $options;

  /**
   * Create a new instance of the given property.
   *
   * @param string $property
   * @since 1.0
   *
   * @throws Exception
   * @return PTB_Property
   */

  public static function factory ($property) {
    self::filter_custom_properties();
    if (in_array($property, self::$properties) && class_exists($property)) {
      $klass = new $property();
      $klass->setup_globals();
      add_action('admin_head', array($klass, 'css'));
      add_action('admin_head', array($klass, 'autocss'));
      add_action('admin_footer', array($klass, 'js'));
      add_action('admin_footer', array($klass, 'autojs'));
      return $klass;
    } else {
      throw new Exception('PTB Error: Unsupported property - ' . $property);
    }
  }

  /**
   * Setup globals.
   *
   * @since 1.0
   * @access private
   */

  private function setup_globals () {
    $this->js_dir = PTB_PLUGIN_DIR . 'gui/js/';
    $this->js_url = PTB_PLUGIN_URL . 'gui/js/';
    $this->css_dir = PTB_PLUGIN_DIR . 'gui/css/';
    $this->css_url = PTB_PLUGIN_URL . 'gui/css/';
  }

  /**
   * Find custom properties that isn't register in this plugin.
   *
   * @since 1.0
   * @access private
   */

  private static function filter_custom_properties () {
    $result = apply_filters('ptb_custom_properties', self::$properties);
    if (is_array($result)) {
      self::$properties = array_filter(array_unique(array_merge(self::$properties, $result)), function ($property) {
        return preg_match('/Property\w+/', $property);
      });
    }
  }

  /**
   * Check if the property exists in the properties array.
   *
   * @param string $property
   * @since 1.0
   *
   * @return bool
   */

  public static function exists ($property) {
    return isset(self::$properties[$property]);<commit_msg>Changed filter ptb_custom_properties to ptb_properties<commit_after><?php

// Exit if accessed directly
if (!defined('ABSPATH')) exit;

/**
 * Page Type Builder Property class.
 */

abstract class PTB_Property {

  /**
   * Page Type Builder properties array.
   *
   * @var array
   * @since 1.0
   * @access private
   */

  private static $properties = array(
    'PropertyString',
    'PropertyBoolean',
    'PropertyEmail',
    'PropertyUrl',
    'PropertyNumber',
    'PropertyDate',
    'PropertyDivider',
    'PropertyMap',
    'PropertyText',
    'PropertyImage'
  );

  /**
   * Current property options object that is used to generate a property.
   *
   * @var object
   * @since 1.0
   * @access private
   */

  private $options;

  /**
   * Create a new instance of the given property.
   *
   * @param string $property
   * @since 1.0
   *
   * @throws Exception
   * @return PTB_Property
   */

  public static function factory ($property) {
    self::filter_custom_properties();
    if (in_array($property, self::$properties) && class_exists($property)) {
      $klass = new $property();
      $klass->setup_globals();
      add_action('admin_head', array($klass, 'css'));
      add_action('admin_head', array($klass, 'autocss'));
      add_action('admin_footer', array($klass, 'js'));
      add_action('admin_footer', array($klass, 'autojs'));
      return $klass;
    } else {
      throw new Exception('PTB Error: Unsupported property - ' . $property);
    }
  }

  /**
   * Setup globals.
   *
   * @since 1.0
   * @access private
   */

  private function setup_globals () {
    $this->js_dir = PTB_PLUGIN_DIR . 'gui/js/';
    $this->js_url = PTB_PLUGIN_URL . 'gui/js/';
    $this->css_dir = PTB_PLUGIN_DIR . 'gui/css/';
    $this->css_url = PTB_PLUGIN_URL . 'gui/css/';
  }

  /**
   * Find custom properties that isn't register in this plugin.
   *
   * @since 1.0
   * @access private
   */

  private static function filter_custom_properties () {
    $result = apply_filters('ptb_properties', self::$properties);
    if (is_array($result)) {
      self::$properties = array_filter(array_unique(array_merge(self::$properties, $result)), function ($property) {
        return preg_match('/Property\w+/', $property);
      });
    }
  }

  /**
   * Check if the property exists in the properties array.
   *
   * @param string $property
   * @since 1.0
   *
   * @return bool
   */

  public static function exists ($property) {
    return isset(self::$properties[$property]);
{'fraction_non_alphanumeric': 0.14619412001610954, 'fraction_numerical': 0.004832863471606927, 'mean_word_length': 2.8956862745098038, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2112483', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1586, 'n_words': 377}