Completed
Pull Request — master (#716)
by Zack
09:51 queued 04:52
created

GravityView_Theme_Hooks_Church_Themes::add_hooks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
c 2
b 1
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 19 and the first side effect is on line 63.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Add Church Themes compatibility to GravityView
4
 *
5
 * @file      class-gravityview-theme-hooks-church-themes.php
6
 * @package   GravityView
7
 * @license   GPL2
8
 * @author    Katz Web Services, Inc.
9
 * @link      http://gravityview.co
10
 * @copyright Copyright 2016, Katz Web Services, Inc.
11
 *
12
 * @since 1.17
13
 */
14
15
/**
16
 * @inheritDoc
17
 * @since 1.17
18
 */
19
class GravityView_Theme_Hooks_Church_Themes extends GravityView_Plugin_and_Theme_Hooks {
20
21
	/**
22
	 * Church Themes framework version number
23
	 *
24
	 * @inheritDoc
25
	 * @since 1.17
26
	 */
27
	protected $constant_name = 'CTFW_VERSION';
28
29
	/**
30
	 * Add filters
31
	 *
32
	 * @since 1.17
33
	 *
34
	 * @return void
35
	 */
36
	protected function add_hooks() {
37
		parent::add_hooks();
38
39
		add_filter( 'ctfw_has_content', array( $this, 'if_gravityview_return_true' ) );
40
	}
41
42
	/**
43
	 * Tell Church Themes that GravityView has content if the current page is a GV post type or has shortcode
44
	 *
45
	 * @since 1.17
46
	 *
47
	 * @param bool $has_content Does the post have content?
48
	 *
49
	 * @return bool True: It is GV post type, or has shortcode, or $has_content was true.
50
	 */
51
	public function if_gravityview_return_true( $has_content = false ) {
52
53
		if( ! class_exists( 'GravityView_frontend' ) ) {
54
			return $has_content;
55
		}
56
57
		$instance = GravityView_frontend::getInstance();
58
59
		return ( $instance->is_gravityview_post_type || $instance->post_has_shortcode ) ? true : $has_content;
0 ignored issues
show
Bug introduced by
The property is_gravityview_post_type cannot be accessed from this context as it is declared private in class GravityView_frontend.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
Bug introduced by
The property post_has_shortcode cannot be accessed from this context as it is declared private in class GravityView_frontend.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
60
	}
61
}
62
63
new GravityView_Theme_Hooks_Church_Themes;