-
Notifications
You must be signed in to change notification settings - Fork 4
/
bybrick-columns.php
executable file
·149 lines (120 loc) · 5.13 KB
/
bybrick-columns.php
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
<?php
/*
Plugin Name: byBrick Columns
Plugin URI: https://github.com/byBrick/byBrick-Columns-Plugin
Description: A plugin that enables for column based shortcodes.
Version: 1.4
Author: byBrick
Author URI: http://www.bybrick.se/
License: GNU General Public License (GPLv3)
*/
/**
* Our shortcodes
*
*/
function bb_one_third( $atts, $content = null ) {
return '<div class="one_third bbcol">' . do_shortcode($content) . '</div>';
}
function bb_one_third_last( $atts, $content = null ) {
return '<div class="one_third column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_two_third( $atts, $content = null ) {
return '<div class="two_third bbcol">' . do_shortcode($content) . '</div>';
}
function bb_two_third_last( $atts, $content = null ) {
return '<div class="two_third column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_one_half( $atts, $content = null ) {
return '<div class="one_half bbcol">' . do_shortcode($content) . '</div>';
}
function bb_one_half_last( $atts, $content = null ) {
return '<div class="one_half column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_one_fourth( $atts, $content = null ) {
return '<div class="one_fourth bbcol">' . do_shortcode($content) . '</div>';
}
function bb_one_fourth_last( $atts, $content = null ) {
return '<div class="one_fourth column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_three_fourth( $atts, $content = null ) {
return '<div class="three_fourth bbcol">' . do_shortcode($content) . '</div>';
}
function bb_three_fourth_last( $atts, $content = null ) {
return '<div class="three_fourth column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_one_fifth( $atts, $content = null ) {
return '<div class="one_fifth bbcolh">' . do_shortcode($content) . '</div>';
}
function bb_one_fifth_last( $atts, $content = null ) {
return '<div class="one_fifth column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_two_fifth( $atts, $content = null ) {
return '<div class="two_fifth bbcol">' . do_shortcode($content) . '</div>';
}
function bb_two_fifth_last( $atts, $content = null ) {
return '<div class="two_fifth column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_three_fifth( $atts, $content = null ) {
return '<div class="three_fifth bbcol">' . do_shortcode($content) . '</div>';
}
function bb_three_fifth_last( $atts, $content = null ) {
return '<div class="three_fifth column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_four_fifth( $atts, $content = null ) {
return '<div class="four_fifth bbcol">' . do_shortcode($content) . '</div>';
}
function bb_four_fifth_last( $atts, $content = null ) {
return '<div class="four_fifth column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_one_sixth( $atts, $content = null ) {
return '<div class="one_sixth bbcol">' . do_shortcode($content) . '</div>';
}
function bb_one_sixth_last( $atts, $content = null ) {
return '<div class="one_sixth column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
function bb_five_sixth( $atts, $content = null ) {
return '<div class="five_sixth bbcol">' . do_shortcode($content) . '</div>';
}
function bb_five_sixth_last( $atts, $content = null ) {
return '<div class="five_sixth column-last bbcol">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
$bbcodes = array('one_third', 'one_third_last', 'two_third', 'two_third_last', 'one_half', 'one_half_last', 'one_fourth', 'one_fourth_last', 'three_fourth', 'three_fourth_last', 'one_fifth', 'one_fifth_last', 'two_fifth', 'two_fifth_last', 'three_fifth', 'three_fifth_last', 'four_fifth', 'four_fifth_last', 'one_sixth', 'one_sixth_last', 'five_sixth', 'five_sixth_last');
function bb_make_shortcodes() {
foreach ($GLOBALS["bbcodes"] as $bbcode) {
$function_name = "bb_" . $bbcode;
add_shortcode($bbcode, $function_name);
}
};
add_action('init', 'bb_make_shortcodes');
/**
* Load our files
*
*/
function bb_scripts() {
wp_enqueue_style( 'bybrick-columns', plugins_url() . '/bybrick-columns/css/bybrick-columns-style.css' );
wp_enqueue_script( 'bybrick-columns', plugins_url() . '/bybrick-columns/js/bybrick-columns-frontend.js', array( 'jquery' ), '20120206', true );
}
add_action( 'wp_enqueue_scripts', 'bb_scripts' );
/**
* Button in TinyMCE
*
*/
function register_button( $buttons ) {
array_push( $buttons, "|", "columns" );
return $buttons;
}
function add_plugin( $plugin_array ) {
$plugin_array['columns'] = plugins_url('/js/bybrick-columns-backend.js', __FILE__);
return $plugin_array;
}
function bb_columns_button() {
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
return;
}
if ( get_user_option('rich_editing') == 'true' ) {
add_filter( 'mce_external_plugins', 'add_plugin' );
add_filter( 'mce_buttons', 'register_button' );
}
}
add_action('init', 'bb_columns_button');
?>