-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add quick code option to settings and shortcode parameters #126
Changes from 1 commit
126ae96
53143c6
0afc0e6
9e736a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+ | |
'tabsize' => 4, | ||
'toolbar' => 0, | ||
'wraplines' => 1, // 2.x only | ||
'quickcode' => 1, | ||
) ); | ||
|
||
// Create the settings array by merging the user's settings and the defaults | ||
|
@@ -1038,6 +1039,9 @@ function maybe_output_scripts() { | |
if ( 1 != $this->settings['wraplines'] ) | ||
echo " SyntaxHighlighter.defaults['wrap-lines'] = false;\n"; | ||
|
||
if ( 1 != $this->settings['quickcode'] ) | ||
echo " SyntaxHighlighter.defaults['quick-code'] = false;\n"; | ||
|
||
?> SyntaxHighlighter.all(); | ||
|
||
// Infinite scroll support | ||
|
@@ -1114,6 +1118,7 @@ function shortcode_callback( $atts, $code = '', $tag = false ) { | |
'title' => $this->settings['title'], | ||
'toolbar' => false, | ||
'wraplines' => false, | ||
'quickcode' => false, | ||
), $atts ) ); | ||
|
||
// Check for language shortcode tag such as [php]code[/php] | ||
|
@@ -1171,6 +1176,7 @@ function shortcode_callback( $atts, $code = '', $tag = false ) { | |
'smarttabs' => 'smart-tabs', | ||
'tabsize' => 'tab-size', | ||
'wraplines' => 'wrap-lines', | ||
'quickcode' => 'quick-code', | ||
); | ||
|
||
// Allowed configuration parameters and their type | ||
|
@@ -1191,6 +1197,7 @@ function shortcode_callback( $atts, $code = '', $tag = false ) { | |
'title' => 'other', | ||
'toolbar' => 'boolean', | ||
'wrap-lines' => 'boolean', | ||
'quick-code' => 'boolean', | ||
) ); | ||
|
||
$title = ''; | ||
|
@@ -1392,6 +1399,7 @@ function settings_page() { ?> | |
<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 /> | ||
<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 /> | ||
<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 /> | ||
<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 /> | ||
<!--<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 "HTML script" 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>--> | ||
</fieldset> | ||
</td> | ||
|
@@ -1516,6 +1524,7 @@ function settings_page() { ?> | |
<li><?php printf( _x( '%1$s (v3 only) — 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> | ||
<li><?php printf( _x( '%s — Toggle the toolbar (buttons in v2, the about question mark in v3)', 'toolbar parameter', 'syntaxhighlighter' ), '<code>toolbar</code>' ); ?></li> | ||
<li><?php printf( _x( '%s (v2 only) — Toggle line wrapping.', 'wraplines parameter', 'syntaxhighlighter'), '<code>wraplines</code>' ); ?></li> | ||
<li><?php printf( _x( '%s — Enable edit mode on double click.', 'quickcode parameter', 'syntaxhighlighter' ), '<code>quickcode</code>' ); ?></li> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! I took the opportunity to fix all occurrences. Maybe I could do it in another PR, but as I was changing some of these texts, I think it also makes sense to be in this PR. Makes sense to you? If you think not, I can split ;) |
||
</ul> | ||
|
||
<p><?php _e( 'Some example shortcodes:', 'syntaxhighlighter' ); ?></p> | ||
|
@@ -1553,6 +1562,7 @@ function validate_settings( $settings ) { | |
$settings['smarttabs'] = ( ! empty($settings['smarttabs']) ) ? 1 : 0; | ||
$settings['toolbar'] = ( ! empty($settings['toolbar']) ) ? 1 : 0; // May be overridden below | ||
$settings['wraplines'] = ( ! empty($settings['wraplines']) ) ? 1 : 0; // 2.x only for now | ||
$settings['quickcode'] = ( ! empty($settings['quickcode']) ) ? 1 : 0; | ||
|
||
// If the version changed, then force change the toolbar version setting | ||
if ( $settings['shversion'] != $this->settings['shversion'] ) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use
esc_html_e( ... )
hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I took the opportunity to fix all occurrences.
c3debae
Maybe I could do it in another PR, but as I was changing some of these texts, I think it also makes sense to be in this PR. Makes sense to you? If you think not, I can split ;)