crosp
Forum Replies Created
-
Here is my quick & dirty solution that doesn’t require modification of source files.
var SubscriptionHandler = (function ($) { var handleSubscribeRequest = function (xhr, options) { var originalSuccessCallback = options.success; options.success = function (data, textStatus, jqXhr) { alert("SUCCESS !!"); //originalSuccessCallback.apply(this, arguments) } }; var interceptAjaxRequest = function () { $.ajaxSetup({ beforeSend: function (xhr, options) { if (options.data.startsWith("action=wysija_ajax")) { handleSubscribeRequest(xhr, options); } } }); }; var init = function () { interceptAjaxRequest(); }; return { init: init } })($);
In case you want to modify source code of the plugin. This is handled inside
plugins/wysija-newsletters/js/front-subscribers.js
Here is the part.
$.ajax({ type: "post", url: wysijaAJAX.ajaxurl, data: wysijaAJAX, success: function (response) {
But be ready to modify obfuscated code)
Hope this helps someone.
- This reply was modified 7 years, 11 months ago by crosp.
Forum: Reviews
In reply to: [Accordion Categories] Great WidgetThanks for your feedback. Appreciate it.
Forum: Fixing WordPress
In reply to: Bug in wp_html_split with unclosed PHP tagPlease review my ticket https://core.trac.www.ads-software.com/ticket/39153#no0 , it has not been reviewed for 5 weeks.
Forum: Fixing WordPress
In reply to: Bug in wp_html_split with unclosed PHP tagI forgot to mention, the problem disappears when closing tag for PHP snippet
?>
is added.Forum: Fixing WordPress
In reply to: WordPress PHP code in post content BUGThanks for answer. As far as I am creating my own plugin, I have done $content dump a lot of times.
Lets clarify all moments.
I am using Text Editor for post, not Visual, because Visual one adds some markup.
1. As I’ve described, to be sure that my plugin or any other plugin can cause this problem, I installed pure wordpress distro. But the problem still exists. Without any plugin. You can try by your own. If tag is not closed all content after code snippet starts to look weird.2. Here are images that I posted earlier (but inserted incorrect link)
First :
Second:
Third:
3. My plugin just takes code between shortcodes, processes it, saves to db and than output formatted code.
Here is unformatted code :
[code-highlight line-numbers="table" linenostart="53" highlight-lines="1,3,8" style="native" lang="html+php" pyg-id="1" ] <?php //This callback registers our plug-in function wpse72394_register_tinymce_plugin($plugin_array) { $plugin_array['wpse72394_button'] = 'path/to/shortcode.js'; return $plugin_array; } //This callback adds our button to the toolbar function wpse72394_add_tinymce_button($buttons) { //Add the button ID to the $button array $buttons[] = "wpse72394_button"; return $buttons; } ?>[/code-highlight]
And now formatted code that goes directly to the output
<table class="highlighted-source native html-php table"><tr><td class="linenos"><div class="linenodiv"><pre>53 54 55 56 57 58 59 60 61 62 63 64 65 66</pre></div></td><td class="code"><div class="highlighted-source native html-php "><pre><span></span><span class="hll"><span class="cp"><?php</span> </span><span class="c1">//This callback registers our plug-in</span> <span class="hll"><span class="k">function</span> <span class="nf">wpse72394_register_tinymce_plugin</span><span class="p">(</span><span class="nv">$plugin_array</span><span class="p">)</span> <span class="p">{</span> </span> <span class="nv">$plugin_array</span><span class="p">[</span><span class="s1">'wpse72394_button'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'path/to/shortcode.js'</span><span class="p">;</span> <span class="k">return</span> <span class="nv">$plugin_array</span><span class="p">;</span> <span class="p">}</span> <span class="hll"><span class="c1">//This callback adds our button to the toolbar</span> </span><span class="k">function</span> <span class="nf">wpse72394_add_tinymce_button</span><span class="p">(</span><span class="nv">$buttons</span><span class="p">)</span> <span class="p">{</span> <span class="c1">//Add the button ID to the $button array</span> <span class="nv">$buttons</span><span class="p">[]</span> <span class="o">=</span> <span class="s2">"wpse72394_button"</span><span class="p">;</span> <span class="k">return</span> <span class="nv">$buttons</span><span class="p">;</span> <span class="p">}</span> <span class="cp">?></span> </pre></div> </td></tr></table>
This code works because of
<span class="cp">?></span>
Again this problem is not in my plugin.4. It doesn’t work even with following HTML `<span><</span><span>?</span>php</span>
</span>` content is just missing, only one line after code snippet is present, no html at all than.Maybe I am going crazy but I have no idea what is wrong. I am not aware of each core part of WordPress maybe there is core filter that tries to fix unclosed tags ..
[Moderator note: Please, no bumping.]
- This reply was modified 8 years, 4 months ago by crosp.
- This reply was modified 8 years, 4 months ago by crosp.
- This reply was modified 8 years, 4 months ago by Steven Stern (sterndata).
Forum: Fixing WordPress
In reply to: WordPress PHP code in post content BUGI am doing exactly as you’ve suggested. I using custom shortcode in text mode (because in visual mode TinyMCE will automatically add html markup to the code, but I don’t need this because my plugin will do this work)
[code-highlight line-numbers="table" linenostart="53" highlight-lines="1,3,8" style="native" lang="html+php" pyg-id="1" ] <?php //This callback registers our plug-in function wpse72394_register_tinymce_plugin($plugin_array) { $plugin_array['wpse72394_button'] = 'path/to/shortcode.js'; return $plugin_array; } //This callback adds our button to the toolbar function wpse72394_add_tinymce_button($buttons) { //Add the button ID to the $button array $buttons[] = "wpse72394_button"; return $buttons; } ?> [/code-highlight]
Here is an example of full my code, it is displayed correctly but in case of missing closing tag the behavior is the same. Next part of the post after the code snippet with unclosed tag is missed.
As I’ve already explained even if php tag insidespan
or any other tag without closing tag it doesn’t work.Forum: Fixing WordPress
In reply to: WordPress PHP code in post content BUGThank you for you reply, I am not trying to execute php code, I just want to include in my post and in my case with the help of my plugin to highlight.
For example post explaining how to build wordpress plugin. I need to include some code snippets, consider my example and if I miss PHP end tag (?>) than I will get weird behavior as described earlier.Forum: Fixing WordPress
In reply to: WordPress PHP code in post content BUGI got following result
In this case php tag is unclosed, and everything after code disappears, so we won’t see neither 5 nor 6 sentence.
In case of wrapping this code inside
code
tag like that<code><?php //This callback registers our plug-in echo "HELLO I AM BUG"; function wpse72394_register_tinymce_plugin($plugin_array) { $plugin_array['wpse72394_button'] = 'path/to/shortcode.js'; return $plugin_array; } //This callback adds our button to the toolbar function wpse72394_add_tinymce_button($buttons) { //Add the button ID to the $button array $buttons[] = "wpse72394_button"; return $buttons; }</code>
The result is following
And if I close php tag it will be displayed without this code here it is
You may say you have wrap the code into HTML/CSS tags.
I am currently on the stage of creating my own plugin for syntax highlighting, but here is an example of formatted code
<span class="cp"><?php</span> </span><span class="c1">//This callback registers our plug-in</span> <span class="hll"><span class="k">function</span> <span class="nf">wpse72394_register_tinymce_plugin</span><span class="p">(</span><span class="nv">$plugin_array</span><span class="p">)</span> <span class="p">{</span> </span> <span class="nv">$plugin_array</span><span class="p">[</span><span class="s1">'wpse72394_button'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'path/to/shortcode.js'</span><span class="p">;</span> <span class="k">return</span> <span class="nv">$plugin_array</span><span class="p">;</span> <span class="p">}</span>
Please note
<span class="cp"><?php</span>
but STILL problem exists even if php tag is wrapped insidespan
tag in this case.I thought that it would be problem with some plugins that use
the_content
filter, but I’ve just set up new installation of WordPress completely clean (all examples were tested with it).Is this is problem with WordPress or maybe browser.
Please share your thoughts.
Thanks
Forum: Fixing WordPress
In reply to: WordPress PHP code in post content BUGI don’t want it to work. I have good understanding of what is happening in browser, server side….
Please see my updated post, I’ve accidentally submitted the post, and I have no way to edit it.