PluginProbe
WP Directory Kit / 1.4.8
WP Directory Kit v1.4.8
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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / blocks / blocks-init.php

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

63 lines 1.8 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 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'blocks/inc/block-share/block-share.php';
9
10 function wdk_block_category($categories, $post) {
11 return array_merge(
12 array(
13 array(
14 'slug' => 'wdk-blocks',
15 'title' => __('WDK Blocks', 'text-domain'),
16 'icon' => 'dashicons-heart',
17 ),
18 ),
19 $categories
20 );
21 }
22
23 add_filter('block_categories_all', 'wdk_block_category', 10, 2);
24
25 function wdk_block_view($view_file = '', $element = '', $print = false)
26 {
27 if(empty($view_file)) return false;
28 $file = false;
29 if(is_child_theme() && file_exists(get_stylesheet_directory().'/wpdirectorykit/blocks/inc/'.$view_file))
30 {
31 $file = get_stylesheet_directory().'/wpdirectorykit/blocks/inc/'.$view_file;
32 }
33 elseif(file_exists(get_template_directory().'/wpdirectorykit/blocks/inc/'.$view_file))
34 {
35 $file = get_template_directory().'/wpdirectorykit/blocks/inc/'.$view_file;
36 }
37 elseif(file_exists(WPDIRECTORYKIT_PATH.'blocks/inc/'.$view_file))
38 {
39 $file = WPDIRECTORYKIT_PATH.'blocks/inc/'.$view_file;
40 }
41
42 if($file)
43 {
44 extract($element);
45 if($print) {
46 include $file;
47 } else {
48 ob_start();
49 include $file;
50 return ob_get_clean();
51 }
52 }
53 else
54 {
55 if($print) {
56 echo 'View file not found in: '.esc_html($file);
57 } else {
58 return 'View file not found in: '.$file;
59 }
60 }
61 }
62
63 ?>