Skip to content

Commit 1d9b90c

Browse files
committed
fix Url convert to relative url, Fixes #249
1 parent 14066ad commit 1d9b90c

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

field_types/multiline_field/multiline_field.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
jQuery.mf_bind('add',function(){
22
if('undefined' != typeof tinyMCEPreInit){
3+
4+
if ( typeof tinymce !== 'undefined' ) {
5+
for ( id in tinyMCEPreInit.mceInit ) {
6+
init = tinyMCEPreInit.mceInit[id];
7+
$wrap = tinymce.$( '#wp-' + id + '-wrap' );
8+
9+
if ( $wrap.hasClass( 'html-active' ) ){
10+
for ( id in tinyMCEPreInit.mceInit ) {
11+
init = tinyMCEPreInit.mceInit[id];
12+
tinymce.init( init );
13+
}
14+
15+
// yeah, I know, this is ugly but works :s
16+
setTimeout(function(){
17+
jQuery("button#content-html").click();
18+
}, 1500);
19+
}
20+
}
21+
}
22+
23+
324
jQuery(".multiline_custom_field .add_editor_mf").each( function(index,value){
425
var editor_text = jQuery(this).attr('id');
5-
tinyMCE.execCommand(mf_js.mf_mceAddString, true, editor_text);
26+
tinyMCE.execCommand(mf_js.mf_mceAddString, false, editor_text);
627
jQuery(this).removeClass('add_editor_mf');
728
});
829
}
930
});
31+
1032
jQuery.mf_bind('before_sort', function(){
1133
if('undefined' != typeof tinyMCEPreInit){
1234
jQuery("#"+sort_group_id+" .multiline_custom_field .pre_editor").each( function(){
@@ -18,6 +40,7 @@ jQuery.mf_bind('before_sort', function(){
1840
});
1941
}
2042
});
43+
2144
jQuery.mf_bind('after_sort', function(){
2245
if('undefined' != typeof tinyMCEPreInit){
2346
jQuery("#"+sort_group_id+" .multiline_custom_field .temp_remove_editor").each( function(){
@@ -32,7 +55,9 @@ jQuery.mf_bind('before_save',function(){
3255
if('undefined' != typeof tinyMCEPreInit){
3356
jQuery(".multiline_custom_field .pre_editor").each(function(){
3457
var editor_text = jQuery(this).attr('id');
35-
jQuery(jQuery('#'+editor_text)).attr('value', tinyMCE.get(editor_text).getContent());
58+
if(tinyMCE.get(editor_text)) {
59+
jQuery(jQuery('#'+editor_text)).attr('value', tinyMCE.get(editor_text).getContent());
60+
}
3661
});
3762
}
3863
});
@@ -46,6 +71,7 @@ function add_editor(id){
4671
tinyMCE.execCommand(mf_js.mf_mceAddString, false, id);
4772
}
4873
}
74+
4975
// Remove the editor (button)
5076
function del_editor(id){
5177
if('undefined' != typeof tinyMCEPreInit){
@@ -58,4 +84,4 @@ jQuery().ready(function($){
5884
$(this).closest(".tab_multi_mf").find(".edButtonHTML_mf").removeClass("current");
5985
$(this).addClass("current");
6086
});
61-
});
87+
});

field_types/multiline_field/multiline_field.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class multiline_field extends mf_custom_fields {
1212
function get_properties() {
1313
return array(
1414
'js' => TRUE,
15-
'js_dependencies' => array(),
15+
'js_dependencies' => array(),
1616
'css' => FALSE
1717
);
1818
}
@@ -21,10 +21,10 @@ public function _update_description(){
2121
global $mf_domain;
2222
$this->description = __("An additional visual editor",$mf_domain);
2323
}
24-
24+
2525
public function _options() {
2626
global $mf_domain;
27-
27+
2828
$data = array(
2929
'option' => array(
3030
'height' => array(
@@ -96,14 +96,14 @@ public function display_field( $field, $group_index = 1, $field_index = 1 ) {
9696
$output .= sprintf('<a onclick="add_editor(\'%s\');" class="edButtonHTML_mf current" >Visual</a>',$field['input_id']);
9797
$output .= sprintf('</div><br /><br />');
9898
$class = 'pre_editor add_editor_mf';
99-
99+
100100
if(mf_settings::get('dont_remove_tags') != '1'){
101101
$value = apply_filters('the_editor_content', $value);
102102
}
103103
}
104-
104+
105105
if($field['options']['hide_visual'] == 0 && user_can_richedit() ){
106-
printf('<div style="display: none1" id="wp-%s-media-buttons" class="wp-media-buttons mf_media_button_div" >',$field['input_id']);
106+
printf('<div id="wp-%s-media-buttons" class="wp-media-buttons mf_media_button_div" >',$field['input_id']);
107107
require_once( ABSPATH . 'wp-admin/includes/media.php' );
108108
media_buttons( $field['input_id'] );
109109
printf('</div>');
@@ -114,4 +114,4 @@ public function display_field( $field, $group_index = 1, $field_index = 1 ) {
114114

115115
return $output;
116116
}
117-
}
117+
}

0 commit comments

Comments
 (0)