giannit
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: How to properly hide the div of an inline collapsible button?Ok, so let me summarize the problem.
PROBLEM: When placing the
divassociated with the button, the wpautop function encapsulates the surrounding obects in up to 2ptags which add up to 2 empty lines in the ouput (1 line above thedivand/or 1 line under thediv).All these empty lines are both ugly to see and worsen the fruition of the site, hence I want to get rid of them in a proper way.
Forum: Fixing WordPress
In reply to: How to properly hide the div of an inline collapsible button?Moderator could you let me edit the thread since I have to fix the codes spacing, the titles of the sections and the bold words?
Forum: Fixing WordPress
In reply to: Place a button and its div with one commandI forgot to say that the content of the button, ie what is written inside the div, should also be possibile to be a wordpress shortcode.
The approach shown in this example works good except that is doesn’t allow shortcode as content. I tried it on my site, but if I put a shortcode in the data-message, for example
data-message="[myshortcode]", then when I click on the button it just shows[myshortcode]not what’s inside the shortcode.SOmebody knows a workaround?
- This reply was modified 6 years, 7 months ago by giannit.
Instead of trying to remove the automatically added paragraphs before or after the fact, the solution is to remove the wpautop filter from the_content within the shortcode (and re-adding it to maintain consistency for other plugins etc.):
add_shortcode( 'test', 'test_sc' ); function test_sc( $atts ){ remove_filter( 'the_content', 'wpautop' ); $content = apply_filters( 'the_content', '$\frac{15}{5} = 3$' ); add_filter( 'the_content', 'wpautop' ); return $content; }This is what I tried so far in details (all the following codes were placed in
functions.phpfile)————————–
remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop' , 99); add_filter( 'the_content', 'shortcode_unautop',100 ); add_shortcode( 'test', 'test_sc' ); function test_sc( $atts ){ return apply_filters( 'the_content', '$\frac{15}{5} = 3$' ); }————————–
function wpex_clean_shortcodes($content){ $array = array ( '<p>[' => '[', ']</p>' => ']', ']<br />' => ']' ); $content = strtr($content, $array); return $content; } add_filter('the_content', 'wpex_clean_shortcodes'); add_shortcode( 'test', 'test_sc' ); function test_sc( $atts ){ return wpex_clean_shortcodes(apply_filters( 'the_content','$\frac{15}{5} = 3$' )); }————————–
add_shortcode( 'test', 'test_sc' ); function test_sc( $atts ){ $content = apply_filters( 'the_content','$\frac{15}{5} = 3$' ); $content = shortcode_unautop($content); return $content; }————————–
add_shortcode( 'test', 'test_sc' ); function test_sc( $atts ){ $content = apply_filters( 'the_content','$\frac{15}{5} = 3$' ); return do_shortcode(wpautop($content)); }————————–
add_shortcode( 'test', 'test_sc' ); function test_sc( $atts ){ return apply_filters( 'the_content','$\frac{15}{5} = 3$' ); } add_filter( 'the_content', 'shortcode_empty_paragraph_fix' ); function shortcode_empty_paragraph_fix( $content ) { // define your shortcodes to filter, '' filters all shortcodes $shortcodes = array( 'test' ); foreach ( $shortcodes as $shortcode ) { $array = array ( '<p>[' . $shortcode => '[' .$shortcode, '<p>[/' . $shortcode => '[/' .$shortcode, $shortcode . ']</p>' => $shortcode . ']', $shortcode . ']<br />' => $shortcode . ']' ); $content = strtr( $content, $array ); } return $content; }————————–
In all the previous cases, what gets displayed is

and the HTML is
<p>the fraction </p><p><img ...></p> equals a natural number<p></p>I would like that the shortcode would not be wrapped in p tags, how to get rid of them?
Thank you @joyously for reply.
Using the codereturn apply_filters( 'the_content', '$\frac{15}{5} = 3$' );the content is displayed correctyle, anyway it is wrapped inside<p>tags.
I’m trying to avoid this but none of the following worked, you have any suggestion?What I tried so far
-
remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop' , 99); add_filter( 'the_content', 'shortcode_unautop',100 ); -
function wpex_clean_shortcodes($content){ $array = array ( '<p>[' => '[', ']</p>' => ']', ']<br />' => ']' ); $content = strtr($content, $array); return $content; } add_filter('the_content', 'wpex_clean_shortcodes'); -
$content = '<div class="two-column">'.$content.'</div>'; $content = shortcode_unautop($content); return $content; -
return do_shortcode(wpautop($content)); - Shortcode Empty Paragraph Fix plugin
- This reply was modified 6 years, 7 months ago by giannit.
I found out that by using the code
return apply_filters( 'the_content', '$\frac{15}{5} = 3$' );the formula is showed correctly, but as side effect it is displayed inside
<p>tags, and so a sentence such asthis is [test] a fractiongets displayed in 3 lines (the first one contains
this is, the second one contains the formula, the third one containsa fraction).
Is it possible to show it without the p tags?Forum: Developing with WordPress
In reply to: Navigate through the posts using keyboard arrowsThank you @ronaldvw for answer it works
Do you think it would be better for security reasons to place the script inside a IIFE so that the variables will not global?Forum: Developing with WordPress
In reply to: Insert b tag when pressing b button instead of strong tagthe thread can be deleted
i added the button bold using the functionQTags.addButtonIt can be done with this in
function.phpfilefunction my_custom_admin_styles() { echo '<style> #qt_content_center { color: red; } </style>'; } add_action('admin_head', 'my_custom_admin_styles');@bcworkz Thank you very much for support!
I inspected the button with the browser tool and I was easily able to change its color as you can see here

So then I opened the file
style.cssand added this small code.qt_content_center { color: red; }I refreshed the page and I verified that the file was loaded, but the button color was not changed.
This is how the buttons appear in the inspector tool
<div id="ed_toolbar" class="quicktags-toolbar" style="position: absolute; top: 87px; width: 702px;"> <input type="button" id="qt_content_collpasible button" class="ed_button button button-small" value="BTN"> <input type="button" id="qt_content_content" class="ed_button button button-small" value="CON"> <input type="button" id="qt_content_center" class="ed_button button button-small" value="center"> <div>Maybe to style the buttons the code have to be placed in the
functions.phpfile, but there css code doesn’t work, does it?@bcworkz Thank you very much it worked and it is very simple!
Can I ask one more thing? I’m adding QTags button to the WP text editor, and I’d like to customize the color of the buttons.
For example this one
QTags.addButton( 'red', 'red', '<font color=red>', '</font>', '', '', '1' );is showed as
, is it possible to have redwritten in red color ?- This reply was modified 6 years, 7 months ago by giannit.
Forum: Fixing WordPress
In reply to: Font .woff files loaded don’t correspond to the displayed stylesDon’t know why but this solved the problem
@font-face { font-family: "Computer Modern"; src: url('http://localhost/matesvolta/wp-includes/fonts/latex/cmunrm.woff'); } @font-face { font-family: "Computer Modern"; src: url('http://localhost/matesvolta/wp-includes/fonts/latex/cmunti.woff'); font-style: italic; } @font-face { font-family: "Computer Modern"; src: url('http://localhost/matesvolta/wp-includes/fonts/latex/cmunbx.woff'); font-weight: bold; } @font-face { font-family: "Computer Modern"; src: url('http://localhost/matesvolta/wp-includes/fonts/latex/cmunbi.woff'); font-weight: bold; font-style: italic; }@bcworkz I use the Classic Editor plugin, I prefer to have high control on the content.
About
wpautopjust few days ago I installed the pluginToggle wpautopwhich let the user decide to disable that function in a specific post or page.To obtain what is showed in the second image I created 2 simple CSS classes
.div-as-span { margin: -1.5em 0 -1em 0; } .bspace { margin-bottom: 1.5em; }and the HTML is
badp <div class="div-as-span bspace">badp</div> badpHow to create a shortcode whose text is fully customizable? I have a plugin to create blocks of content but I cannot decide the name of the shortcodes.
- This reply was modified 6 years, 8 months ago by giannit.
This seems to solve all the problems
coll = document.getElementsByClassName("col"); conn = document.getElementsByClassName("con"); var i; for (i = 0; i < coll.length; i++) { coll[i].setAttribute('data-id', 'con' + i); conn[i].setAttribute('id', 'con' + i); coll[i].addEventListener("click", function() { this.classList.toggle("active"); var content = document.getElementById(this.getAttribute('data-id')); if (content.style.maxHeight) { content.style.maxHeight = null; } else { content.style.maxHeight = content.scrollHeight + "px"; } }); }