Skip to content

Commit 1e2f381

Browse files
authored
Merge pull request #251 from magic-fields-team/fix-relative-url-multiline
fix Url convert to relative url, Fixes #249
2 parents 608b26a + 9357ddd commit 1e2f381

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

admin/mf_custom_fields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function fields_list() {
182182
<th scope="col" id="name" class="manage-column column-title" width="35%"><?php _e('Name',$mf_domain); ?> (<?php _e('order',$mf_domain); ?>)</th>
183183
<th scope="col" id="type" class="manage-column column-title" width="25%"><?php _e('Type',$mf_domain); ?></th>
184184
</tr>
185-
</tfood>
185+
</tfoot>
186186
<tbody rel="group-<?php print $group['id']; ?>" >
187187
<?php foreach($fields as $field): ?>
188188
<tr id="order_<?php echo $field['id']; ?>">

field_types/multiline_field/multiline_field.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
jQuery.mf_bind('add',function(){
22
if('undefined' != typeof tinyMCEPreInit){
3+
4+
if ( typeof tinymce !== 'undefined' ) {
5+
for ( id in tinyMCEPreInit.mceInit ) {
6+
if (tinyMCEPreInit.mceInit.hasOwnProperty(id)) {
7+
init = tinyMCEPreInit.mceInit[id];
8+
$wrap = tinymce.$( '#wp-' + id + '-wrap' );
9+
10+
if ( $wrap.hasClass( 'html-active' ) ){
11+
for ( id in tinyMCEPreInit.mceInit ) {
12+
if (tinyMCEPreInit.mceInit.hasOwnProperty(id)) {
13+
init = tinyMCEPreInit.mceInit[id];
14+
tinymce.init( init );
15+
}
16+
}
17+
18+
// yeah, I know, this is ugly but works :s
19+
setTimeout(function(){
20+
jQuery("button#content-html").click();
21+
}, 1500);
22+
23+
}
24+
}
25+
}
26+
}
27+
28+
329
jQuery(".multiline_custom_field .add_editor_mf").each( function(index,value){
430
var editor_text = jQuery(this).attr('id');
5-
tinyMCE.execCommand(mf_js.mf_mceAddString, true, editor_text);
31+
tinyMCE.execCommand(mf_js.mf_mceAddString, false, editor_text);
632
jQuery(this).removeClass('add_editor_mf');
733
});
834
}
935
});
36+
1037
jQuery.mf_bind('before_sort', function(){
1138
if('undefined' != typeof tinyMCEPreInit){
1239
jQuery("#"+sort_group_id+" .multiline_custom_field .pre_editor").each( function(){
@@ -18,6 +45,7 @@ jQuery.mf_bind('before_sort', function(){
1845
});
1946
}
2047
});
48+
2149
jQuery.mf_bind('after_sort', function(){
2250
if('undefined' != typeof tinyMCEPreInit){
2351
jQuery("#"+sort_group_id+" .multiline_custom_field .temp_remove_editor").each( function(){
@@ -32,7 +60,9 @@ jQuery.mf_bind('before_save',function(){
3260
if('undefined' != typeof tinyMCEPreInit){
3361
jQuery(".multiline_custom_field .pre_editor").each(function(){
3462
var editor_text = jQuery(this).attr('id');
35-
jQuery(jQuery('#'+editor_text)).attr('value', tinyMCE.get(editor_text).getContent());
63+
if(tinyMCE.get(editor_text)) {
64+
jQuery(jQuery('#'+editor_text)).attr('value', tinyMCE.get(editor_text).getContent());
65+
}
3666
});
3767
}
3868
});
@@ -46,6 +76,7 @@ function add_editor(id){
4676
tinyMCE.execCommand(mf_js.mf_mceAddString, false, id);
4777
}
4878
}
79+
4980
// Remove the editor (button)
5081
function del_editor(id){
5182
if('undefined' != typeof tinyMCEPreInit){
@@ -58,4 +89,4 @@ jQuery().ready(function($){
5889
$(this).closest(".tab_multi_mf").find(".edButtonHTML_mf").removeClass("current");
5990
$(this).addClass("current");
6091
});
61-
});
92+
});

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)