| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Mcp\Abilities; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
class Wordpress_Best_Practices_Ability extends Abstract_Ability { |
| 10 |
const URI = 'elementor://wordpress/best-practices'; |
| 11 |
const FILE_PATH = __DIR__ . '/../static-resources/wordpress/best-practices.md'; |
| 12 |
|
| 13 |
protected function get_ability_id(): string { |
| 14 |
return 'elementor/wordpress-best-practices'; |
| 15 |
} |
| 16 |
|
| 17 |
protected function get_definition(): Ability_Definition { |
| 18 |
return new Ability_Definition( |
| 19 |
__( 'WordPress Best Practices', 'elementor' ), |
| 20 |
__( 'Opinionated WordPress patterns for Elementor builds: repeating layouts (single template vs N pages), include-all + exclude-exceptions condition scoping, Post Content placement, dynamic tags.', 'elementor' ), |
| 21 |
'elementor', |
| 22 |
[ 'type' => 'string' ], |
| 23 |
[ |
| 24 |
'mcp' => [ |
| 25 |
'type' => 'resource', |
| 26 |
'uri' => self::URI, |
| 27 |
'public' => true, |
| 28 |
'mimeType' => 'text/markdown', |
| 29 |
'description' => __( 'Opinionated WordPress patterns for Elementor builds: repeating layouts (single template vs N pages), include-all + exclude-exceptions condition scoping, Post Content placement, dynamic tags.', 'elementor' ), |
| 30 |
], |
| 31 |
], |
| 32 |
fn() => current_user_can( 'edit_posts' ) |
| 33 |
); |
| 34 |
} |
| 35 |
|
| 36 |
public function execute( $input = [] ) { |
| 37 |
if ( ! file_exists( self::FILE_PATH ) ) { |
| 38 |
return new \WP_Error( |
| 39 |
'resource_not_found', |
| 40 |
__( 'Static resource file not found', 'elementor' ), |
| 41 |
[ 'status' => 404 ] |
| 42 |
); |
| 43 |
} |
| 44 |
|
| 45 |
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents |
| 46 |
return file_get_contents( self::FILE_PATH ); |
| 47 |
} |
| 48 |
} |
| 49 |
|