Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/elemento.../modules/apps
File: admin-apps-page.php
<?php
[0] Fix | Delete
namespace Elementor\Modules\Apps;
[1] Fix | Delete
[2] Fix | Delete
use Elementor\Core\Isolation\Wordpress_Adapter;
[3] Fix | Delete
use Elementor\Core\Isolation\Plugin_Status_Adapter;
[4] Fix | Delete
[5] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[6] Fix | Delete
exit; // Exit if accessed directly.
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
class Admin_Apps_Page {
[10] Fix | Delete
[11] Fix | Delete
const APPS_URL = 'https://assets.elementor.com/apps/v1/apps.json';
[12] Fix | Delete
[13] Fix | Delete
private static ?Wordpress_Adapter $wordpress_adapter = null;
[14] Fix | Delete
[15] Fix | Delete
private static ?Plugin_Status_Adapter $plugin_status_adapter = null;
[16] Fix | Delete
[17] Fix | Delete
public static function render() {
[18] Fix | Delete
?>
[19] Fix | Delete
<div class="wrap e-a-apps">
[20] Fix | Delete
[21] Fix | Delete
<div class="e-a-page-title">
[22] Fix | Delete
<h2><?php echo esc_html__( 'Popular Add-ons, New Possibilities.', 'elementor' ); ?></h2>
[23] Fix | Delete
<p><?php echo esc_html__( 'Boost your web-creation process with add-ons, plugins, and more tools specially selected to unleash your creativity, increase productivity, and enhance your Elementor-powered website.', 'elementor' ); ?>*<br>
[24] Fix | Delete
<a href="https://go.elementor.com/wp-dash-apps-about-apps-page/" target="_blank"><?php echo esc_html__( 'Learn more about this page.', 'elementor' ); ?></a>
[25] Fix | Delete
</p>
[26] Fix | Delete
</div>
[27] Fix | Delete
[28] Fix | Delete
<div class="e-a-list">
[29] Fix | Delete
<?php self::render_plugins_list(); ?>
[30] Fix | Delete
</div>
[31] Fix | Delete
<div class="e-a-page-footer">
[32] Fix | Delete
<p>*<?php echo esc_html__( 'Please note that certain tools and services on this page are developed by third-party companies and are not part of Elementor\'s suite of products or support. Before using them, we recommend independently evaluating them. Additionally, when clicking on their action buttons, you may be redirected to an external website.', 'elementor' ); ?></p>
[33] Fix | Delete
</div>
[34] Fix | Delete
</div>
[35] Fix | Delete
<?php
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
private static function render_plugins_list() {
[39] Fix | Delete
$plugins = self::get_plugins();
[40] Fix | Delete
[41] Fix | Delete
foreach ( $plugins as $plugin ) {
[42] Fix | Delete
self::render_plugin_item( $plugin );
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
private static function get_plugins(): array {
[47] Fix | Delete
if ( ! self::$wordpress_adapter ) {
[48] Fix | Delete
self::$wordpress_adapter = new Wordpress_Adapter();
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
if ( ! self::$plugin_status_adapter ) {
[52] Fix | Delete
self::$plugin_status_adapter = new Plugin_Status_Adapter( self::$wordpress_adapter );
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
$apps = static::get_remote_apps();
[56] Fix | Delete
[57] Fix | Delete
return static::filter_apps( $apps );
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
private static function get_remote_apps() {
[61] Fix | Delete
$apps = wp_remote_get( static::APPS_URL );
[62] Fix | Delete
[63] Fix | Delete
if ( is_wp_error( $apps ) ) {
[64] Fix | Delete
return [];
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
$apps = json_decode( wp_remote_retrieve_body( $apps ), true );
[68] Fix | Delete
[69] Fix | Delete
if ( empty( $apps['apps'] ) || ! is_array( $apps['apps'] ) ) {
[70] Fix | Delete
return [];
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
return $apps['apps'];
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
private static function filter_apps( $apps ) {
[77] Fix | Delete
$filtered_apps = [];
[78] Fix | Delete
[79] Fix | Delete
foreach ( $apps as $app ) {
[80] Fix | Delete
if ( static::is_wporg_app( $app ) ) {
[81] Fix | Delete
$app = static::filter_wporg_app( $app );
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
if ( static::is_ecom_app( $app ) ) {
[85] Fix | Delete
$app = static::filter_ecom_app( $app );
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
if ( empty( $app ) ) {
[89] Fix | Delete
continue;
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
$filtered_apps[] = $app;
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
return $filtered_apps;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
private static function is_wporg_app( $app ) {
[99] Fix | Delete
return isset( $app['type'] ) && 'wporg' === $app['type'];
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
private static function filter_wporg_app( $app ) {
[103] Fix | Delete
if ( self::$wordpress_adapter->is_plugin_active( $app['file_path'] ) ) {
[104] Fix | Delete
return null;
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
if ( self::$plugin_status_adapter->is_plugin_installed( $app['file_path'] ) ) {
[108] Fix | Delete
if ( current_user_can( 'activate_plugins' ) ) {
[109] Fix | Delete
$app['action_label'] = esc_html__( 'Activate', 'elementor' );
[110] Fix | Delete
$app['action_url'] = self::$plugin_status_adapter->get_activate_plugin_url( $app['file_path'] );
[111] Fix | Delete
} else {
[112] Fix | Delete
$app['action_label'] = esc_html__( 'Cannot Activate', 'elementor' );
[113] Fix | Delete
$app['action_url'] = '#';
[114] Fix | Delete
}
[115] Fix | Delete
} elseif ( current_user_can( 'install_plugins' ) ) {
[116] Fix | Delete
$app['action_label'] = esc_html__( 'Install', 'elementor' );
[117] Fix | Delete
$app['action_url'] = self::$plugin_status_adapter->get_install_plugin_url( $app['file_path'] );
[118] Fix | Delete
} else {
[119] Fix | Delete
$app['action_label'] = esc_html__( 'Cannot Install', 'elementor' );
[120] Fix | Delete
$app['action_url'] = '#';
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
return $app;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
private static function is_ecom_app( $app ) {
[127] Fix | Delete
return isset( $app['type'] ) && 'ecom' === $app['type'];
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
private static function filter_ecom_app( $app ) {
[131] Fix | Delete
if ( self::$wordpress_adapter->is_plugin_active( $app['file_path'] ) ) {
[132] Fix | Delete
return null;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
if ( ! self::$plugin_status_adapter->is_plugin_installed( $app['file_path'] ) ) {
[136] Fix | Delete
return $app;
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
if ( current_user_can( 'activate_plugins' ) ) {
[140] Fix | Delete
$app['action_label'] = esc_html__( 'Activate', 'elementor' );
[141] Fix | Delete
$app['action_url'] = self::$plugin_status_adapter->get_activate_plugin_url( $app['file_path'] );
[142] Fix | Delete
} else {
[143] Fix | Delete
$app['action_label'] = esc_html__( 'Cannot Activate', 'elementor' );
[144] Fix | Delete
$app['action_url'] = '#';
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
$app['target'] = '_self';
[148] Fix | Delete
[149] Fix | Delete
return $app;
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
private static function get_images_url() {
[153] Fix | Delete
return ELEMENTOR_URL . 'modules/apps/images/';
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
private static function is_elementor_pro_installed() {
[157] Fix | Delete
return defined( 'ELEMENTOR_PRO_VERSION' );
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
private static function render_plugin_item( $plugin ) {
[161] Fix | Delete
?>
[162] Fix | Delete
<div class="e-a-item"<?php echo ! empty( $plugin['file_path'] ) ? ' data-plugin="' . esc_attr( $plugin['file_path'] ) . '"' : ''; ?>>
[163] Fix | Delete
<div class="e-a-heading">
[164] Fix | Delete
<img class="e-a-img" src="<?php echo esc_url( $plugin['image'] ); ?>" alt="<?php echo esc_attr( $plugin['name'] ); ?>">
[165] Fix | Delete
<?php if ( ! empty( $plugin['badge'] ) ) : ?>
[166] Fix | Delete
<span class="e-a-badge"><?php echo esc_html( $plugin['badge'] ); ?></span>
[167] Fix | Delete
<?php endif; ?>
[168] Fix | Delete
</div>
[169] Fix | Delete
<h3 class="e-a-title"><?php echo esc_html( $plugin['name'] ); ?></h3>
[170] Fix | Delete
<p class="e-a-author"><?php esc_html_e( 'By', 'elementor' ); ?> <a href="<?php echo esc_url( $plugin['author_url'] ); ?>" target="_blank"><?php echo esc_html( $plugin['author'] ); ?></a></p>
[171] Fix | Delete
<div class="e-a-desc">
[172] Fix | Delete
<p><?php echo esc_html( $plugin['description'] ); ?></p>
[173] Fix | Delete
<?php if ( ! empty( $plugin['offering'] ) ) : ?>
[174] Fix | Delete
<p class="e-a-offering"><?php echo esc_html( $plugin['offering'] ); ?></p>
[175] Fix | Delete
<?php endif; ?>
[176] Fix | Delete
</div>
[177] Fix | Delete
[178] Fix | Delete
<p class="e-a-actions">
[179] Fix | Delete
<?php if ( ! empty( $plugin['learn_more_url'] ) ) : ?>
[180] Fix | Delete
<a class="e-a-learn-more" href="<?php echo esc_url( $plugin['learn_more_url'] ); ?>" target="_blank"><?php echo esc_html__( 'Learn More', 'elementor' ); ?></a>
[181] Fix | Delete
<?php endif; ?>
[182] Fix | Delete
<a href="<?php echo esc_url( $plugin['action_url'] ); ?>" class="e-btn e-accent" target="<?php echo isset( $plugin['target'] ) ? esc_attr( $plugin['target'] ) : '_blank'; ?>"><?php echo esc_html( $plugin['action_label'] ); ?></a>
[183] Fix | Delete
</p>
[184] Fix | Delete
</div>
[185] Fix | Delete
<?php
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function