GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
GravityForms.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @license GPL-2.0-or-later
4  *
5  * Modified by gravityview on 13-January-2023 using Strauss.
6  * @see https://github.com/BrianHenryIE/strauss
7  */
8 
10 
14 
15 class GravityForms {
16  /**
17  * @since 1.0.3
18  *
19  * @var GravityForms Class instance.
20  */
21  private static $_instance;
22 
23  private function __construct() {
24  add_filter( 'gform_system_report', [ $this, 'modify_system_report' ] );
25  }
26 
27  /**
28  * Returns class instance.
29  *
30  * @since 1.0.3
31  *
32  * @return GravityForms
33  */
34  public static function get_instance() {
35  if ( ! self::$_instance ) {
36  self::$_instance = new self();
37  }
38 
39  return self::$_instance;
40  }
41 
42  /**
43  * Adds GravityKit products to GF's system report
44  *
45  * @since 1.0.3
46  *
47  * @param array $system_report
48  *
49  * @return array
50  */
51  public function modify_system_report( $system_report ) {
52  if ( ! Arr::get( $system_report, '0.tables' ) ) {
53  return $system_report;
54  }
55 
56  foreach ( $system_report[0]['tables'] as &$table ) {
57  if ( 'Add-Ons' !== Arr::get( $table, 'title_export' ) ) {
58  continue;
59  }
60 
61  $registered_plugins = Core::get_instance()->get_registered_plugins();
62 
63  foreach ( $registered_plugins as $registered_plugin ) {
64  $plugin_data = CoreHelpers::get_plugin_data( $registered_plugin );
65 
66  /**
67  * Controls whether to include a GravityKit product in GF's system report.
68  *
69  * @filter gk/foundation/integrations/gravityforms/add-to-system-report
70  *
71  * @since 1.0.3
72  *
73  * @param bool $include_in_system_report Default: true.
74  * @param string $text_domain Product text domain.
75  */
76  $include_in_system_report = apply_filters( 'gk/foundation/integrations/gravityforms/add-to-system-report', true, Arr::get( $plugin_data, 'TextDomain' ) );
77 
78  if ( ! $include_in_system_report ) {
79  continue;
80  }
81 
82  $author = wp_kses( Arr::get( $plugin_data, 'Author' ), 'post' );
83 
84  $table['items'][] = [
85  'label' => sprintf( '<a href="%s">%s</a>', esc_url( Arr::get( $plugin_data, 'PluginURI', '' ) ), Arr::get( $plugin_data, 'Name' ) ),
86  'label_export' => Arr::get( $plugin_data, 'Name' ),
87  'value' => sprintf( 'by %s - %s', $author, esc_html( Arr::get( $plugin_data, 'Version' ) ) ),
88  'value_export' => sprintf( 'by %s - %s', $author, esc_html( Arr::get( $plugin_data, 'Version' ) ) ),
89  'is_valid' => true, // TODO: Show validation errors if they exist.
90  'validation_message' => '',
91  'validation_message_export' => '',
92  ];
93  }
94  }
95 
96  return $system_report;
97  }
98 }
static get( $array, $key, $default=null)
{}
Definition: Arr.php:99
modify_system_report( $system_report)
Adds GravityKit products to GF&#39;s system report.
static get_instance()
Returns class instance.
Definition: Core.php:182