|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Spurs enqueue scripts |
|
4
|
|
|
* |
|
5
|
|
|
* @package spurs |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
// Exit if accessed directly. |
|
9
|
|
|
defined( 'ABSPATH' ) || exit; |
|
10
|
|
|
|
|
11
|
|
|
if ( ! function_exists( 'spurs_scripts' ) ) { |
|
12
|
|
|
/** |
|
13
|
|
|
* Load theme JS and CSS |
|
14
|
|
|
*/ |
|
15
|
|
|
function spurs_scripts() { |
|
16
|
|
|
// Get the theme data. |
|
17
|
|
|
$the_theme = wp_get_theme(); |
|
18
|
|
|
$theme_version = $the_theme->get( 'Version' ); |
|
19
|
|
|
|
|
20
|
|
|
$css_version = $theme_version . '.' . filemtime( get_template_directory() . '/css/theme.min.css' ); |
|
21
|
|
|
wp_enqueue_style( 'spurs-styles', get_stylesheet_directory_uri() . '/css/theme.min.css', array(), $css_version ); |
|
22
|
|
|
|
|
23
|
|
|
wp_enqueue_script( 'jquery' ); |
|
24
|
|
|
|
|
25
|
|
|
//wp_enqueue_script('google.maps.api', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBzGRoIbHnQqqYWxOYuTpE58WYGx6RkAjo&v=3.exp', null, null, true); |
|
26
|
|
|
|
|
27
|
|
|
$js_version = $theme_version . '.' . filemtime( get_template_directory() . '/js/theme.min.js' ); |
|
28
|
|
|
wp_enqueue_script( 'spurs-scripts', get_template_directory_uri() . '/js/theme.min.js', array(), $js_version, true ); |
|
29
|
|
|
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
|
30
|
|
|
wp_enqueue_script( 'comment-reply' ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
// now the most interesting part |
|
34
|
|
|
// we have to pass parameters to myloadmore.js script but we can get the parameters values only in PHP |
|
35
|
|
|
// you can define variables directly in your HTML but I decided that the most proper way is wp_localize_script() |
|
36
|
|
|
wp_localize_script( 'spurs-scripts', 'spurs_loadmore_params', array( |
|
37
|
|
|
'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', // WordPress AJAX |
|
38
|
|
|
'posts' => json_encode( $wp_query->query_vars ), // everything about your loop is here |
|
39
|
|
|
'current_page' => get_query_var( 'paged' ) ? get_query_var('paged') : 1, |
|
40
|
|
|
'max_page' => $wp_query->max_num_pages |
|
41
|
|
|
) ); |
|
42
|
|
|
} |
|
43
|
|
|
} // endif function_exists( 'spurs_scripts' ). |
|
44
|
|
|
|
|
45
|
|
|
add_action( 'wp_enqueue_scripts', 'spurs_scripts' ); |
|
46
|
|
|
|
|
47
|
|
|
add_action('admin_head', 'spurs_admin_inline_styles'); |
|
48
|
|
|
function spurs_admin_inline_styles() { |
|
49
|
|
|
echo '<style> |
|
50
|
|
|
.wp-block{max-width: 1070px} |
|
51
|
|
|
.wp-block[data-align=wide]{max-width: 1250px} |
|
52
|
|
|
</style>'; |
|
53
|
|
|
} |
|
54
|
|
|
|