Skip to content

Commit 126ae96

Browse files
author
Renatho De Carli Rosa
committed
Add quick code option to settings and shortcode parameters
It allows to toggle the feature that allows the user to enter in edit mode when double clicking.
1 parent 2562939 commit 126ae96

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

syntaxhighlighter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
104104
'tabsize' => 4,
105105
'toolbar' => 0,
106106
'wraplines' => 1, // 2.x only
107+
'quickcode' => 1,
107108
) );
108109

109110
// Create the settings array by merging the user's settings and the defaults
@@ -1038,6 +1039,9 @@ function maybe_output_scripts() {
10381039
if ( 1 != $this->settings['wraplines'] )
10391040
echo " SyntaxHighlighter.defaults['wrap-lines'] = false;\n";
10401041

1042+
if ( 1 != $this->settings['quickcode'] )
1043+
echo " SyntaxHighlighter.defaults['quick-code'] = false;\n";
1044+
10411045
?> SyntaxHighlighter.all();
10421046

10431047
// Infinite scroll support
@@ -1114,6 +1118,7 @@ function shortcode_callback( $atts, $code = '', $tag = false ) {
11141118
'title' => $this->settings['title'],
11151119
'toolbar' => false,
11161120
'wraplines' => false,
1121+
'quickcode' => false,
11171122
), $atts ) );
11181123

11191124
// Check for language shortcode tag such as [php]code[/php]
@@ -1171,6 +1176,7 @@ function shortcode_callback( $atts, $code = '', $tag = false ) {
11711176
'smarttabs' => 'smart-tabs',
11721177
'tabsize' => 'tab-size',
11731178
'wraplines' => 'wrap-lines',
1179+
'quickcode' => 'quick-code',
11741180
);
11751181

11761182
// Allowed configuration parameters and their type
@@ -1191,6 +1197,7 @@ function shortcode_callback( $atts, $code = '', $tag = false ) {
11911197
'title' => 'other',
11921198
'toolbar' => 'boolean',
11931199
'wrap-lines' => 'boolean',
1200+
'quick-code' => 'boolean',
11941201
) );
11951202

11961203
$title = '';
@@ -1392,6 +1399,7 @@ function settings_page() { ?>
13921399
<label for="syntaxhighlighter-light"><input name="syntaxhighlighter_settings[light]" type="checkbox" id="syntaxhighlighter-light" value="1" <?php checked( $this->settings['light'], 1 ); ?> /> <?php _e( 'Use the light display mode, best for single lines of code', 'syntaxhighlighter' ); ?></label><br />
13931400
<label for="syntaxhighlighter-smarttabs"><input name="syntaxhighlighter_settings[smarttabs]" type="checkbox" id="syntaxhighlighter-smarttabs" value="1" <?php checked( $this->settings['smarttabs'], 1 ); ?> /> <?php _e( 'Use smart tabs allowing tabs being used for alignment', 'syntaxhighlighter' ); ?></label><br />
13941401
<label for="syntaxhighlighter-wraplines"><input name="syntaxhighlighter_settings[wraplines]" type="checkbox" id="syntaxhighlighter-wraplines" value="1" <?php checked( $this->settings['wraplines'], 1 ); ?> /> <?php _e( 'Wrap long lines (v2.x only, disabling this will make a scrollbar show instead)', 'syntaxhighlighter' ); ?></label><br />
1402+
<label for="syntaxhighlighter-quickcode"><input name="syntaxhighlighter_settings[quickcode]" type="checkbox" id="syntaxhighlighter-quickcode" value="1" <?php checked( $this->settings['quickcode'], 1 ); ?> /> <?php _e( 'Enable edit mode on double click', 'syntaxhighlighter' ); ?></label><br />
13951403
<!--<label for="syntaxhighlighter-htmlscript"><input name="syntaxhighlighter_settings[htmlscript]" type="checkbox" id="syntaxhighlighter-htmlscript" value="1" <?php checked( $this->settings['htmlscript'], 1 ); ?> /> <?php _e( 'Enable &quot;HTML script&quot; mode by default (see the bottom of this page for details). Checking this box is not recommended as this mode only works with certain languages.', 'syntaxhighlighter' ); ?></label>-->
13961404
</fieldset>
13971405
</td>
@@ -1516,6 +1524,7 @@ function settings_page() { ?>
15161524
<li><?php printf( _x( '%1$s (v3 only) &#8212; Sets some text to show up before the code. Very useful when combined with the %2$s parameter.', 'title parameter', 'syntaxhighlighter' ), '<code>title</code>', '<code>collapse</code>' ); ?></li>
15171525
<li><?php printf( _x( '%s &#8212; Toggle the toolbar (buttons in v2, the about question mark in v3)', 'toolbar parameter', 'syntaxhighlighter' ), '<code>toolbar</code>' ); ?></li>
15181526
<li><?php printf( _x( '%s (v2 only) &#8212; Toggle line wrapping.', 'wraplines parameter', 'syntaxhighlighter'), '<code>wraplines</code>' ); ?></li>
1527+
<li><?php printf( _x( '%s &#8212; Enable edit mode on double click.', 'quickcode parameter', 'syntaxhighlighter' ), '<code>quickcode</code>' ); ?></li>
15191528
</ul>
15201529

15211530
<p><?php _e( 'Some example shortcodes:', 'syntaxhighlighter' ); ?></p>
@@ -1553,6 +1562,7 @@ function validate_settings( $settings ) {
15531562
$settings['smarttabs'] = ( ! empty($settings['smarttabs']) ) ? 1 : 0;
15541563
$settings['toolbar'] = ( ! empty($settings['toolbar']) ) ? 1 : 0; // May be overridden below
15551564
$settings['wraplines'] = ( ! empty($settings['wraplines']) ) ? 1 : 0; // 2.x only for now
1565+
$settings['quickcode'] = ( ! empty($settings['quickcode']) ) ? 1 : 0;
15561566

15571567
// If the version changed, then force change the toolbar version setting
15581568
if ( $settings['shversion'] != $this->settings['shversion'] ) {

0 commit comments

Comments
 (0)