← All changes
|
includes/template-library/sources/local.php
+8
-20
4.1.0-dev1
→
4.3.0-beta3
View file →
| @@ -14,9 +14,8 @@ | ||
| 14 | 14 | use Elementor\Utils; |
| 15 | 15 | use Elementor\User; |
| 16 | 16 | use Elementor\Core\Isolation\Wordpress_Adapter; |
| 17 | 17 | use Elementor\Core\Isolation\Wordpress_Adapter_Interface; |
| 18 | -use Elementor\Core\Isolation\Elementor_Adapter; | |
| 19 | 18 | use Elementor\Core\Isolation\Elementor_Adapter_Interface; |
| 20 | 19 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 21 | 20 | use Elementor\Includes\TemplateLibrary\Sources\AdminMenuItems\Editor_One_Saved_Templates_Menu; |
| 22 | 21 | use Elementor\Includes\TemplateLibrary\Sources\AdminMenuItems\Editor_One_Templates_Menu; |
| @@ -1267,8 +1266,10 @@ | ||
| 1267 | 1266 | * |
| 1268 | 1267 | * @param string $redirect_to The redirect URL. |
| 1269 | 1268 | * @param string $action The action being taken. |
| 1270 | 1269 | * @param array $post_ids The items to take the action on. |
| 1270 | + * | |
| 1271 | + * @return string The redirect URL, unchanged when the action is not handled here. | |
| 1271 | 1272 | */ |
| 1272 | 1273 | public function admin_export_multiple_templates( $redirect_to, $action, $post_ids ) { |
| 1273 | 1274 | if ( self::BULK_EXPORT_ACTION === $action ) { |
| 1274 | 1275 | $result = $this->export_multiple_templates( $post_ids ); |
| @@ -1276,8 +1277,10 @@ | ||
| 1276 | 1277 | // If you reach this line, the export failed |
| 1277 | 1278 | // PHPCS - Not user input. |
| 1278 | 1279 | wp_die( $result->get_error_message() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1279 | 1280 | } |
| 1281 | + | |
| 1282 | + return $redirect_to; | |
| 1280 | 1283 | } |
| 1281 | 1284 | |
| 1282 | 1285 | /** |
| 1283 | 1286 | * Print admin tabs. |
| @@ -1997,33 +2000,18 @@ | ||
| 1997 | 2000 | if ( null === $this->wordpress_adapter ) { |
| 1998 | 2001 | $this->set_wordpress_adapter( new WordPress_Adapter() ); |
| 1999 | 2002 | } |
| 2000 | 2003 | |
| 2001 | - if ( ! $this->should_check_permissions( $args ) ) { | |
| 2002 | - return true; | |
| 2003 | - } | |
| 2004 | - | |
| 2005 | 2004 | $post_id = intval( $args['template_id'] ); |
| 2006 | 2005 | $post_status = $this->wordpress_adapter->get_post_status( $post_id ); |
| 2007 | - $is_private_or_non_published = ( 'private' === $post_status && ! $this->wordpress_adapter->current_user_can( 'read_private_posts', $post_id ) ) || ( 'publish' !== $post_status ); | |
| 2008 | 2006 | |
| 2009 | - $can_read_template = ! $is_private_or_non_published || $this->wordpress_adapter->current_user_can( 'edit_post', $post_id ); | |
| 2010 | - | |
| 2011 | - return apply_filters( 'elementor/template-library/is_allowed_to_read_template', $can_read_template, $args ); | |
| 2012 | - } | |
| 2013 | - | |
| 2014 | - private function should_check_permissions( array $args ): bool { | |
| 2015 | - if ( null === $this->elementor_adapter ) { | |
| 2016 | - $this->set_elementor_adapter( new Elementor_Adapter() ); | |
| 2007 | + if ( 'publish' === $post_status && ! post_password_required( $post_id ) ) { | |
| 2008 | + return true; | |
| 2017 | 2009 | } |
| 2018 | 2010 | |
| 2019 | - $check_permissions = isset( $args['check_permissions'] ) && false === $args['check_permissions']; | |
| 2011 | + $can_read_template = $this->wordpress_adapter->current_user_can( 'edit_post', $post_id ); | |
| 2020 | 2012 | |
| 2021 | - if ( $check_permissions ) { | |
| 2022 | - return false; | |
| 2023 | - } | |
| 2024 | - | |
| 2025 | - return true; | |
| 2013 | + return apply_filters( 'elementor/template-library/is_allowed_to_read_template', $can_read_template, $args ); | |
| 2026 | 2014 | } |
| 2027 | 2015 | |
| 2028 | 2016 | public function set_wordpress_adapter( Wordpress_Adapter_Interface $wordpress_adapter ) { |
| 2029 | 2017 | $this->wordpress_adapter = $wordpress_adapter; |