PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.3
Kubio AI Page Builder v2.8.3
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / full-site-editing / full-site-editing.php
kubio / lib / full-site-editing Last commit date
block-templates.php 1 year ago class-templates-list-table.php 2 years ago default-template-types.php 7 months ago full-site-editing.php 1 year ago get-block-templates.php 1 year ago template-loader.php 1 year ago template-parts.php 1 month ago templates.php 1 month ago
full-site-editing.php
124 lines
1 <?php
2
3 function kubio_maybe_transform_slug_to_title( $slug ) {
4
5 $slug_parts = explode(
6 ' ',
7 trim(
8 preg_replace(
9 '/\s\s+/',
10 ' ',
11 str_replace( array( '-', ' ' ), ' ', $slug )
12 )
13 )
14 );
15 $title = implode(
16 ' ',
17 array_map(
18 function ( $item ) {
19 return ucfirst( $item );
20 },
21 $slug_parts
22 )
23 );
24
25 if ( empty( trim( $title ) ) ) {
26 $title = $slug;
27 }
28
29 return $title;
30 }
31
32 function kubio_get_template_hierarchy( $template_type ) {
33 if ( ! in_array( $template_type, kubio_get_template_type_slugs(), true ) ) {
34 return array();
35 }
36
37 $get_template_function = 'get_' . str_replace( '-', '_', $template_type ) . '_template'; // front-page -> get_front_page_template.
38 $template_hierarchy_filter = str_replace( '-', '', $template_type ) . '_template_hierarchy'; // front-page -> frontpage_template_hierarchy.
39
40 $result = array();
41 $template_hierarchy_filter_function = function ( $templates ) use ( &$result ) {
42 $result = $templates;
43
44 return $templates;
45 };
46
47 add_filter( $template_hierarchy_filter, $template_hierarchy_filter_function, 20, 1 );
48 call_user_func( $get_template_function ); // This invokes template_hierarchy_filter.
49 remove_filter( $template_hierarchy_filter, $template_hierarchy_filter_function, 20 );
50
51 return $result;
52 }
53
54
55 function kubio_get_template_paths() {
56
57 $template_parts_rels = array(
58 '/full-site-editing/block-templates/*.html',
59 '/block-templates/*.html',
60 );
61 $block_template_files = array();
62
63 foreach ( $template_parts_rels as $template_parts_rel ) {
64 $parent_block_template_files = glob( get_stylesheet_directory() . $template_parts_rel );
65 $block_template_files = is_array( $block_template_files ) ? array_merge( $block_template_files, $parent_block_template_files ) : array();
66
67 }
68
69 if ( is_child_theme() ) {
70 foreach ( $template_parts_rels as $template_parts_rel ) {
71 $child_block_template_files = glob( get_template_directory() . $template_parts_rel );
72 $child_block_template_files = is_array( $child_block_template_files ) ? $child_block_template_files : array();
73 $block_template_files = array_merge( $block_template_files, $child_block_template_files );
74 }
75 }
76
77 return $block_template_files;
78 }
79
80 function kubio_get_template_part_paths( $base_directory ) {
81 $path_list = array();
82 if ( file_exists( $base_directory . '/full-site-editing/block-template-parts' ) ) {
83 $nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory . '/full-site-editing/block-template-parts' ) );
84 $nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH );
85 foreach ( $nested_html_files as $path => $file ) {
86 $path_list[] = $path;
87 }
88 } else {
89 if ( file_exists( $base_directory . '/block-template-parts' ) ) {
90 $nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory . '/block-template-parts' ) );
91 $nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH );
92 foreach ( $nested_html_files as $path => $file ) {
93 $path_list[] = $path;
94 }
95 }
96 }
97
98 return $path_list;
99 }
100
101
102 function kubio_add_page_top_div() {
103 ?>
104 <div id="page-top" tabindex="-1"></div>
105 <?php
106 }
107
108 add_action( 'wp_body_open', 'kubio_add_page_top_div' );
109
110
111 add_filter(
112 'wp_list_table_class_name',
113 function ( $class ) {
114 global $post_type;
115
116 if ( $post_type === 'wp_template_part' || $post_type === 'wp_template' ) {
117 require_once __DIR__ . '/class-templates-list-table.php';
118 $class = 'KubioWPTemplateListTable';
119 }
120
121 return $class;
122 }
123 );
124