acf-settings.php ➔ my_acf_settings_path()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php 
2
3
// Hide ACF field group menu item
4
add_filter('acf/settings/show_admin', '__return_false');
5
6
// Customize ACF path
7
add_filter('acf/settings/path', 'my_acf_settings_path');
8
 
9
function my_acf_settings_path( $path ) {
0 ignored issues
show
Unused Code introduced by
The parameter $path is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
10
 
11
    // update path
12
    $path = get_stylesheet_directory() . '/includes/acf/';
13
    
14
    // return
15
    return $path;
16
}
17
18
// Customize ACF dir
19
add_filter('acf/settings/dir', 'my_acf_settings_dir');
20
 
21
function my_acf_settings_dir( $dir ) {
0 ignored issues
show
Unused Code introduced by
The parameter $dir is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
 
23
    // update path
24
    $dir = get_stylesheet_directory_uri() . '/includes/acf/';
25
    
26
    // return
27
    return $dir;
28
}
29
30
// Save ACF field as JSON
31
add_filter('acf/settings/save_json', 'my_acf_json_save_point');
32
 
33
function my_acf_json_save_point( $path ) {
0 ignored issues
show
Unused Code introduced by
The parameter $path is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    
35
    // update path
36
    $path = get_stylesheet_directory() . '/includes/acf-json';
37
    
38
    // return
39
    return $path; 
40
}
41
42
// Load ACF field from JSON
43
add_filter('acf/settings/load_json', 'my_acf_json_load_point');
44
45
function my_acf_json_load_point( $paths ) {
46
    
47
    // remove original path (optional)
48
    unset($paths[0]);
49
    
50
    // append path
51
    $paths[] = get_stylesheet_directory() . '/includes/acf-json';
52
    
53
    // return
54
    return $paths;
55
}
56
57
58
/*****
59
 Options Page
60
***************/
61
if( function_exists('acf_add_options_page') ) {
62
63
	acf_add_options_page(array(
0 ignored issues
show
Documentation introduced by
array('page_title' => 'L... => 'dashicons-layout') is of type array<string,string|fals...","icon_url":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
64
		'page_title' 	=> 'Lighthouse General Settings',
65
		'menu_title'	=> 'Theme Settings',
66
		'menu_slug' 	=> 'lighthouse-general-settings',
67
		'capability'	=> 'edit_posts',
68
		'parent_slug'	=> '',
69
		'redirect'		=> false,
70
		'icon_url' => 'dashicons-layout'
71
		));
72
	
73
	acf_add_options_sub_page(array(
0 ignored issues
show
Documentation introduced by
array('page_title' => 'A...ouse-general-settings') is of type array<string,string,{"pa...parent_slug":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
74
		'page_title' 	=> 'Announcement Slider',
75
		'menu_title'	=> 'Announcement',
76
		'menu_slug' 	=> 'announcement-slider',
77
		'parent_slug'	=> 'lighthouse-general-settings',
78
		));
79
	
80
	acf_add_options_sub_page(array(
0 ignored issues
show
Documentation introduced by
array('page_title' => 'M...ouse-general-settings') is of type array<string,string,{"pa...parent_slug":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
81
		'page_title' 	=> 'Members Logo Slider',
82
		'menu_title'	=> 'Members Logo',
83
		'menu_slug' 	=> 'members-logo-slider',
84
		'parent_slug'	=> 'lighthouse-general-settings',
85
		));
86
}