Repository navigation
Expand file tree
/
Copy pathfunctions.php
More file actions
161 lines (150 loc) · 4.63 KB
/
Copy pathfunctions.php
File metadata and controls
161 lines (150 loc) · 4.63 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
/**
* Ipsum functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Ipsum
* @since Ipsum 1.0
*/
// Loads style.css in the editors too, then the few overrides only the editors need.
if ( ! function_exists( 'ipsum_editor_style' ) ) :
/**
* Adds style.css and editor-style.css as editor stylesheets.
*
* @since Ipsum 1.0
* @return void
*/
function ipsum_editor_style() {
add_editor_style( array( 'style.css', 'assets/css/editor-style.css' ) );
}
endif;
add_action( 'after_setup_theme', 'ipsum_editor_style' );
if ( ! function_exists( 'ipsum_styles' ) ) :
/**
* Enqueue styles.
*
* @since Ipsum 1.0
* @return void
*/
function ipsum_styles() {
// Register theme stylesheet.
wp_register_style(
'ipsum-style',
get_stylesheet_directory_uri() . '/style.css',
array(),
wp_get_theme()->get( 'Version' )
);
// Enqueue theme stylesheet.
wp_enqueue_style( 'ipsum-style' );
}
endif;
add_action( 'wp_enqueue_scripts', 'ipsum_styles' );
if ( ! function_exists( 'ipsum_comments_cta_binding' ) ) :
/**
* Returns the comments call to action for the current post.
*
* @since Ipsum 1.0
* @param array $source_args Block binding source arguments.
* @param WP_Block $block_instance The block instance.
* @return string The call to action text.
*/
function ipsum_comments_cta_binding( $source_args, $block_instance ) {
$post_id = $block_instance->context['postId'] ?? get_the_ID();
if ( get_comments_number( $post_id ) > 0 ) {
$text = __( 'Join the conversation', 'ipsum' );
} else {
$text = __( 'Be the first to comment', 'ipsum' );
}
return '<a href="' . esc_url( get_comments_link( $post_id ) ) . '">' . esc_html( $text ) . '</a>';
}
endif;
if ( ! function_exists( 'ipsum_register_block_bindings' ) ) :
/**
* Registers the comments call-to-action block binding source.
*
* @since Ipsum 1.0
* @return void
*/
function ipsum_register_block_bindings() {
register_block_bindings_source(
'ipsum/comments-cta',
array(
'label' => __( 'Comments call to action', 'ipsum' ),
'get_value_callback' => 'ipsum_comments_cta_binding',
'uses_context' => array( 'postId' ),
)
);
}
endif;
add_action( 'init', 'ipsum_register_block_bindings' );
if ( ! function_exists( 'ipsum_sidebar_template_types' ) ) :
/**
* Registers the sidebar template variants as template types, so they are
* listed with proper titles and descriptions in the Site Editor.
*
* @since Ipsum 1.0
* @param array $default_template_types The default template types.
* @return array
*/
function ipsum_sidebar_template_types( $default_template_types ) {
$default_template_types['index-sidebar'] = array(
'title' => _x( 'Index Sidebar', 'Template name', 'ipsum' ),
'description' => __( 'Displays the latest posts beside a sidebar with categories and recent posts.', 'ipsum' ),
);
$default_template_types['archive-sidebar'] = array(
'title' => _x( 'All Archives Sidebar', 'Template name', 'ipsum' ),
'description' => __( 'Displays post archives beside a sidebar with categories and recent posts.', 'ipsum' ),
);
return $default_template_types;
}
endif;
add_filter( 'default_template_types', 'ipsum_sidebar_template_types' );
if ( ! function_exists( 'ipsum_pattern_categories' ) ) :
/**
* Registers the pattern categories the theme's patterns use beyond core's.
*
* @since Ipsum 1.0
* @return void
*/
function ipsum_pattern_categories() {
register_block_pattern_category(
'ipsum_page',
array(
'label' => _x( 'Pages', 'Block pattern category', 'ipsum' ),
'description' => __( 'Full page layouts, ready to be applied to a page.', 'ipsum' ),
)
);
}
endif;
add_action( 'init', 'ipsum_pattern_categories' );
if ( ! function_exists( 'ipsum_block_styles' ) ) :
/**
* Registers block style variations.
*
* The Evening code style keeps the Evening palette's literals on purpose,
* so the block reads as a dark slab under every style variation.
*
* @since Ipsum 1.0
* @return void
*/
function ipsum_block_styles() {
register_block_style(
'core/code',
array(
'name' => 'evening',
'label' => _x( 'Evening', 'Block style label', 'ipsum' ),
'inline_style' => '.wp-block-code.is-style-evening{background-color:#000000;color:#fafafa;border-color:#fafafa40;}',
)
);
register_block_style(
'core/site-logo',
array(
'name' => 'sharp',
'label' => _x( 'Sharp', 'Block style label', 'ipsum' ),
'inline_style' => '.wp-block-site-logo.is-style-sharp{border-radius:0;}',
)
);
}
endif;
add_action( 'init', 'ipsum_block_styles' );