1
+ <?php
2
+ /**
3
+ * Add custom navigation elements
4
+ *
5
+ * @package My Calendar custom navigation
6
+ * @author Joe Dolson
7
+ * @copyright 2022 Joe Dolson
8
+ * @license GPL-2.0+
9
+ *
10
+ * @wordpress-plugin
11
+ * Plugin Name: My Calendar custom navigation
12
+ * Plugin URI: http://localhost
13
+ * Description: Demonstrates how to render custom information in the calendar header or footer.
14
+ * Author: Joseph C Dolson
15
+ * Author URI: https://www.joedolson.com
16
+ * Text Domain: localhost
17
+ * License: GPL-2.0+
18
+ * License URI: http://www.gnu.org/license/gpl-2.0.txt
19
+ * Domain Path: lang
20
+ * Version: 1.0.0
21
+ */
22
+
23
+ /*
24
+ Copyright 2022 Joe Dolson
25
+
26
+ This program is free software; you can redistribute it and/or modify
27
+ it under the terms of the GNU General Public License as published by
28
+ the Free Software Foundation; either version 2 of the License, or
29
+ (at your option) any later version.
30
+
31
+ This program is distributed in the hope that it will be useful,
32
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
33
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34
+ GNU General Public License for more details.
35
+
36
+ You should have received a copy of the GNU General Public License
37
+ along with this program; if not, write to the Free Software
38
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
39
+ */
40
+
41
+ // Exit if accessed directly.
42
+ if ( ! defined ( 'ABSPATH ' ) ) {
43
+ exit ;
44
+ }
45
+
46
+ /**
47
+ * Create your custom navigation item using the current view's parameters. All this example does is print the current parameters in the menu.
48
+ *
49
+ * @param array $params Parameters for the current view.
50
+ *
51
+ * @return string HTML for navigation item.
52
+ */
53
+ function my_custom_nav_item ( $ params ) {
54
+ return '<pre> ' . print_r ( $ params , 1 ) . '</pre> ' ;
55
+ }
56
+
57
+ /**
58
+ * Return a custom navigation item in the header. (Can do same thing with filter `mc_footer_navigation`).
59
+ *
60
+ * @param array $in Array of currently selected navigation parameters.
61
+ * @param array $used Array of all navigation parameters currently in use for this calendar view.
62
+ * @param array $params Parameters specifying this view.
63
+ *
64
+ * @return array
65
+ */
66
+ function mc_add_custom_nav ( $ in , $ used , $ params ) {
67
+ $ in [] = 'my_custom_nav_item ' ;
68
+
69
+ return $ in ;
70
+ }
71
+ add_filter ( 'mc_header_navigation ' , 'mc_add_custom_nav ' , 10 , 3 );
0 commit comments