Skip to content

Instantly share code, notes, and snippets.

@turtlepod
Last active December 15, 2015 23:58
Show Gist options
  • Save turtlepod/5343672 to your computer and use it in GitHub Desktop.
Save turtlepod/5343672 to your computer and use it in GitHub Desktop.
Example to filter editor style json style_formats
<?php
function capsule_print_data2(){
/* style dropdown */
$settings = array();
$style_formats = array(
array(
'title' => 'Code',
'inline' => 'code',
),
array(
'title' => 'Clear',
'block' => 'div',
'classes' => 'clear'
),
array(
'title' => 'Info Boxes'
),
);
$settings['style_formats'] = json_encode( $style_formats );
/* new */
$add_style_formats = array(
array(
'title' => 'Buttons'
),
array(
'title' => 'White',
'inline' => 'span',
'classes' => 'button'
),
);
/* merge */
$old_style = json_decode( $settings['style_formats'], true );
$new_style = array_merge( $add_style_formats, $old_style );
$new_settings = $settings;
$new_settings['style_formats'] = json_encode( $new_style );;
ccdd( $settings, '$settings' );
ccdd( $add_style_formats, '$add_style_formats' );
ccdd( $new_style, '$new_style' );
ccdd( $new_settings, '$new_settings' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment