Column Shortcodes - Version 0.6.7

Version Description

  • [Fixed] Paragraphs are added to the columns
Download this release

Release Info

Developer tschutter
Plugin Icon 128x128 Column Shortcodes
Version 0.6.7
Comparing to
See all releases

Code changes from version 0.6.6 to 0.6.7

assets/images/shortcode.png CHANGED
File without changes
assets/js/jquery.ck.js CHANGED
File without changes
column-shortcodes.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /*
4
  Plugin Name: Column Shortcodes
5
- Version: 0.6.6
6
  Description: Adds shortcodes to easily create columns in your posts or pages
7
  Author: Codepress
8
  Author URI: http://www.codepresshq.com/
@@ -27,9 +27,9 @@ along with this program; if not, write to the Free Software
27
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
  */
29
 
30
- define( 'CPSH_VERSION', '0.6.6' );
31
- define( 'CPSH_URL', plugins_url( '', __FILE__ ) );
32
- define( 'CPSH_TEXTDOMAIN', 'column-shortcodes' );
33
 
34
  // Long posts should require a higher limit, see http://core.trac.wordpress.org/ticket/8553
35
  @ini_set( 'pcre.backtrack_limit', 500000 );
@@ -55,7 +55,7 @@ class Codepress_Column_Shortcodes {
55
  */
56
  function __construct() {
57
 
58
- add_action( 'wp_loaded', array( $this, 'init') );
59
  }
60
 
61
  /**
@@ -71,11 +71,11 @@ class Codepress_Column_Shortcodes {
71
  add_action( 'admin_footer', array( $this, 'popup' ) );
72
 
73
  // styling
74
- add_action( 'admin_print_styles', array( $this, 'admin_styles') );
75
- add_action( 'wp_enqueue_scripts', array( $this, 'frontend_styles') );
76
 
77
  // scripts, only load when editor is available
78
- add_filter( 'tiny_mce_plugins', array( $this, 'admin_scripts') );
79
 
80
  // translations
81
  load_plugin_textdomain( CPSH_TEXTDOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
@@ -121,9 +121,10 @@ class Codepress_Column_Shortcodes {
121
  public function frontend_styles() {
122
  if ( apply_filters( 'cpsh_load_styles', true ) ) {
123
  if ( ! is_rtl() ) {
124
- wp_enqueue_style( 'cpsh-shortcodes', CPSH_URL.'/assets/css/shortcodes.css', array(), CPSH_VERSION, 'all' );
125
- } else {
126
- wp_enqueue_style( 'cpsh-shortcodes-rtl', CPSH_URL.'/assets/css/shortcodes-rtl.css', array(), CPSH_VERSION, 'all' );
 
127
  }
128
  }
129
  }
@@ -147,42 +148,46 @@ class Codepress_Column_Shortcodes {
147
  * @param array $atts
148
  * @param string $content
149
  * @param string $name
 
150
  * @return string $ouput Column HTML output
151
  */
152
- function columns( $atts, $content = null, $name='' ) {
153
 
154
  $atts = shortcode_atts( array(
155
- "id" => '',
156
- "class" => '',
157
- "padding" => '',
158
  ), $atts );
159
 
160
- $id = sanitize_text_field( $atts['id'] );
161
- $class = sanitize_text_field( $atts['class'] );
162
  $padding = sanitize_text_field( $atts['padding'] );
163
 
164
- $id = ( $id <> '' ) ? " id='" . esc_attr( $id ) . "'" : '';
165
- $class = ( $class <> '' ) ? esc_attr( ' ' . $class ) : '';
166
 
167
  $content = $this->content_helper( $content );
168
 
169
  // padding generator
170
  if ( $padding <> '' ) {
171
- $parts = explode(" ", $padding);
172
 
173
  // check for '0' values. if true we will split padding attributes into top,right,bottom and left.
174
  if ( $parts && in_array( '0', $parts ) ) {
175
- $padding = !empty( $parts[0] ) ? "padding-top:{$parts[0]};" : '';
176
- $padding .= !empty( $parts[1] ) ? "padding-right:{$parts[1]};" : '';
177
- $padding .= !empty( $parts[2] ) ? "padding-bottom:{$parts[2]};" : '';
178
- $padding .= !empty( $parts[3] ) ? "padding-left:{$parts[3]};" : '';
179
  }
180
  else {
181
  $padding = "padding:{$padding};";
182
  }
183
 
184
  // wraps the content in an extra div with padding applied
185
- $content = '<div style="' . esc_attr( $padding ) . '">' . $content . '</div>';
 
 
 
186
  }
187
 
188
  // last class
@@ -230,8 +235,9 @@ class Codepress_Column_Shortcodes {
230
  * @since 0.4
231
  */
232
  private function has_permissions() {
233
- if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) )
234
  return true;
 
235
 
236
  return false;
237
  }
@@ -243,11 +249,12 @@ class Codepress_Column_Shortcodes {
243
  */
244
  function add_editor_buttons() {
245
 
246
- if ( ! $this->has_permissions() || ! $this->is_edit_screen() )
247
  return false;
 
248
 
249
  // add html buttons, when using this filter
250
- if( apply_filters( 'add_shortcode_html_buttons', false ) ) {
251
  add_action( 'admin_head', array( $this, 'add_html_buttons' ) );
252
  }
253
 
@@ -265,9 +272,9 @@ class Codepress_Column_Shortcodes {
265
  */
266
  public function add_shortcode_button( $page = null, $target = null ) {
267
  ?>
268
- <a href="#TB_inline?width=640&amp;height=600&amp;inlineId=cpsh-wrap" class="thickbox button" title="<?php _e( 'Select shortcode', CPSH_TEXTDOMAIN ); ?>" data-page="<?php echo $page; ?>" data-target="<?php echo $target; ?>">
269
- <img src="<?php echo CPSH_URL . "/assets/images/shortcode.png";?>" alt="" />
270
- </a>
271
  <?php
272
  }
273
 
@@ -283,8 +290,8 @@ class Codepress_Column_Shortcodes {
283
  $select = '';
284
  foreach ( $buttons as $button ) {
285
 
286
- $open_tag = str_replace( '\n', '', $button['options']['open_tag'] );
287
- $close_tag = str_replace( '\n', '', $button['options']['close_tag'] );
288
 
289
  $select .= "
290
  <a href='javascript:;' rel='{$open_tag}{$close_tag}' data-tag='{$open_tag}{$close_tag}' class='cp-{$button['class']} columns insert-shortcode'>
@@ -305,32 +312,32 @@ class Codepress_Column_Shortcodes {
305
  <?php echo $select; ?>
306
  </div><!--.cpsh-shortcodes-->
307
 
308
- <?php if ( ! apply_filters( 'cpsh_hide_padding_settings', false ) ) : ?>
309
-
310
- <div class="cpsh-settings">
311
- <h2 class="cpsh-title"><?php _e( "Column padding ( optional )", CPSH_TEXTDOMAIN ); ?></h2>
312
- <p class="description">
313
- <?php _e( "Use the input fields below to customize the padding of your column shortcode.", CPSH_TEXTDOMAIN ); ?>
314
- <?php _e( "Enter padding first, then select your column shortcode.", CPSH_TEXTDOMAIN ); ?>
315
- </p>
316
-
317
- <div id="preview-padding">
318
- <div class="column-container">
319
- <div class="column-inner">
 
 
 
 
 
 
 
320
  </div>
321
- <div class="padding-fields">
322
- <input id="padding-top" placeholder="0" value=""/>
323
- <input id="padding-right" placeholder="0" value=""/>
324
- <input id="padding-bottom" placeholder="0" value=""/>
325
- <input id="padding-left" placeholder="0" value=""/>
326
- </div>
327
- </div>
328
 
329
- <a class="padding-reset" href="javascript:;"><?php _e( "reset", CPSH_TEXTDOMAIN ); ?></a>
330
- </div>
331
- </div><!--.cpsh-settings-->
332
 
333
- <?php endif; ?>
334
 
335
  </div><!--cpsh-generator-header-->
336
 
@@ -351,55 +358,59 @@ class Codepress_Column_Shortcodes {
351
  function get_shortcodes() {
352
  static $shortcodes;
353
 
354
- if ( ! empty( $shortcodes ) )
355
  return $shortcodes;
 
356
 
357
  // define column shortcodes
358
  $column_shortcodes = apply_filters( 'cpsh_column_shortcodes', array(
359
- 'full_width' => array( 'display_name' => __('full width', CPSH_TEXTDOMAIN ) ),
360
- 'one_half' => array( 'display_name' => __('one half', CPSH_TEXTDOMAIN ) ),
361
- 'one_third' => array( 'display_name' => __('one third', CPSH_TEXTDOMAIN ) ),
362
- 'one_fourth' => array( 'display_name' => __('one fourth', CPSH_TEXTDOMAIN ) ),
363
- 'two_third' => array( 'display_name' => __('two third', CPSH_TEXTDOMAIN ) ),
364
- 'three_fourth' => array( 'display_name' => __('three fourth', CPSH_TEXTDOMAIN ) ),
365
- 'one_fifth' => array( 'display_name' => __('one fifth', CPSH_TEXTDOMAIN ) ),
366
- 'two_fifth' => array( 'display_name' => __('two fifth', CPSH_TEXTDOMAIN ) ),
367
- 'three_fifth' => array( 'display_name' => __('three fifth', CPSH_TEXTDOMAIN ) ),
368
- 'four_fifth' => array( 'display_name' => __('four fifth', CPSH_TEXTDOMAIN ) ),
369
- 'one_sixth' => array( 'display_name' => __('one sixth', CPSH_TEXTDOMAIN ) ),
370
- 'five_sixth' => array( 'display_name' => __('five sixth', CPSH_TEXTDOMAIN ) )
371
- ));
372
-
373
- if ( ! $column_shortcodes )
374
  return array();
 
375
 
376
  foreach ( $column_shortcodes as $short => $options ) {
377
 
378
  // add prefix
379
  $shortcode = $this->prefix . $short;
380
 
381
- $shortcodes[] = array(
382
- 'name' => $shortcode,
383
- 'class' => $short,
384
- 'options' => array(
385
- 'display_name' => $options['display_name'],
386
- 'open_tag' => '\n'."[{$shortcode}]",
387
- 'close_tag' => "[/{$shortcode}]".'\n',
388
- 'key' => ''
389
- )
390
  );
391
 
392
- if ( 'full_width' == $short ) continue;
393
-
394
- $shortcodes[] = array(
395
- 'name' => "{$shortcode}_last",
396
- 'class' => "{$short}_last",
397
- 'options' => array(
398
- 'display_name' => $options['display_name'] . ' (' . __('last', CPSH_TEXTDOMAIN) . ')',
399
- 'open_tag' => '\n'."[{$shortcode}_last]",
400
- 'close_tag' => "[/{$shortcode}_last]".'\n',
401
- 'key' => ''
402
- )
 
 
403
  );
404
  }
405
 
@@ -448,6 +459,7 @@ class Codepress_Column_Shortcodes {
448
  * @param string $content
449
  * @param bool $paragraph_tag Filter p-tags
450
  * @param bool $br_tag Filter br-tags
 
451
  * @return string Shortcode
452
  */
453
  function content_helper( $content, $paragraph_tag = false, $br_tag = false ) {
2
 
3
  /*
4
  Plugin Name: Column Shortcodes
5
+ Version: 0.6.7
6
  Description: Adds shortcodes to easily create columns in your posts or pages
7
  Author: Codepress
8
  Author URI: http://www.codepresshq.com/
27
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
  */
29
 
30
+ define( 'CPSH_VERSION', '0.6.7' );
31
+ define( 'CPSH_URL', plugins_url( '', __FILE__ ) );
32
+ define( 'CPSH_TEXTDOMAIN', 'column-shortcodes' );
33
 
34
  // Long posts should require a higher limit, see http://core.trac.wordpress.org/ticket/8553
35
  @ini_set( 'pcre.backtrack_limit', 500000 );
55
  */
56
  function __construct() {
57
 
58
+ add_action( 'wp_loaded', array( $this, 'init' ) );
59
  }
60
 
61
  /**
71
  add_action( 'admin_footer', array( $this, 'popup' ) );
72
 
73
  // styling
74
+ add_action( 'admin_print_styles', array( $this, 'admin_styles' ) );
75
+ add_action( 'wp_enqueue_scripts', array( $this, 'frontend_styles' ) );
76
 
77
  // scripts, only load when editor is available
78
+ add_filter( 'tiny_mce_plugins', array( $this, 'admin_scripts' ) );
79
 
80
  // translations
81
  load_plugin_textdomain( CPSH_TEXTDOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
121
  public function frontend_styles() {
122
  if ( apply_filters( 'cpsh_load_styles', true ) ) {
123
  if ( ! is_rtl() ) {
124
+ wp_enqueue_style( 'cpsh-shortcodes', CPSH_URL . '/assets/css/shortcodes.css', array(), CPSH_VERSION, 'all' );
125
+ }
126
+ else {
127
+ wp_enqueue_style( 'cpsh-shortcodes-rtl', CPSH_URL . '/assets/css/shortcodes-rtl.css', array(), CPSH_VERSION, 'all' );
128
  }
129
  }
130
  }
148
  * @param array $atts
149
  * @param string $content
150
  * @param string $name
151
+ *
152
  * @return string $ouput Column HTML output
153
  */
154
+ function columns( $atts, $content = null, $name = '' ) {
155
 
156
  $atts = shortcode_atts( array(
157
+ "id" => '',
158
+ "class" => '',
159
+ "padding" => '',
160
  ), $atts );
161
 
162
+ $id = sanitize_text_field( $atts['id'] );
163
+ $class = sanitize_text_field( $atts['class'] );
164
  $padding = sanitize_text_field( $atts['padding'] );
165
 
166
+ $id = ( $id <> '' ) ? " id='" . esc_attr( $id ) . "'" : '';
167
+ $class = ( $class <> '' ) ? esc_attr( ' ' . $class ) : '';
168
 
169
  $content = $this->content_helper( $content );
170
 
171
  // padding generator
172
  if ( $padding <> '' ) {
173
+ $parts = explode( " ", $padding );
174
 
175
  // check for '0' values. if true we will split padding attributes into top,right,bottom and left.
176
  if ( $parts && in_array( '0', $parts ) ) {
177
+ $padding = ! empty( $parts[0] ) ? "padding-top:{$parts[0]};" : '';
178
+ $padding .= ! empty( $parts[1] ) ? "padding-right:{$parts[1]};" : '';
179
+ $padding .= ! empty( $parts[2] ) ? "padding-bottom:{$parts[2]};" : '';
180
+ $padding .= ! empty( $parts[3] ) ? "padding-left:{$parts[3]};" : '';
181
  }
182
  else {
183
  $padding = "padding:{$padding};";
184
  }
185
 
186
  // wraps the content in an extra div with padding applied
187
+ $content = '<div style="' . esc_attr( $padding ) . '"><p>' . $content . '</p></div>';
188
+ }
189
+ else {
190
+ $content = '<p>' . $content . '</p>';
191
  }
192
 
193
  // last class
235
  * @since 0.4
236
  */
237
  private function has_permissions() {
238
+ if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) {
239
  return true;
240
+ }
241
 
242
  return false;
243
  }
249
  */
250
  function add_editor_buttons() {
251
 
252
+ if ( ! $this->has_permissions() || ! $this->is_edit_screen() ) {
253
  return false;
254
+ }
255
 
256
  // add html buttons, when using this filter
257
+ if ( apply_filters( 'add_shortcode_html_buttons', false ) ) {
258
  add_action( 'admin_head', array( $this, 'add_html_buttons' ) );
259
  }
260
 
272
  */
273
  public function add_shortcode_button( $page = null, $target = null ) {
274
  ?>
275
+ <a href="#TB_inline?width=640&amp;height=600&amp;inlineId=cpsh-wrap" class="thickbox button" title="<?php _e( 'Select shortcode', CPSH_TEXTDOMAIN ); ?>" data-page="<?php echo $page; ?>" data-target="<?php echo $target; ?>">
276
+ <img src="<?php echo CPSH_URL . "/assets/images/shortcode.png"; ?>" alt=""/>
277
+ </a>
278
  <?php
279
  }
280
 
290
  $select = '';
291
  foreach ( $buttons as $button ) {
292
 
293
+ $open_tag = str_replace( '\n', '', $button['options']['open_tag'] );
294
+ $close_tag = str_replace( '\n', '', $button['options']['close_tag'] );
295
 
296
  $select .= "
297
  <a href='javascript:;' rel='{$open_tag}{$close_tag}' data-tag='{$open_tag}{$close_tag}' class='cp-{$button['class']} columns insert-shortcode'>
312
  <?php echo $select; ?>
313
  </div><!--.cpsh-shortcodes-->
314
 
315
+ <?php if ( ! apply_filters( 'cpsh_hide_padding_settings', false ) ) : ?>
316
+
317
+ <div class="cpsh-settings">
318
+ <h2 class="cpsh-title"><?php _e( "Column padding ( optional )", CPSH_TEXTDOMAIN ); ?></h2>
319
+ <p class="description">
320
+ <?php _e( "Use the input fields below to customize the padding of your column shortcode.", CPSH_TEXTDOMAIN ); ?>
321
+ <?php _e( "Enter padding first, then select your column shortcode.", CPSH_TEXTDOMAIN ); ?>
322
+ </p>
323
+
324
+ <div id="preview-padding">
325
+ <div class="column-container">
326
+ <div class="column-inner">
327
+ </div>
328
+ <div class="padding-fields">
329
+ <input id="padding-top" placeholder="0" value=""/>
330
+ <input id="padding-right" placeholder="0" value=""/>
331
+ <input id="padding-bottom" placeholder="0" value=""/>
332
+ <input id="padding-left" placeholder="0" value=""/>
333
+ </div>
334
  </div>
 
 
 
 
 
 
 
335
 
336
+ <a class="padding-reset" href="javascript:;"><?php _e( "reset", CPSH_TEXTDOMAIN ); ?></a>
337
+ </div>
338
+ </div><!--.cpsh-settings-->
339
 
340
+ <?php endif; ?>
341
 
342
  </div><!--cpsh-generator-header-->
343
 
358
  function get_shortcodes() {
359
  static $shortcodes;
360
 
361
+ if ( ! empty( $shortcodes ) ) {
362
  return $shortcodes;
363
+ }
364
 
365
  // define column shortcodes
366
  $column_shortcodes = apply_filters( 'cpsh_column_shortcodes', array(
367
+ 'full_width' => array( 'display_name' => __( 'full width', CPSH_TEXTDOMAIN ) ),
368
+ 'one_half' => array( 'display_name' => __( 'one half', CPSH_TEXTDOMAIN ) ),
369
+ 'one_third' => array( 'display_name' => __( 'one third', CPSH_TEXTDOMAIN ) ),
370
+ 'one_fourth' => array( 'display_name' => __( 'one fourth', CPSH_TEXTDOMAIN ) ),
371
+ 'two_third' => array( 'display_name' => __( 'two third', CPSH_TEXTDOMAIN ) ),
372
+ 'three_fourth' => array( 'display_name' => __( 'three fourth', CPSH_TEXTDOMAIN ) ),
373
+ 'one_fifth' => array( 'display_name' => __( 'one fifth', CPSH_TEXTDOMAIN ) ),
374
+ 'two_fifth' => array( 'display_name' => __( 'two fifth', CPSH_TEXTDOMAIN ) ),
375
+ 'three_fifth' => array( 'display_name' => __( 'three fifth', CPSH_TEXTDOMAIN ) ),
376
+ 'four_fifth' => array( 'display_name' => __( 'four fifth', CPSH_TEXTDOMAIN ) ),
377
+ 'one_sixth' => array( 'display_name' => __( 'one sixth', CPSH_TEXTDOMAIN ) ),
378
+ 'five_sixth' => array( 'display_name' => __( 'five sixth', CPSH_TEXTDOMAIN ) ),
379
+ ) );
380
+
381
+ if ( ! $column_shortcodes ) {
382
  return array();
383
+ }
384
 
385
  foreach ( $column_shortcodes as $short => $options ) {
386
 
387
  // add prefix
388
  $shortcode = $this->prefix . $short;
389
 
390
+ $shortcodes[] = array(
391
+ 'name' => $shortcode,
392
+ 'class' => $short,
393
+ 'options' => array(
394
+ 'display_name' => $options['display_name'],
395
+ 'open_tag' => '\n' . "[{$shortcode}]",
396
+ 'close_tag' => "[/{$shortcode}]" . '\n',
397
+ 'key' => '',
398
+ ),
399
  );
400
 
401
+ if ( 'full_width' == $short ) {
402
+ continue;
403
+ }
404
+
405
+ $shortcodes[] = array(
406
+ 'name' => "{$shortcode}_last",
407
+ 'class' => "{$short}_last",
408
+ 'options' => array(
409
+ 'display_name' => $options['display_name'] . ' (' . __( 'last', CPSH_TEXTDOMAIN ) . ')',
410
+ 'open_tag' => '\n' . "[{$shortcode}_last]",
411
+ 'close_tag' => "[/{$shortcode}_last]" . '\n',
412
+ 'key' => '',
413
+ ),
414
  );
415
  }
416
 
459
  * @param string $content
460
  * @param bool $paragraph_tag Filter p-tags
461
  * @param bool $br_tag Filter br-tags
462
+ *
463
  * @return string Shortcode
464
  */
465
  function content_helper( $content, $paragraph_tag = false, $br_tag = false ) {
languages/column-shortcodes.po CHANGED
File without changes
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Column Shortcodes ===
2
- Contributors: codepress, tschutter, davidmosterd
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J
4
  Tags: columns, column, shortcodes, shortcode, divider, layout, posts, editor, wp-admin, admin, codepress, wordpress
5
  Requires at least: 3.1
6
- Tested up to: 4.1
7
- Stable tag: 0.6.6
8
 
9
  Adds shortcodes to easily create columns in your posts or pages.
10
 
@@ -259,6 +259,9 @@ You will find a .po file in the languages folder which you can use. You can send
259
 
260
  == Changelog ==
261
 
 
 
 
262
  = 0.6.6 =
263
  * [Fixed] Swapped images for 5/6 columns
264
 
1
  === Column Shortcodes ===
2
+ Contributors: codepress, tschutter, davidmosterd, dungengronovius
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDZRSYLQ4Z76J
4
  Tags: columns, column, shortcodes, shortcode, divider, layout, posts, editor, wp-admin, admin, codepress, wordpress
5
  Requires at least: 3.1
6
+ Tested up to: 4.6.1
7
+ Stable tag: 0.6.7
8
 
9
  Adds shortcodes to easily create columns in your posts or pages.
10
 
259
 
260
  == Changelog ==
261
 
262
+ = 0.6.7 =
263
+ * [Fixed] Paragraphs are added to the columns
264
+
265
  = 0.6.6 =
266
  * [Fixed] Swapped images for 5/6 columns
267