-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.php
More file actions
127 lines (111 loc) · 2.39 KB
/
Core.php
File metadata and controls
127 lines (111 loc) · 2.39 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* Main theme class.
*
* @author Themeisle
* @package jaxon
* @since 1.0.0
*/
namespace Jaxon;
/**
* Class Core
*
* @package jaxon
*/
class Core {
/**
* Core instance.
*
* @var Core
*/
public static $instance = null;
/**
* Get the static instance of the class.
*
* @return Core
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Core constructor.
*/
public function __construct() {
$this->run_hooks();
new Admin();
new Block_Patterns();
new Block_Styles();
}
/**
* Initialize hooks.
*
* @return void
*/
private function run_hooks() {
add_action( 'after_setup_theme', array( $this, 'setup' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'add_editor_styles' ) );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
}
/**
* Setup theme.
*
* @return void
*/
public function setup() {
load_theme_textdomain( 'jaxon', JAXON_DIR . '/languages' );
$starter_content = new Starter_Content();
add_theme_support( 'starter-content', $starter_content->get() );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'editor-styles' );
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
)
);
register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu', 'jaxon' ) ) );
}
/**
* Enqueue scripts and styles.
*
* @return void
*/
public function enqueue() {
Assets_Manager::enqueue_style( Assets_Manager::ASSETS_SLUGS['frontend-css'], 'style' );
}
/**
* Add editor styles.
*
* @return void
*/
public function add_editor_styles() {
Assets_Manager::enqueue_style( Assets_Manager::ASSETS_SLUGS['editor-css'], 'editor' );
}
/**
* Modify the main query before it is executed.
*
* @param \WP_Query $query The WP_Query instance.
*/
public function pre_get_posts( \WP_Query $query ) {
// Only modify frontend main query.
if ( is_admin() || ! $query->is_main_query() || $query->is_feed() ) {
return;
}
if ( $query->is_archive() ) {
$query->set( 'posts_per_page', 4 );
}
}
}