Copyright © 2011 Kaltura Inc.
All Rights Reserved. Designated trademarks and brands are the property of their respective owners.
Use of this web site constitutes acceptance of the Terms of Use and Privacy Policy.
EduVideo.org
How to automatically load the wizard
Hi,
You can simulate a real click using JavaScript.
The simplest code looks like this:
Code: Select all
jQuery("#media-buttons a:last").click()
Put the following code in post-new.php file:
Code: Select all
?>
jQuery(function() {
jQuery("#media-buttons a:last").click();
});
<?php
Just above:
Code: Select all
include('admin-footer.php');
The only issue with code that it assume that Kaltura's button is the last one.
Wow, that was easy. Thanks very much, Roman!
Now -- something else -- this is probably more difficult. I want to have the post automatically published upon completion of the wizard. In other words, I want to simulate the pressing of the Publish button upon successful completion of the wizard -- or, should they not successfully complete the wizard, return them to the previous page. My goal here is to avoid displaying the Write form.
Do you want the post to be published after clicking "send to editor"?
Add this code to view/view_send_to_editor.php
Code: Select all
topWindow.jQuery("#publish").click();
Just before
Code: Select all
setTimeout('topWindow.tb_remove()', 0);
BTW,
Write down the changes you are making to the plugin, and to worpdress code so you will be able to upgrade to newer versions and restore your "hacks".
Roman
Thanks. There are problems associated with this: clicking the Insert Into Post button lands the blogger back in the Write Post page with the Publish and Save buttons enabled even though the post is already published. If at this point they attempt to navigate away from the page, they get a JS alert prompt saying they have unsaved content. Not good.
So instead I'm paring down the Write Post page using the Post Control plugin and a bit of hacking so that only the Publish button is displayed -- and also an explanatory message telling what to do next -- depending on whether they completed or aborted the Kaltura wizard.
Now I have to figure out how to redirect the Write Post page upon publishing, but that's strictly a WP issue.
Thanks also for the reminder to track hacks. I am marking each hack with a comment in the source code beginning with "HACK" so I can obtain a listing of my hacks at any time using a multiple file search utility such as Funduc's Search and Replace. Of course, I am using plugins rather than hacks where possible.
I've made changes such that a user can now publish a video post without landing in the Write Post form. What got it to work was a combination of Roman's suggestion to insert
Code: Select all
topWindow.jQuery("#publish").click();
in view_send_to_editor.php plus the following hack to the WordPress post-new.php script immediately below the line that reads
wp_enqueue_script('word-count');:
Code: Select all
// HACK Redirect to homepage upon publishing
if ( isset($_GET['posted']) && $_GET['posted'] ) {
$_GET['posted'] = (int) $_GET['posted'];
header("Location: ". get_option('siteurl'));
}
And to review, the addition to post-new.php given by Roman in his original reply that causes the contribution wizard to open automatically upon the loading of post-new.php:
Code: Select all
jQuery(function() {
jQuery("#media-buttons a:last").click();
});
To finish this initiative, I'd like to avoid a user returning to post-new.php when they click the Close button in the upper right corner of the contribution wizard. The browser shows the Close button is a link targeting post-new.php with a "#" appended. What does the "#" mean? Where can I change this link target to go to, say, the blog home page -- in view/view_contribution_wizard_admin.php, perhaps?
Nice to hear the you are moving forward with the hacks :)
About the last issue, it's not only when the close button is clicked, but the whole modal background area which will close the contribution wizard, right?
Lets start from the close button:
In view_contribution_wizard_admin.php look for the function onContributionWizardCloseTimeouted
You can replace this line: setTimeout("topWindow.tb_remove()", 0);
with something like topWindow.location.href = "the new url";
For the modal background area:
Open kaltura.js and look for modalBoxWp26IntervalFunction, this function is invoked every 100ms to check if the modal box is closed, you can add your code after Kaltura.restoreModalBoxWp26();
Thanks for trying to help me work through this, Roman.
Roman wrote:About the last issue, it's not only when the close button is clicked, but the whole modal background area which will close the contribution wizard, right?
Hmm, I thought the contribution wizard and the whole modal background area are one and the same. At any rate, yes I want them both to go away when the close button is clicked. But they already do that. :?
Roman wrote:Lets start from the close button:
In view_contribution_wizard_admin.php look for the function onContributionWizardCloseTimeouted
You can replace this line: setTimeout("topWindow.tb_remove()", 0);
with something like topWindow.location.href = "the new url";
OK. I thought doing this would change the link target that displays in the browser status bar when one hovers on the close button, but that is not the case.
Roman wrote:For the modal background area:
Open kaltura.js and look for modalBoxWp26IntervalFunction, this function is invoked every 100ms to check if the modal box is closed, you can add your code after Kaltura.restoreModalBoxWp26();
You really lose me here. :oops: What would be the purpose of the code you are saying to add? I refer you to the first sentence in my original post: "I'm not a programmer..." :) (especially not a JavaScript programmer).
About the modal background area, try clicking on it.... This will also close the contribution wizard.
So what I meant is that you have to deal with the (x) click and the click on the background (which are different).
The link target for the close button doesn't do anything, javascript does the work, thats why you will have to add something like this:
topWindow.location.href = "the new url"
Let me know if you managed to figure out the close button, then we'll go over to the background click.
Inserting this line of code ...
Code: Select all
topWindow.location.href = "<?php echo get_option('siteurl'); ?>";
had no apparent effect. I tried inserting the line three different ways: as a replacement for
Code: Select all
setTimeout("topWindow.tb_remove()", 0);
and immediately before and immediately after.
You're right, it doesn't work there... my mistake
But you can use the second solution for both issues
open kaltura.js
edit the function modalBoxWp26IntervalFunction
Code: Select all
modalBoxWp26IntervalFunction: function () {
// if thickbox was closed
if (jQuery("#TB_window").css("display") != "block")
{
Kaltura.restoreModalBoxWp26();
window.location.href = "/";
}
},
This will redirect the user to the homepage when the (x) is clicked and when clicked outside of the modal box
Thanks!
I think what I really want is
Code: Select all
window.location.href = history.back();
but it doesn't work.
If my goal of redirecting on close to the blog home page turns out to be unreachable, is there a way to get video_send_to_editor to insert the Kaltura shortcode if the editor is hidden? I ask because I've found a way to hide the editor (and all the rest of the Write Post form) using CSS. When the editor is hidden, I get the "failed trying to insert the shortcode" message. This happens regardless of whether I use the CSS "display: none" or "visibility: hidden". If the editor is displayed/visible, the shortcode gets inserted.
Did it redirect you to a "page not found"?
You should just write:
history.back();
without the window.location.href
What I really wanted is
Code: Select all
window.location.href = "../";
because I want to redirect to the blog home page rather than the site home page. (This is a WPMU site.)
And it works. Thanks, Roman!! :)
The only case so far I've found that it doesn't work is where the user doesn't have their partner ID yet. This is probably not a big issue because I'm designing the workflow so the user isn't shown a link to post-new.php until they already have their partner ID and they will only ever use post-new.php to post their first segment of video on a given blog (maximum one post per blog). Once they post the first segment they'll use the Upload and Remix buttons on the player.
By the way I believe I've successfully moved the Kaltura registration to the site's front-end -- need to do more testing of this.
Great!
Show us the result when it's finished...
Roman
To the well one more time ... :)
To refresh your memory, adding the window.location line as follows in kaltura.js will redirect a user to the specified href when they click (x) or outside the modal box.
Code: Select all
modalBoxWp26IntervalFunction: function () {
// if thickbox was closed
if (jQuery("#TB_window").css("display") != "block")
{
Kaltura.restoreModalBoxWp26();
window.location.href = "../";
}
},
This works for the wizard's Add tab but not for the Browse tab. Any ideas for a solution for the Browse tab?
You can add this code:
Code: Select all
var topWindow = Kaltura.getTopWindow();
topWindow.tb_positionKalturaBackup = topWindow.tb_position;
topWindow.Kaltura.modalBoxWp26Interval = topWindow.setInterval(topWindow.Kaltura.modalBoxWp26IntervalFunction, 100);
to view/view_browse.php
before function deleteKShow(kshowId)
Thanks again, Roman. This works but not for the scenario that prompted my question ... after Kaltura automatically switches the user from the Add tab to the Browse tab to have them select the player color, size, and permissions and optionally edit the title.
I'm not a programmer so I'm probably in over my head, but this is what I'd like to implement ...
I'd like the Kaltura contribution wizard overlay to automatically load when the WordPress Write Post page opens. In other words, when the Write Post page loads, I'd like to simulate the hitting of the link wp-site/wp-admin/media-upload.php?post_id=xx&tab=kaltura&TB_iframe=true&height=500&width=640.
I know this is a JavaScript thing but after digging through the WordPress core and Kaltura plug-in source code, I have little idea where to begin.
Any guidance would be appreciated.