PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.2
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / Gutenberg / Templates / AbstractBlockTemplate.php

AbstractBlockTemplate.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.2, at inc/Gutenberg/Templates/AbstractBlockTemplate.php

48 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace LearnPress\Gutenberg\Templates;
4
5 use LearnPress\Helpers\Template;
6 use WP_Block_Template;
7
8 /**
9 * Abstract_Block_Template class.
10 *
11 * @since 4.2.8 Convert from old class Abstract_Block_Template
12 * @version 1.0.1
13 */
14 abstract class AbstractBlockTemplate extends WP_Block_Template {
15 public $theme = 'learnpress/learnpress';
16 public $type = 'wp_template';
17 /**
18 * @var string name of the block
19 */
20 public $origin = 'plugin';
21 public $source = 'plugin'; // plugin|custom|theme, if custom save on db will be use 'custom'.
22 public $content = ''; // Set content will be shown on edit block and the frontend.
23 public $has_theme_file = true;
24 public $is_custom = false;
25 public $path_html_block_template_file = '';
26
27 public function __construct() {
28 $this->id = $this->theme . '//' . $this->slug;
29 $template_file = '';
30
31 if ( ! empty( $this->path_html_block_template_file ) ) {
32 $template_file = Template::instance( false )->get_frontend_template_type_block(
33 $this->path_html_block_template_file
34 );
35 }
36
37 // Set content from theme file.
38 if ( file_exists( $template_file ) ) {
39 $content = file_get_contents( $template_file );
40 if ( version_compare( get_bloginfo( 'version' ), '6.4-beta', '>=' ) ) {
41 $this->content = traverse_and_serialize_blocks( parse_blocks( $content ) );
42 } else {
43 $this->content = _inject_theme_attribute_in_block_template_content( $content );
44 }
45 }
46 }
47 }
48