Skip to content

Commit

Permalink
fix Url convert to relative url, Fixes #249
Browse files Browse the repository at this point in the history
  • Loading branch information
hunk committed Sep 10, 2016
1 parent 14066ad commit 1d9b90c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
32 changes: 29 additions & 3 deletions field_types/multiline_field/multiline_field.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
jQuery.mf_bind('add',function(){
if('undefined' != typeof tinyMCEPreInit){

if ( typeof tinymce !== 'undefined' ) {
for ( id in tinyMCEPreInit.mceInit ) {
init = tinyMCEPreInit.mceInit[id];
$wrap = tinymce.$( '#wp-' + id + '-wrap' );

if ( $wrap.hasClass( 'html-active' ) ){
for ( id in tinyMCEPreInit.mceInit ) {
init = tinyMCEPreInit.mceInit[id];
tinymce.init( init );
}

// yeah, I know, this is ugly but works :s
setTimeout(function(){
jQuery("button#content-html").click();
}, 1500);
}
}
}


jQuery(".multiline_custom_field .add_editor_mf").each( function(index,value){
var editor_text = jQuery(this).attr('id');
tinyMCE.execCommand(mf_js.mf_mceAddString, true, editor_text);
tinyMCE.execCommand(mf_js.mf_mceAddString, false, editor_text);
jQuery(this).removeClass('add_editor_mf');
});
}
});

jQuery.mf_bind('before_sort', function(){
if('undefined' != typeof tinyMCEPreInit){
jQuery("#"+sort_group_id+" .multiline_custom_field .pre_editor").each( function(){
Expand All @@ -18,6 +40,7 @@ jQuery.mf_bind('before_sort', function(){
});
}
});

jQuery.mf_bind('after_sort', function(){
if('undefined' != typeof tinyMCEPreInit){
jQuery("#"+sort_group_id+" .multiline_custom_field .temp_remove_editor").each( function(){
Expand All @@ -32,7 +55,9 @@ jQuery.mf_bind('before_save',function(){
if('undefined' != typeof tinyMCEPreInit){
jQuery(".multiline_custom_field .pre_editor").each(function(){
var editor_text = jQuery(this).attr('id');
jQuery(jQuery('#'+editor_text)).attr('value', tinyMCE.get(editor_text).getContent());
if(tinyMCE.get(editor_text)) {
jQuery(jQuery('#'+editor_text)).attr('value', tinyMCE.get(editor_text).getContent());
}
});
}
});
Expand All @@ -46,6 +71,7 @@ function add_editor(id){
tinyMCE.execCommand(mf_js.mf_mceAddString, false, id);
}
}

// Remove the editor (button)
function del_editor(id){
if('undefined' != typeof tinyMCEPreInit){
Expand All @@ -58,4 +84,4 @@ jQuery().ready(function($){
$(this).closest(".tab_multi_mf").find(".edButtonHTML_mf").removeClass("current");
$(this).addClass("current");
});
});
});
14 changes: 7 additions & 7 deletions field_types/multiline_field/multiline_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class multiline_field extends mf_custom_fields {
function get_properties() {
return array(
'js' => TRUE,
'js_dependencies' => array(),
'js_dependencies' => array(),
'css' => FALSE
);
}
Expand All @@ -21,10 +21,10 @@ public function _update_description(){
global $mf_domain;
$this->description = __("An additional visual editor",$mf_domain);
}

public function _options() {
global $mf_domain;

$data = array(
'option' => array(
'height' => array(
Expand Down Expand Up @@ -96,14 +96,14 @@ public function display_field( $field, $group_index = 1, $field_index = 1 ) {
$output .= sprintf('<a onclick="add_editor(\'%s\');" class="edButtonHTML_mf current" >Visual</a>',$field['input_id']);
$output .= sprintf('</div><br /><br />');
$class = 'pre_editor add_editor_mf';

if(mf_settings::get('dont_remove_tags') != '1'){
$value = apply_filters('the_editor_content', $value);
}
}

if($field['options']['hide_visual'] == 0 && user_can_richedit() ){
printf('<div style="display: none1" id="wp-%s-media-buttons" class="wp-media-buttons mf_media_button_div" >',$field['input_id']);
printf('<div id="wp-%s-media-buttons" class="wp-media-buttons mf_media_button_div" >',$field['input_id']);
require_once( ABSPATH . 'wp-admin/includes/media.php' );
media_buttons( $field['input_id'] );
printf('</div>');
Expand All @@ -114,4 +114,4 @@ public function display_field( $field, $group_index = 1, $field_index = 1 ) {

return $output;
}
}
}

0 comments on commit 1d9b90c

Please sign in to comment.