Completed
Branch master (30daa2)
by
unknown
01:57
created

ALNP_Poseidon::add_theme_support()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * Auto Load Next Post Theme Support: Poseidon
4
 *
5
 * Applies support for Poseidon Theme.
6
 *
7
 * @since    1.5.9
8
 * @author   Sébastien Dumont
9
 * @category Theme Support
10
 * @package  Auto Load Next Post/Theme Support
11
 * @license  GPL-2.0+
12
 */
13
14
// Exit if accessed directly.
15
if ( ! defined( 'ABSPATH' ) ) {
16
	exit;
17
}
18
19
/**
20
 * ALNP_Poseidon class.
21
 */
22
class ALNP_Poseidon {
23
24
	/**
25
	 * Initlize Theme.
26
	 *
27
	 * @access public
28
	 * @static
29
	 */
30
	public static function init() {
31
		// Add theme support and preset the theme selectors.
32
		add_action( 'after_setup_theme', array( __CLASS__, 'add_theme_support' ) );
33
34
		// Display the post thumbnail before the content.
35
		add_action( 'alnp_load_before_content', array( __CLASS__, 'the_post_thumbnail' ), 10 );
36
37
		// Filters the repeater template location.
38
		add_filter( 'alnp_template_location', array( __CLASS__, 'alnp_poseidon_template_location' ) );
39
	} // END init()
40
41
	/**
42
	 * Display the post thumbnail before the content if the 
43
	 * theme is set to display them only in the header.
44
	 *
45
	 * @access public
46
	 * @static
47
	 */
48
	public static function the_post_thumbnail() {
49
		if ( is_single() && has_post_thumbnail() && 'header' == $theme_options['post_layout_single'] ) {
0 ignored issues
show
Bug introduced by
The variable $theme_options does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
50
			the_post_thumbnail();
51
		}
52
	} // END the_post_thumbnail()
53
54
	/**
55
	 * Filters the template location for get_template_part().
56
	 *
57
	 * @access public
58
	 * @static
59
	 */
60
	public static function alnp_poseidon_template_location() {
61
		return 'template-parts/';
62
	} // alnp_poseidon_template_location()
63
64
	/**
65
	 * Add theme support by providing the theme selectors
66
	 * to be applied once the theme is activated.
67
	 *
68
	 * @access public
69
	 * @static
70
	 */
71
	public static function add_theme_support() {
72
		add_theme_support( 'auto-load-next-post', array(
73
			'content_container'    => 'main.site-main',
74
			'title_selector'       => 'h1.entry-title',
75
			'navigation_container' => 'nav.post-navigation',
76
			'comments_container'   => 'div#comments',
77
			'load_js_in_footer'    => 'no',
78
			'lock_js_in_footer'    => 'no',
79
		) );
80
	} // END add_theme_support()
81
82
} // END class
83
84
ALNP_Poseidon::init();
85