I'm developing a WordPress plugin that allows sending a short code into the rich text editor. Assuming the short code content is stored inside shortcode variable, the following code works perfectly:
tinyMCE.execCommand('mceInsertContent', false, shortcode);
...if the user is in "Visual Editor" mode. If they switch to "Plain Text" mode, the code doesn't work anymore - no content appears in the textarea.
Anyone can help? Thanks in advance.
(Ah, if that matters, I have several instance of editors on the same "Add Post" page).
Just got it! Simply do
send_to_editor(shortcode);
this function is located inside media-upload.js, which should be loaded in Edit/Add Post pages.
Related
We're developing a plugin for a client on a Wordpress site. And, for some reason, an excerpt of the clientside javascript of the plugin appears as raw text in the body of the page.
Here is an image of the page with its markdown:
Entire shortcode script:
<?php
/*
Plugin Name: Cata Employee
Plugin URI:
description: Employee Viewer
...
https://pastebin.com/iFiJT0rM
strangely enough, even when removing the clientside javascript, the script still appears as text on the page after a couple refreshes. My guess is it's something cached, and my coworker suggested it's being caused by SEO stuff of some sort.
What we've tried:
Changing the plugin from a Cornerstone Element to a Shortcode
Adding a function to the script that hides the text (only some of the lines of the text are in targetable elements, and they share a direct parent with the plugin itself, so we can't just hide the whole tree)
Making the plugin the only element on the page
Might seem redundant, but desired behavior needs to be explicitly stated:
Observed Behavior:
A snip of the clientside javascript appears as text on the page
Desired Behavior:
Not having a snip of the clientside javascript appear as text on the page
Any advice or solutions would be greatly appreciated; we really have no idea what's causing this
I'm working on a TinyMCE client request. In TinyMCE, a user inputs a url into the editor. (Let's say www.google.com). The user saves the input and "www.google.com" is rendered as plain text inside of a p tag. How can I make this url clickable? Our application is using TinyMCE version 3.5. I would very much appreciate some guidance here as I'm new to the inner workings of TinyMCE. Thank you.
If you've upgraded to TinyMCE 4, add plugins: "autolink" to your TinyMCE init function.
If not, http://www.tinymce.com/wiki.php/Plugin3x:autolink
We are new to Umbraco and coding within it, so I thank you in advance for your patience and assistance.
In short, we created a 'test' page utilizing a colorbox pop-up to display a form. It works perfectly in the test page.
When trying to integrate the code into Umbraco, when the "Request Info" button is clicked, the form opens in a full page, and the colorbox does not display.
I would appreciate any assistance that you could provide.
Test link (working):
http://online.saintleo.edu/Colorbox/Untitled-1.html
Example of a page where the "Request Info" button (yellow on right) opens full page, and NOT colorbox:
http://online.saintleo.edu/academics/masters-programs/master-of-accounting-(macc).aspx
I've spent the entire weekend trying to find the solution, hoping to get this resolved ASAP.
Thank you in advance, I appreciate your time and assistance.
This looks like a problem with how you have implemented your script in Umbraco. Just looking through Chrome's browser inspector, I can see that your script is failing to find the colorbox objects which means that something is prevent the library from being available. This is usually because a dependent javascript library has failed.
Looking at your source code, you are loading all your jQuery libraries at the bottom of your page. This is good practice, but you have placed your a second jQuery file reference, your colorbox file references and the custom colorbox code in the head of the page.
There are several things you will need to do:
Remove the jQuery reference from the head of the page;
Move the colorbox file references to the bottom of the page, after all the other javascript file references. You can leave the colorbox CSS file reference in the head.
Move the custom colorbox code to after all the other javascript file references. I usually place this kind of code in a separate file.
Depending on your Umbraco implementation:
If you are using masterpages, use a ContentPlaceholder to allow templates to drop javascript file references into the bottom of the page;
If you are using MVC views, use a footer section to do the same
I am using Sitefinity 6.X . The requirement is to create a photo gallery.But Sitefinity does not seem to work with javascript /jquery. I am always getting the error "Function Not defined", even though i included references to all jQueries.
Experts help is much appreciated.
If you are using Sitefinity 6.x go to Widget section drag JavaScript widget from Script and Style Widget and embed your JavaScript/Jquery. There will be a choice to embed your script in html. Please select "Before the closing body" option or "Where the widget is dropped".
Refresh your page again. You will be able to see your photo gallery /Carousel running.
-Rengaseshan
First drag and drop the JavaScript widget
Second either link the file or paste your JavaScript code in the widget
Finally, click more options at the bottom and select the option of inserting your code Before the Closing tag
As a rule of thumb always have JavaScript code/files just before the end of the body tag
I've tried creating a new post on my Wordpress blog and I've pasted an external code from a site, which has a <script src="..."></script> in order to work.
When I publish my post, the script tag simply gets deleted.
Is this a default behavior in Wordpress? Is there any way to avoid this? (preferably without doing any modifications to Wordpress or using inline code).
No this is not default behaviour in wordpress. I have added <script> tags to the html view of a page or post no problem.
Did you switch the view after you add the code ? If so, don't. Wordpress will delete all tags if you switch to view back from HTML.
Like Tim said, you probably posted the code into the Visual Editor (doesn't accept any HTML tags, like scripts). You should to the HTML editor to implement your code, but if you want to have it on more than one page, you should open up the Appearance Editor and paste it into your theme where you need it (most likely in the header).
If you put the script code in html and then switch to the visual editor, it will delete the script. This is a commonly reported problem and is the default behavior of wp.
Wordpress assigns Roles to Users, Users who are either Administrators or Editors can add javascript codes within posts. If the User's role is Author or Contributor then they can not add javascript codes inside posts, even if these users try to add Javascript in HTML mode, wordpress automatically removes the tags.