@@ -123,46 +123,6 @@ function wzkb_archive_template( $template ) {
123123}
124124add_filter ( 'template_include ' , 'wzkb_archive_template ' );
125125
126-
127- /**
128- * Helper function to build a WP_Block_Template object.
129- *
130- * @param string $theme The source of the template (plugin name in this case).
131- * @param string $template_slug Template slug for the block template.
132- * @param string $template_file Path to the template file.
133- * @param string $template_type Template type (either 'wp_template' or 'wp_template_part').
134- *
135- * @return WP_Block_Template|WP_Error The block template object or WP_Error on failure.
136- */
137- function wzkb_build_block_template_result ( $ theme , $ template_slug , $ template_file , $ template_type ) {
138- // Use wp_remote_get to retrieve the content of the template file.
139- $ response = wp_remote_get ( $ template_file );
140-
141- // Check for errors in the response.
142- if ( is_wp_error ( $ response ) ) {
143- return $ response ; // Return the error if there's an issue.
144- }
145-
146- $ content = wp_remote_retrieve_body ( $ response ); // Get the body content of the response.
147-
148- // Create a new WP_Block_Template object.
149- $ template = new WP_Block_Template ();
150- $ template ->id = $ theme . '// ' . $ template_slug ;
151- $ template ->theme = $ theme ;
152- $ template ->content = $ content ;
153- $ template ->slug = $ template_slug ;
154- $ template ->source = 'plugin ' ;
155- $ template ->type = $ template_type ;
156- $ template ->title = ucfirst ( str_replace ( '- ' , ' ' , $ template_slug ) );
157- $ template ->status = 'publish ' ;
158- $ template ->has_theme_file = true ;
159- $ template ->is_custom = true ;
160- $ template ->modified = null ; // Adjust as necessary.
161-
162- return $ template ;
163- }
164-
165-
166126/**
167127 * For knowledge base search results, set posts_per_page 10.
168128 *
0 commit comments