Created
June 5, 2017 23:02
-
-
Save jocastaneda/881776acd2b10b9067bd0317562483c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Kalunder | |
Plugin URI: http://blog.josemcastaneda.comn | |
Description: Adds the shortcode kalunder so that you can display the WordPress calendar to any post, page or custom post type. | |
Author: Jose Castaneda | |
Version: 1.0.0 | |
Author URI: https://blog.josemcastaneda.com | |
*/ | |
add_shortcode( 'kalunder', 'jc_get_cal' ); | |
function jc_get_cal( $atts ) { | |
// set a unique ID for the calendar. | |
$id = uniqid( 'wp-calendar-' ); | |
//get the calendar. | |
$cal = get_calendar( false, false ); | |
// replace the ID. | |
$cal = str_replace( 'id="wp-calendar"', 'id="' . $id . '"', $cal ); | |
// Set a wrapper. | |
$out = sprintf( '<div class="calendar_wrap" id="calendar-%1$s">%2$s</div>', | |
get_the_ID(), | |
$cal | |
); | |
// finally return it. | |
return $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment