| 1 |
<?php |
| 2 |
namespace Elementor\Modules\System_Info\Reporters; |
| 3 |
|
| 4 |
use Elementor\Utils; |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly. |
| 8 |
} |
| 9 |
|
| 10 |
abstract class Base_Plugin extends Base { |
| 11 |
public static $required_plugins_properties = [ |
| 12 |
'Name', |
| 13 |
'Version', |
| 14 |
'URL', |
| 15 |
'Author', |
| 16 |
]; |
| 17 |
|
| 18 |
public function print_html() { |
| 19 |
foreach ( $this->get_report( 'html' ) as $field ) { |
| 20 |
foreach ( $field['value'] as $plugin_info ) : |
| 21 |
?> |
| 22 |
<tr> |
| 23 |
<td><?php |
| 24 |
if ( $plugin_info['PluginURI'] ) : |
| 25 |
$plugin_name = sprintf( '<a href="%s">%s</a>', $plugin_info['PluginURI'], $plugin_info['Name'] ); |
| 26 |
else : |
| 27 |
$plugin_name = $plugin_info['Name']; |
| 28 |
endif; |
| 29 |
|
| 30 |
if ( $plugin_info['Version'] ) : |
| 31 |
$plugin_name .= ' - ' . $plugin_info['Version']; |
| 32 |
endif; |
| 33 |
|
| 34 |
Utils::print_unescaped_internal_string( $plugin_name ); |
| 35 |
?></td> |
| 36 |
<td><?php |
| 37 |
if ( $plugin_info['Author'] ) : |
| 38 |
if ( $plugin_info['AuthorURI'] ) : |
| 39 |
$author = sprintf( '<a href="%s">%s</a>', $plugin_info['AuthorURI'], $plugin_info['Author'] ); |
| 40 |
else : |
| 41 |
$author = $plugin_info['Author']; |
| 42 |
endif; |
| 43 |
|
| 44 |
Utils::print_unescaped_internal_string( "By $author" ); |
| 45 |
endif; |
| 46 |
?></td> |
| 47 |
<td></td> |
| 48 |
</tr> |
| 49 |
<?php |
| 50 |
endforeach; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
public function print_raw( $tabs_count ) { |
| 55 |
echo PHP_EOL; |
| 56 |
|
| 57 |
$required_plugins_properties = array_flip( self::$required_plugins_properties ); |
| 58 |
|
| 59 |
unset( $required_plugins_properties['Name'] ); |
| 60 |
|
| 61 |
foreach ( $this->get_report( 'raw' ) as $field_name => $field ) : |
| 62 |
$sub_indent = str_repeat( "\t", $tabs_count ); |
| 63 |
|
| 64 |
echo "== {$field['label']} ==" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 65 |
|
| 66 |
foreach ( $field['value'] as $plugin_info ) : |
| 67 |
$plugin_properties = array_intersect_key( $plugin_info, $required_plugins_properties ); |
| 68 |
|
| 69 |
echo esc_html( $sub_indent . $plugin_info['Name'] ); |
| 70 |
|
| 71 |
foreach ( $plugin_properties as $property_name => $property ) : |
| 72 |
echo PHP_EOL . "{$sub_indent}\t{$property_name}: {$property}"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 73 |
endforeach; |
| 74 |
|
| 75 |
echo PHP_EOL . PHP_EOL; |
| 76 |
endforeach; |
| 77 |
endforeach; |
| 78 |
} |
| 79 |
} |
| 80 |
|