forked from daronspence/acf-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-code.php
50 lines (42 loc) · 1.2 KB
/
example-code.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Put this stuff in your functions.php file if necessary.
*/
/**
* include the plugin without "installing" it
*/
include_once( get_stylesheet_directory() . '/acfw/acf-widgets.php' );
// Enable include mode
add_filter('acfw_include', '__return_true');
// Filter for ACFW include directory. Reletive to the theme root. Necessary for include mode.
add_filter('acfw_dir', 'acfw_directory');
function acfw_directory( $dir ){
// default value is /acf-widgets/
return '/acfw/';
}
/**
* Enable LITE MODE
*/
add_filter('acfw_lite', '__return_true' ); // hides all admin screens but the plugin stays active if installed. Similar to ACF hide.
/**
* Create your own widgets on the go to include with a theme
* All key => value pairs are required.
*/
add_filter('acfw_include_widgets', 'add_include_widgets');
function add_include_widgets(){
$acfw_widgets = array(
array(
'title' => 'Test Widget 1',
'description' => 'A widget test from functions.php',
'slug' => 'test-widget',
'id' => 'Test_Widget',
),
array(
'title' => 'Test Widget 2',
'description' => 'A second widget test from functions.php',
'slug' => 'test-widget-2',
'id' => 'Test_Widget2',
),
);
return $acfw_widgets;
}