-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunctions.php
More file actions
121 lines (96 loc) · 3.76 KB
/
Copy pathfunctions.php
File metadata and controls
121 lines (96 loc) · 3.76 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
<?php
if(!is_admin()) {
wp_enqueue_style('ExiaCSS', get_template_directory_uri() . '/dist/main.css');
wp_enqueue_script('ExiaJS', get_template_directory_uri() . '/dist/main.js');
}else{
wp_enqueue_script('MetaBoxJS', get_template_directory_uri() . '/plugins/meta-boxes/meta-boxes.js');
}
add_theme_support('automatic-feed-links');
//pages should be prefixed
add_action( 'init', 'custom_page_rules' );
function custom_page_rules() {
global $wp_rewrite;
$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%';
}
add_theme_support('post-formats', [
'image', 'gallery', 'video', 'audio'
]);
//allow a custom logo
add_theme_support( 'custom-logo', [
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
]);
add_theme_support( 'post-thumbnails' );
add_action('print_media_templates', function(){
?>
<script type="text/html" id="tmpl-custom-gallery-setting">
<h3 style="z-index: -1;">___________________________________________________________________________________________</h3>
<h3>Custom Settings</h3>
<label class="setting">
<span><?php _e('Light Mode'); ?></span>
<input type="checkbox" data-setting="light_mode">
</label>
</script>
<script>
jQuery(document).ready(function(){
_.extend(wp.media.gallery.defaults, {
light_mode: false,
});
wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({
template: function(view){
return wp.media.template('gallery-settings')(view)
+ wp.media.template('custom-gallery-setting')(view);
}
});
});
</script>
<?php
});
add_filter('post_gallery','customFormatGallery',10,2);
function customFormatGallery($string,$attr){
$output = '<div class="exia-gallery-placeholder" data-columns="'.$attr['columns'].'" data-light="'.($attr['light_mode']).'">';
$posts = get_posts(array('include' => $attr['ids'],'post_type' => 'attachment'));
foreach($posts as $imagePost){
$output .= '<div
data-id="'.$imagePost->ID.'"
data-medium="'.wp_get_attachment_image_src($imagePost->ID, 'medium')[0].'"
data-large="'.wp_get_attachment_image_src($imagePost->ID, 'large')[0].'"
></div>';
}
return $output.'</div>';
}
require_once __DIR__ . '/plugins/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'prefix_register_required_plugins' );
function prefix_register_required_plugins() {
$plugins = [
[
'name' => 'Meta Box',
'slug' => 'meta-box',
'required' => true,
]
];
$config = [
'id' => 'your-id',
];
tgmpa( $plugins, $config );
}
require_once __DIR__ . '/plugins/meta-boxes/meta-boxes.php';
add_action( 'do_meta_boxes', 'remove_default_custom_fields_meta_box', 1, 3 );
function remove_default_custom_fields_meta_box( $post_type, $context, $post ) {
remove_meta_box( 'postcustom', $post_type, $context );
}
add_filter( 'rest_prepare_post', function( $response, $post, $request ) {
// Only do this for single post requests.
global $post;
// Get the so-called next post.
$next = get_adjacent_post( false, '', false );
// Get the so-called previous post.
$previous = get_adjacent_post( false, '', true );
// Format them a bit and only send id and slug (or null, if there is no next/previous post).
$response->data['next'] = ( is_a( $next, 'WP_Post') ) ? array( "id" => $next->ID, "link" => get_permalink($next) ) : null;
$response->data['previous'] = ( is_a( $previous, 'WP_Post') ) ? array( "id" => $previous->ID, "link" => get_permalink($previous) ) : null;
return $response;
}, 10, 3 );