-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtablapad_main.php
More file actions
58 lines (44 loc) · 1.52 KB
/
tablapad_main.php
File metadata and controls
58 lines (44 loc) · 1.52 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
<?php
/*
Plugin Name: TablaPad
Plugin URI: http://www.rishiverma.com/software/tablapad
Description: Plugin to transform your WordPress blog into an intuitive Tabla Notebook
Author: Rishi Verma
Version: 0.1
Author URI: http://www.rishiverma.com
*/
// CONSTANTS
define( 'WPS_BASE_URL', plugin_dir_url( __FILE__ ) );
// IMPORTS
wp_enqueue_style('tablapad-styles', WPS_BASE_URL . 'css/tablapad-styles.css');
wp_enqueue_style('google-fonts-indieflower',
'http://fonts.googleapis.com/css?family=Indie+Flower');
// HANDLERS
add_shortcode('tabla', 'tabla_shortcode_handler');
/* Handles the [tabla] shortcode.
Some key operations are listed:
- capitalize each bole within the block
- beautify the font within the block
- add a div border and background to the block
*/
function tabla_shortcode_handler($attributes, $content) {
// (todo: enable configuration from a settings page)
// clean up content
$content = preg_replace('/<[^>]*>/', '', $content); //remove HTML tags
// identify boles
$content = preg_replace('/\./', ' | ', $content); // convert end of line markers
$boles = explode(' ', $content);
// transform boles
$transformed_boles = array();
foreach ($boles as &$bole) {
$bole = ucwords($bole);
array_push($transformed_boles, $bole);
}
$content = implode(' ', $transformed_boles);
// add HTML <p> and <br> markers
$content = wpautop($content, true);
// for CSS styling
$content = "<div class='tabla_composition'>" . $content . "</div>";
return $content;
}
?>