Test Setup Failed
Push — master ( 51607c...6b8ca8 )
by Paul
03:43
created

helpers.php (1 issue)

Labels
Severity
1
<?php
2
defined( 'WPINC' ) || die;
3
4
/**
5
 * @return mixed
6
 */
7
function glsr( $alias = null ) {
8
	$app = \GeminiLabs\SiteReviews\Application::load();
9
	return empty( $alias )
10
		? $app
11
		: $app->make( $alias );
12
}
13
14
/**
15
 * get_current_screen() is unreliable because it is not defined on all admin pages
16
 * @return \WP_Screen|object
0 ignored issues
show
The type WP_Screen was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
 */
18
function glsr_current_screen() {
19
	if( function_exists( 'get_current_screen' )) {
20
		$screen = get_current_screen();
21
	}
22
	return empty( $screen )
23
		? (object)array_fill_keys( ['base', 'id', 'post_type'], null )
24
		: $screen;
25
}
26
27
/**
28
 * @return \GeminiLabs\SiteReviews\Database
29
 */
30
function glsr_db() {
31
	return glsr( 'Database' );
32
}
33
34
/**
35
 * @param mixed ...$vars
36
 * @return void
37
 */
38
function glsr_debug( ...$vars ) {
39
	if( count( $vars ) == 1 ) {
40
		$value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' );
41
		printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value );
42
	}
43
	else {
44
		echo '<div class="glsr-debug-group">';
45
		foreach( $vars as $var ) {
46
			glsr_debug( $var );
47
		}
48
		echo '</div>';
49
	}
50
}
51
52
/**
53
 * @return \GeminiLabs\SiteReviews\Modules\Logger
54
 */
55
function glsr_log() {
56
	$args = func_get_args();
57
	$context = isset( $args[1] )
58
		? $args[1]
59
		: [];
60
	$logger = glsr( 'Modules\Logger' );
61
	return empty( $args )
62
		? $logger
63
		: $logger->log( 'debug', $args[0], $context );
64
}
65
66
/**
67
 * This function prevents the taxonomy object from containing class recursion
68
 * @return void
69
 * @callback register_taxonomy() "meta_box_cb"
70
 */
71
function glsr_categories_meta_box( $post, $box ) {
72
	glsr( 'Controllers\EditorController' )->renderTaxonomyMetabox( $post, $box );
73
}
74
75
76
77
/**
78
 * @param string $option_path
79
 * @param mixed $fallback
80
 * @return string|array
81
 */
82
// function glsr_get_option( $option_path = '', $fallback = '' ) {
83
// 	return glsr( 'Database\OptionManager' )->get( $option_path, $fallback );
84
// }
85
86
/**
87
 * @return array
88
 */
89
// function glsr_get_options() {
90
// 	return glsr( 'Database\OptionManager' )->all();
91
// }
92
93
/**
94
 * @param int $post_id
95
 * @return void|object
96
 */
97
// function glsr_get_review( $post_id ) {
98
// 	return glsr( 'Database' )->getReview( get_post( $post_id ));
99
// }
100
101
/**
102
 * @return array
103
 */
104
// function glsr_get_reviews( array $args = array() ) {
105
// 	return glsr( 'Database' )->getReviews( $args );
106
// }
107