if ( $screen instanceof WP_Screen && in_array( $screen->id, [ 'plugin-install', 'plugin-install-network' ], true ) ) { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); } add_filter( 'install_plugins_tabs', [ $this, 'add_tab' ] ); add_filter( 'install_plugins_table_api_args_' . self::AMP_COMPATIBLE, [ $this, 'filter_plugins_table_api_args' ] ); add_filter( 'plugins_api', [ $this, 'filter_plugins_api' ], 10, 3 ); add_filter( 'plugin_install_action_links', [ $this, 'filter_action_links' ], 10, 2 ); add_filter( 'plugin_row_meta', [ $this, 'filter_plugin_row_meta' ], 10, 3 ); add_action( 'install_plugins_' . self::AMP_COMPATIBLE, 'display_plugins_table' ); } /** * Enqueue style for plugin install page. * * @return void */ public function enqueue_scripts() { $asset_file = AMP__DIR__ . '/assets/js/' . self::ASSET_HANDLE . '.asset.php'; $asset = require $asset_file; $dependencies = $asset['dependencies']; $version = $asset['version']; wp_enqueue_script( self::ASSET_HANDLE, amp_get_asset_url( 'js/' . self::ASSET_HANDLE . '.js' ), $dependencies, $version, true ); wp_enqueue_style( 'amp-admin', amp_get_asset_url( 'css/amp-admin.css' ), [], AMP__VERSION ); $js_data = [ 'AMP_COMPATIBLE' => self::AMP_COMPATIBLE, 'AMP_PLUGINS' => wp_list_pluck( $this->get_plugins(), 'slug' ), ]; wp_add_inline_script( self::ASSET_HANDLE, sprintf( 'var ampPlugins = %s;', wp_json_encode( $js_data ) ), 'before' ); } /** * Add extra tab in plugin install screen. * * @param array $tabs List of tab in plugin install screen. * * @return array List of tab in plugin install screen. */ public function add_tab( $tabs ) { return array_merge( $tabs, [ self::AMP_COMPATIBLE => esc_html__( 'AMP Compatible', 'amp' ), ] ); } /** * Modify args for the plugins_api query on the AMP-compatible tab in plugin install screen. * * @return array */ public function filter_plugins_table_api_args() { $per_page = 36; $total_page = ceil( count( $this->get_plugins() ) / $per_page ); $pagenum = isset( $_REQUEST['paged'] ) ? (int) $_REQUEST['paged'] : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $pagenum = ( $pagenum > $total_page ) ? $total_page : $pagenum; $page = max( 1, $pagenum ); return [ self::AMP_COMPATIBLE => true, 'per_page' => $per_page, 'page' => $page, ]; } /** * Filter the response of API call to wordpress.org for plugin data. * * @param bool|array|stdClass $response List of AMP compatible plugins. * @param string $action API Action. * @param array $args Args for plugin list. * * @return stdClass|array List of AMP compatible plugins. */ public function filter_plugins_api( $response, /** @noinspection PhpUnusedParameterInspection */ $action, $args ) { $args = (array) $args; if ( ! isset( $args[ self::AMP_COMPATIBLE ] ) ) { return $response; } $page = ( ! empty( $args['page'] ) && 0 < (int) $args['page'] ) ? (int) $args['page'] : 1; $plugins = $this->get_plugins(); $plugins_count = count( $plugins ); $plugins_chunks = array_chunk( $plugins, $args['per_page'] ); $plugins_chunk = ( ! empty( $plugins_chunks[ $page - 1 ] ) && is_array( $plugins_chunks[ $page - 1 ] ) ) ? $plugins_chunks[ $page - 1 ] : []; $response = new stdClass(); $response->plugins = $plugins_chunk; $response->info = [ 'page' => $page, 'pages' => count( $plugins_chunks ), 'results' => $plugins_count, ]; return $response; } /** * Update action links for plugin card in plugin install screen. * * @param array $actions List of action button's markup for plugin card. * @param array $plugin Plugin detail. * * @return array List of action button's markup for plugin card. */ public function filter_action_links( $actions, $plugin ) { if ( isset( $plugin['wporg'] ) && true !== $plugin['wporg'] ) { $actions = []; $external_icon = ''; if ( ! empty( $plugin['homepage'] ) ) { $actions[] = sprintf( '%s%s%s', esc_url( $plugin['homepage'] ), esc_attr( /* translators: %s: Plugin name */ sprintf( __( 'Site link of %s', 'amp' ), $plugin['name'] ) ), esc_html__( 'Visit site', 'amp' ), esc_html__( '(opens in a new tab)', 'amp' ), $external_icon ); } } return $actions; } /** * Add plugin metadata for AMP compatibility in plugin listing page. * * @param string[] $plugin_meta An array of the plugin's metadata, including * the version, author, author URI, and plugin URI. * @param string $plugin_file Path to the plugin file relative to the plugins directory. * @param array $plugin_data An array of plugin data. * * @return string[] An array of the plugin's metadata */ public function filter_plugin_row_meta( $plugin_meta, /** @noinspection PhpUnusedParameterInspection */ $plugin_file, $plugin_data ) { $amp_plugins = wp_list_pluck( $this->get_plugins(), 'slug' ); if ( ! empty( $plugin_data['slug'] ) && in_array( $plugin_data['slug'], $amp_plugins, true ) ) { $plugin_meta[] = esc_html__( 'AMP Compatible', 'amp' ); } return $plugin_meta; } } if ( $screen instanceof WP_Screen && in_array( $screen->id, [ 'plugin-install', 'plugin-install-network' ], true ) ) { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); } add_filter( 'install_plugins_tabs', [ $this, 'add_tab' ] ); add_filter( 'install_plugins_table_api_args_' . self::AMP_COMPATIBLE, [ $this, 'filter_plugins_table_api_args' ] ); add_filter( 'plugins_api', [ $this, 'filter_plugins_api' ], 10, 3 ); add_filter( 'plugin_install_action_links', [ $this, 'filter_action_links' ], 10, 2 ); add_filter( 'plugin_row_meta', [ $this, 'filter_plugin_row_meta' ], 10, 3 ); add_action( 'install_plugins_' . self::AMP_COMPATIBLE, 'display_plugins_table' ); } /** * Enqueue style for plugin install page. * * @return void */ public function enqueue_scripts() { $asset_file = AMP__DIR__ . '/assets/js/' . self::ASSET_HANDLE . '.asset.php'; $asset = require $asset_file; $dependencies = $asset['dependencies']; $version = $asset['version']; wp_enqueue_script( self::ASSET_HANDLE, amp_get_asset_url( 'js/' . self::ASSET_HANDLE . '.js' ), $dependencies, $version, true ); wp_enqueue_style( 'amp-admin', amp_get_asset_url( 'css/amp-admin.css' ), [], AMP__VERSION ); $js_data = [ 'AMP_COMPATIBLE' => self::AMP_COMPATIBLE, 'AMP_PLUGINS' => wp_list_pluck( $this->get_plugins(), 'slug' ), ]; wp_add_inline_script( self::ASSET_HANDLE, sprintf( 'var ampPlugins = %s;', wp_json_encode( $js_data ) ), 'before' ); } /** * Add extra tab in plugin install screen. * * @param array $tabs List of tab in plugin install screen. * * @return array List of tab in plugin install screen. */ public function add_tab( $tabs ) { return array_merge( $tabs, [ self::AMP_COMPATIBLE => esc_html__( 'AMP Compatible', 'amp' ), ] ); } /** * Modify args for the plugins_api query on the AMP-compatible tab in plugin install screen. * * @return array */ public function filter_plugins_table_api_args() { $per_page = 36; $total_page = ceil( count( $this->get_plugins() ) / $per_page ); $pagenum = isset( $_REQUEST['paged'] ) ? (int) $_REQUEST['paged'] : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $pagenum = ( $pagenum > $total_page ) ? $total_page : $pagenum; $page = max( 1, $pagenum ); return [ self::AMP_COMPATIBLE => true, 'per_page' => $per_page, 'page' => $page, ]; } /** * Filter the response of API call to wordpress.org for plugin data. * * @param bool|array|stdClass $response List of AMP compatible plugins. * @param string $action API Action. * @param array $args Args for plugin list. * * @return stdClass|array List of AMP compatible plugins. */ public function filter_plugins_api( $response, /** @noinspection PhpUnusedParameterInspection */ $action, $args ) { $args = (array) $args; if ( ! isset( $args[ self::AMP_COMPATIBLE ] ) ) { return $response; } $page = ( ! empty( $args['page'] ) && 0 < (int) $args['page'] ) ? (int) $args['page'] : 1; $plugins = $this->get_plugins(); $plugins_count = count( $plugins ); $plugins_chunks = array_chunk( $plugins, $args['per_page'] ); $plugins_chunk = ( ! empty( $plugins_chunks[ $page - 1 ] ) && is_array( $plugins_chunks[ $page - 1 ] ) ) ? $plugins_chunks[ $page - 1 ] : []; $response = new stdClass(); $response->plugins = $plugins_chunk; $response->info = [ 'page' => $page, 'pages' => count( $plugins_chunks ), 'results' => $plugins_count, ]; return $response; } /** * Update action links for plugin card in plugin install screen. * * @param array $actions List of action button's markup for plugin card. * @param array $plugin Plugin detail. * * @return array List of action button's markup for plugin card. */ public function filter_action_links( $actions, $plugin ) { if ( isset( $plugin['wporg'] ) && true !== $plugin['wporg'] ) { $actions = []; $external_icon = ''; if ( ! empty( $plugin['homepage'] ) ) { $actions[] = sprintf( '%s%s%s', esc_url( $plugin['homepage'] ), esc_attr( /* translators: %s: Plugin name */ sprintf( __( 'Site link of %s', 'amp' ), $plugin['name'] ) ), esc_html__( 'Visit site', 'amp' ), esc_html__( '(opens in a new tab)', 'amp' ), $external_icon ); } } return $actions; } /** * Add plugin metadata for AMP compatibility in plugin listing page. * * @param string[] $plugin_meta An array of the plugin's metadata, including * the version, author, author URI, and plugin URI. * @param string $plugin_file Path to the plugin file relative to the plugins directory. * @param array $plugin_data An array of plugin data. * * @return string[] An array of the plugin's metadata */ public function filter_plugin_row_meta( $plugin_meta, /** @noinspection PhpUnusedParameterInspection */ $plugin_file, $plugin_data ) { $amp_plugins = wp_list_pluck( $this->get_plugins(), 'slug' ); if ( ! empty( $plugin_data['slug'] ) && in_array( $plugin_data['slug'], $amp_plugins, true ) ) { $plugin_meta[] = esc_html__( 'AMP Compatible', 'amp' ); } return $plugin_meta; } } if ( $screen instanceof WP_Screen && in_array( $screen->id, [ 'plugin-install', 'plugin-install-network' ], true ) ) { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); } add_filter( 'install_plugins_tabs', [ $this, 'add_tab' ] ); add_filter( 'install_plugins_table_api_args_' . self::AMP_COMPATIBLE, [ $this, 'filter_plugins_table_api_args' ] ); add_filter( 'plugins_api', [ $this, 'filter_plugins_api' ], 10, 3 ); add_filter( 'plugin_install_action_links', [ $this, 'filter_action_links' ], 10, 2 ); add_filter( 'plugin_row_meta', [ $this, 'filter_plugin_row_meta' ], 10, 3 ); add_action( 'install_plugins_' . self::AMP_COMPATIBLE, 'display_plugins_table' ); } /** * Enqueue style for plugin install page. * * @return void */ public function enqueue_scripts() { $asset_file = AMP__DIR__ . '/assets/js/' . self::ASSET_HANDLE . '.asset.php'; $asset = require $asset_file; $dependencies = $asset['dependencies']; $version = $asset['version']; wp_enqueue_script( self::ASSET_HANDLE, amp_get_asset_url( 'js/' . self::ASSET_HANDLE . '.js' ), $dependencies, $version, true ); wp_enqueue_style( 'amp-admin', amp_get_asset_url( 'css/amp-admin.css' ), [], AMP__VERSION ); $js_data = [ 'AMP_COMPATIBLE' => self::AMP_COMPATIBLE, 'AMP_PLUGINS' => wp_list_pluck( $this->get_plugins(), 'slug' ), ]; wp_add_inline_script( self::ASSET_HANDLE, sprintf( 'var ampPlugins = %s;', wp_json_encode( $js_data ) ), 'before' ); } /** * Add extra tab in plugin install screen. * * @param array $tabs List of tab in plugin install screen. * * @return array List of tab in plugin install screen. */ public function add_tab( $tabs ) { return array_merge( $tabs, [ self::AMP_COMPATIBLE => esc_html__( 'AMP Compatible', 'amp' ), ] ); } /** * Modify args for the plugins_api query on the AMP-compatible tab in plugin install screen. * * @return array */ public function filter_plugins_table_api_args() { $per_page = 36; $total_page = ceil( count( $this->get_plugins() ) / $per_page ); $pagenum = isset( $_REQUEST['paged'] ) ? (int) $_REQUEST['paged'] : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $pagenum = ( $pagenum > $total_page ) ? $total_page : $pagenum; $page = max( 1, $pagenum ); return [ self::AMP_COMPATIBLE => true, 'per_page' => $per_page, 'page' => $page, ]; } /** * Filter the response of API call to wordpress.org for plugin data. * * @param bool|array|stdClass $response List of AMP compatible plugins. * @param string $action API Action. * @param array $args Args for plugin list. * * @return stdClass|array List of AMP compatible plugins. */ public function filter_plugins_api( $response, /** @noinspection PhpUnusedParameterInspection */ $action, $args ) { $args = (array) $args; if ( ! isset( $args[ self::AMP_COMPATIBLE ] ) ) { return $response; } $page = ( ! empty( $args['page'] ) && 0 < (int) $args['page'] ) ? (int) $args['page'] : 1; $plugins = $this->get_plugins(); $plugins_count = count( $plugins ); $plugins_chunks = array_chunk( $plugins, $args['per_page'] ); $plugins_chunk = ( ! empty( $plugins_chunks[ $page - 1 ] ) && is_array( $plugins_chunks[ $page - 1 ] ) ) ? $plugins_chunks[ $page - 1 ] : []; $response = new stdClass(); $response->plugins = $plugins_chunk; $response->info = [ 'page' => $page, 'pages' => count( $plugins_chunks ), 'results' => $plugins_count, ]; return $response; } /** * Update action links for plugin card in plugin install screen. * * @param array $actions List of action button's markup for plugin card. * @param array $plugin Plugin detail. * * @return array List of action button's markup for plugin card. */ public function filter_action_links( $actions, $plugin ) { if ( isset( $plugin['wporg'] ) && true !== $plugin['wporg'] ) { $actions = []; $external_icon = ''; if ( ! empty( $plugin['homepage'] ) ) { $actions[] = sprintf( '%s%s%s', esc_url( $plugin['homepage'] ), esc_attr( /* translators: %s: Plugin name */ sprintf( __( 'Site link of %s', 'amp' ), $plugin['name'] ) ), esc_html__( 'Visit site', 'amp' ), esc_html__( '(opens in a new tab)', 'amp' ), $external_icon ); } } return $actions; } /** * Add plugin metadata for AMP compatibility in plugin listing page. * * @param string[] $plugin_meta An array of the plugin's metadata, including * the version, author, author URI, and plugin URI. * @param string $plugin_file Path to the plugin file relative to the plugins directory. * @param array $plugin_data An array of plugin data. * * @return string[] An array of the plugin's metadata */ public function filter_plugin_row_meta( $plugin_meta, /** @noinspection PhpUnusedParameterInspection */ $plugin_file, $plugin_data ) { $amp_plugins = wp_list_pluck( $this->get_plugins(), 'slug' ); if ( ! empty( $plugin_data['slug'] ) && in_array( $plugin_data['slug'], $amp_plugins, true ) ) { $plugin_meta[] = esc_html__( 'AMP Compatible', 'amp' ); } return $plugin_meta; } } if ( $screen instanceof WP_Screen && in_array( $screen->id, [ 'plugin-install', 'plugin-install-network' ], true ) ) { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); } add_filter( 'install_plugins_tabs', [ $this, 'add_tab' ] ); add_filter( 'install_plugins_table_api_args_' . self::AMP_COMPATIBLE, [ $this, 'filter_plugins_table_api_args' ] ); add_filter( 'plugins_api', [ $this, 'filter_plugins_api' ], 10, 3 ); add_filter( 'plugin_install_action_links', [ $this, 'filter_action_links' ], 10, 2 ); add_filter( 'plugin_row_meta', [ $this, 'filter_plugin_row_meta' ], 10, 3 ); add_action( 'install_plugins_' . self::AMP_COMPATIBLE, 'display_plugins_table' ); } /** * Enqueue style for plugin install page. * * @return void */ public function enqueue_scripts() { $asset_file = AMP__DIR__ . '/assets/js/' . self::ASSET_HANDLE . '.asset.php'; $asset = require $asset_file; $dependencies = $asset['dependencies']; $version = $asset['version']; wp_enqueue_script( self::ASSET_HANDLE, amp_get_asset_url( 'js/' . self::ASSET_HANDLE . '.js' ), $dependencies, $version, true ); wp_enqueue_style( 'amp-admin', amp_get_asset_url( 'css/amp-admin.css' ), [], AMP__VERSION ); $js_data = [ 'AMP_COMPATIBLE' => self::AMP_COMPATIBLE, 'AMP_PLUGINS' => wp_list_pluck( $this->get_plugins(), 'slug' ), ]; wp_add_inline_script( self::ASSET_HANDLE, sprintf( 'var ampPlugins = %s;', wp_json_encode( $js_data ) ), 'before' ); } /** * Add extra tab in plugin install screen. * * @param array $tabs List of tab in plugin install screen. * * @return array List of tab in plugin install screen. */ public function add_tab( $tabs ) { return array_merge( $tabs, [ self::AMP_COMPATIBLE => esc_html__( 'AMP Compatible', 'amp' ), ] ); } /** * Modify args for the plugins_api query on the AMP-compatible tab in plugin install screen. * * @return array */ public function filter_plugins_table_api_args() { $per_page = 36; $total_page = ceil( count( $this->get_plugins() ) / $per_page ); $pagenum = isset( $_REQUEST['paged'] ) ? (int) $_REQUEST['paged'] : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $pagenum = ( $pagenum > $total_page ) ? $total_page : $pagenum; $page = max( 1, $pagenum ); return [ self::AMP_COMPATIBLE => true, 'per_page' => $per_page, 'page' => $page, ]; } /** * Filter the response of API call to wordpress.org for plugin data. * * @param bool|array|stdClass $response List of AMP compatible plugins. * @param string $action API Action. * @param array $args Args for plugin list. * * @return stdClass|array List of AMP compatible plugins. */ public function filter_plugins_api( $response, /** @noinspection PhpUnusedParameterInspection */ $action, $args ) { $args = (array) $args; if ( ! isset( $args[ self::AMP_COMPATIBLE ] ) ) { return $response; } $page = ( ! empty( $args['page'] ) && 0 < (int) $args['page'] ) ? (int) $args['page'] : 1; $plugins = $this->get_plugins(); $plugins_count = count( $plugins ); $plugins_chunks = array_chunk( $plugins, $args['per_page'] ); $plugins_chunk = ( ! empty( $plugins_chunks[ $page - 1 ] ) && is_array( $plugins_chunks[ $page - 1 ] ) ) ? $plugins_chunks[ $page - 1 ] : []; $response = new stdClass(); $response->plugins = $plugins_chunk; $response->info = [ 'page' => $page, 'pages' => count( $plugins_chunks ), 'results' => $plugins_count, ]; return $response; } /** * Update action links for plugin card in plugin install screen. * * @param array $actions List of action button's markup for plugin card. * @param array $plugin Plugin detail. * * @return array List of action button's markup for plugin card. */ public function filter_action_links( $actions, $plugin ) { if ( isset( $plugin['wporg'] ) && true !== $plugin['wporg'] ) { $actions = []; $external_icon = ''; if ( ! empty( $plugin['homepage'] ) ) { $actions[] = sprintf( '%s%s%s', esc_url( $plugin['homepage'] ), esc_attr( /* translators: %s: Plugin name */ sprintf( __( 'Site link of %s', 'amp' ), $plugin['name'] ) ), esc_html__( 'Visit site', 'amp' ), esc_html__( '(opens in a new tab)', 'amp' ), $external_icon ); } } return $actions; } /** * Add plugin metadata for AMP compatibility in plugin listing page. * * @param string[] $plugin_meta An array of the plugin's metadata, including * the version, author, author URI, and plugin URI. * @param string $plugin_file Path to the plugin file relative to the plugins directory. * @param array $plugin_data An array of plugin data. * * @return string[] An array of the plugin's metadata */ public function filter_plugin_row_meta( $plugin_meta, /** @noinspection PhpUnusedParameterInspection */ $plugin_file, $plugin_data ) { $amp_plugins = wp_list_pluck( $this->get_plugins(), 'slug' ); if ( ! empty( $plugin_data['slug'] ) && in_array( $plugin_data['slug'], $amp_plugins, true ) ) { $plugin_meta[] = esc_html__( 'AMP Compatible', 'amp' ); } return $plugin_meta; } } tbox_title_src ]; } if ( $lightbox_description_src && $image_data[ $lightbox_description_src ] ) { $attributes['description'] = $image_data[ $lightbox_description_src ]; } } return $attributes; } private function delete_custom_images( $post_id ) { $image_meta = wp_get_attachment_metadata( $post_id ); if ( ! empty( $image_meta ) && ! empty( $image_meta['sizes'] ) ) { ( new Collection( $image_meta['sizes'] ) ) ->filter( function ( $value, $key ) { return ( 0 === strpos( $key, 'elementor_custom_' ) ); } ) ->pluck( 'file' ) ->each( function ( $path ) { $base_dir = wp_get_upload_dir()['basedir']; wp_delete_file( $base_dir . '/' . $path ); } ); } } /** * Images manager constructor. * * Initializing Elementor images manager. * * @since 1.0.0 * @access public */ public function __construct() { add_action( 'wp_ajax_elementor_get_images_details', [ $this, 'get_images_details' ] ); // Delete elementor thumbnail files on deleting its main image. add_action( 'delete_attachment', function ( $post_id ) { $this->delete_custom_images( $post_id ); } ); } }
Fatal error: Uncaught Error: Class "Elementor\Images_Manager" not found in /htdocs/wp-content/plugins/elementor/includes/plugin.php:760 Stack trace: #0 /htdocs/wp-content/plugins/elementor/includes/plugin.php(673): Elementor\Plugin->init_components() #1 /htdocs/wp-includes/class-wp-hook.php(341): Elementor\Plugin->init('') #2 /htdocs/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(NULL, Array) #3 /htdocs/wp-includes/plugin.php(522): WP_Hook->do_action(Array) #4 /htdocs/wp-settings.php(742): do_action('init') #5 /htdocs/wp-config.php(82): require_once('/htdocs/wp-sett...') #6 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #7 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #8 /htdocs/index.php(17): require('/htdocs/wp-blog...') #9 {main} thrown in /htdocs/wp-content/plugins/elementor/includes/plugin.php on line 760