PluginProbe
WP Directory Kit / 1.3.8
WP Directory Kit v1.3.8
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / blocks / blocks-init.php

blocks-init.php in WP Directory Kit 1.3.8, at blocks/blocks-init.php

61 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly.
4 }
5
6 // Blocks
7 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'blocks/inc/block-product-field/block-product-field.php';
8
9 function my_custom_block_category($categories, $post) {
10 return array_merge(
11 array(
12 array(
13 'slug' => 'wdk-blocks',
14 'title' => __('WDK Blocks', 'text-domain'),
15 'icon' => 'dashicons-heart',
16 ),
17 ),
18 $categories
19 );
20 }
21 add_filter('block_categories_all', 'my_custom_block_category', 10, 2);
22
23 function wdk_block_view($view_file = '', $element = '', $print = false)
24 {
25 if(empty($view_file)) return false;
26 $file = false;
27 if(is_child_theme() && file_exists(get_stylesheet_directory().'/wpdirectorykit/blocks/inc/'.$view_file))
28 {
29 $file = get_stylesheet_directory().'/wpdirectorykit/blocks/inc/'.$view_file;
30 }
31 elseif(file_exists(get_template_directory().'/wpdirectorykit/blocks/inc/'.$view_file))
32 {
33 $file = get_template_directory().'/wpdirectorykit/blocks/inc/'.$view_file;
34 }
35 elseif(file_exists(WPDIRECTORYKIT_PATH.'blocks/inc/'.$view_file))
36 {
37 $file = WPDIRECTORYKIT_PATH.'blocks/inc/'.$view_file;
38 }
39
40 if($file)
41 {
42 extract($element);
43 if($print) {
44 include $file;
45 } else {
46 ob_start();
47 include $file;
48 return ob_get_clean();
49 }
50 }
51 else
52 {
53 if($print) {
54 echo 'View file not found in: '.esc_html($file);
55 } else {
56 return 'View file not found in: '.$file;
57 }
58 }
59 }
60
61 ?>