Plugin Directory

Changeset 906980


Ignore:
Timestamp:
05/02/2014 04:57:38 PM (12 years ago)
Author:
hunk
Message:

update for wp 3.9

Location:
magic-fields-2/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • magic-fields-2/trunk/admin/mf_post.php

    r761841 r906980  
    395395    wp_enqueue_script( 'mf_sortable_groups', MF_BASENAME.'js/mf_sortable_groups.js', array( 'jquery-ui-sortable' ) );
    396396
     397    $mceAddString = "mceAddControl";
     398    $mceRemoveString = "mceRemoveControl";
     399    if(is_wp39()){
     400      $mceAddString = "mceAddEditor";
     401      $mceRemoveString = "mceRemoveEditor";
     402    }
     403
    397404    //global mf js
    398405    $js_vars = array(
     
    400407      'mf_player_url' => MF_BASENAME . 'js/singlemp3player.swf',
    401408      'mf_validation_error_msg' => __('Sorry, some required fields are missing. Please provide values for any highlighted fields and try again.',$mf_domain),
    402       'mf_image_media_set' => __('Insert into field',$mf_domain)
     409      'mf_image_media_set' => __('Insert into field',$mf_domain),
     410      'mf_mceAddString' => $mceAddString,
     411      'mf_mceRemoveString' => $mceRemoveString
    403412    );
    404413    wp_localize_script( 'mf_field_base', 'mf_js', $js_vars );   
     
    421430    /* only add of editor support no exits for the post type*/
    422431    if( (in_array('multiline',$fields) || in_array('image_media',$fields) )  && !post_type_supports($post_type,'editor' ) ){
    423       add_thickbox();
     432      /*add_thickbox();
    424433      wp_enqueue_script('media-upload');
    425434      wp_enqueue_script('editor'); // load admin/mf_editor.js (switchEditor)
    426435      mf_autoload('mf_tiny_mce'); // load admin/mf_tiny_mce.php (tinyMCE)
    427436      add_action( 'admin_print_footer_scripts', 'mf_tiny_mce', 25 ); // embed tinyMCE
    428       add_action( 'admin_print_footer_scripts', array($this, 'media_buttons_add_mf'), 51 );
     437      add_action( 'admin_print_footer_scripts', array($this, 'media_buttons_add_mf'), 51 );*/
    429438    }
    430439
     
    478487    }
    479488  }
    480  
     489
     490  public function check_exist_visual_editor(){
     491
     492    if( !empty( $_GET['post']) && is_numeric( $_GET['post'] ) ) {//when the post already exists
     493      $post_type = get_post_type($_GET['post']);   
     494    }else{ //Creating a new post
     495      $post_type = (!empty($_GET['post_type'])) ? $_GET['post_type'] : 'post';
     496    }
     497
     498    $fields = $this->get_unique_custom_fields_by_post_type($post_type);
     499
     500    /* add tiny_mce script */
     501    /* only add of editor support no exits for the post type*/
     502    if( (in_array('multiline',$fields) || in_array('image_media',$fields) )  && !post_type_supports($post_type,'editor' ) ){
     503      echo "<div style='display:none'>";
     504      echo wp_editor('','you_know_nothing');
     505      echo "</div>";
     506    }
     507
     508   
     509   
     510  }
    481511  public function media_buttons_add_mf(){
    482512   
  • magic-fields-2/trunk/css/mf_field_base.css

    r640332 r906980  
    172172.multiline_custom_field iframe{ Background: white !important; }
    173173textarea.mf_editor { width: 99%; padding: 8px;}
    174 .mf-field-ui .tab_multi_mf { float: left;}
     174.mf-field-ui .tab_multi_mf { float: right;}
    175175.mf-field-ui .tab_multi_mf a {
    176176  float: right;
  • magic-fields-2/trunk/field_types/multiline_field/multiline_field.js

    r454843 r906980  
    33    jQuery(".multiline_custom_field .add_editor_mf").each( function(index,value){
    44      var editor_text = jQuery(this).attr('id');
    5       tinyMCE.execCommand('mceAddControl', true, editor_text);
     5      tinyMCE.execCommand(mf_js.mf_mceAddString, true, editor_text);
    66      jQuery(this).removeClass('add_editor_mf');
    77    });
     
    1313      var editor_text = jQuery(this).attr('id');
    1414      if(tinyMCE.get(editor_text)){
    15         tinyMCE.execCommand('mceRemoveControl', false, editor_text);
     15        tinyMCE.execCommand(mf_js.mf_mceRemoveString, false, editor_text);
    1616        jQuery('#'+editor_text).addClass('temp_remove_editor');
    1717      }
     
    2323    jQuery("#"+sort_group_id+" .multiline_custom_field .temp_remove_editor").each( function(){
    2424      var editor_text = jQuery(this).attr('id');
    25       tinyMCE.execCommand('mceAddControl', false, editor_text);
     25      tinyMCE.execCommand(mf_js.mf_mceAddString, false, editor_text);
    2626      jQuery('#'+editor_text).removeClass('temp_remove_editor');
    2727    });
     
    4444    new_valor = switchEditors.wpautop(new_valor);
    4545    jQuery('#'+id).val(new_valor);
    46     tinyMCE.execCommand('mceAddControl', false, id);
     46    tinyMCE.execCommand(mf_js.mf_mceAddString, false, id);
    4747  }
    4848}
     
    5050function del_editor(id){
    5151  if('undefined' != typeof tinyMCEPreInit){
    52     tinyMCE.execCommand('mceRemoveControl', false, id);
     52    tinyMCE.execCommand(mf_js.mf_mceRemoveString, false, id);
    5353  }
    5454}
  • magic-fields-2/trunk/field_types/multiline_field/multiline_field.php

    r498300 r906980  
    9595      $output .= sprintf('<a onclick="del_editor(\'%s\');" class="edButtonHTML_mf">HTML</a>',$field['input_id']);
    9696      $output .= sprintf('<a onclick="add_editor(\'%s\');" class="edButtonHTML_mf current" >Visual</a>',$field['input_id']);
    97       $output .= sprintf('</div>');
     97      $output .= sprintf('</div><br /><br />');
    9898      $class = 'pre_editor add_editor_mf';
    9999     
     
    102102      }
    103103    }
    104         printf('<div style="display: none" id="wp-%s-media-buttons">',$field['input_id']);
    105         require_once( ABSPATH . 'wp-admin/includes/media.php' );
    106         media_buttons( $field['input_id'] );
    107         printf('</div>');
     104   
     105    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']);
     107          require_once( ABSPATH . 'wp-admin/includes/media.php' );
     108          media_buttons( $field['input_id'] );
     109          printf('</div>');
     110    }
    108111
    109112    $output .= sprintf('<textarea %s class="mf_editor %s" id="%s" name="%s" rows="%s" cols="%s" %s >%s</textarea>',$field['input_validate'],$class,$field['input_id'],$field['input_name'],$field['options']['height'],$field['options']['width'],$max,$value);
  • magic-fields-2/trunk/js/mf_admin.js

    r761841 r906980  
    244244   
    245245  $(document).on('click',".mce_add_image , .mce_add_video , .mce_add_audio , .mce_add_media",function(){
     246    console.log('qwerty');
     247
     248
    246249    window.mf_field_id = '';
    247     var a = this;
     250     var a = this;
     251
     252 
    248253    // When a mce button is clicked, we have to hotswap the activeEditor instance, else the image will be inserted into the wrong tinyMCE box (current editor)
    249254    setTimeout( function() {
     
    252257        }, 500 );
    253258       
     259  });
     260
     261  //focus for visual editor wp 3.8
     262  $(document).on('click',".mf_media_button_div > .add_media",function(){
     263    var idElem = $(this).parent('div.mf_media_button_div').attr('id');
     264    idElem = idElem.replace(/wp-/, "");
     265    idElem = idElem.replace(/-media-buttons/, "");
     266    tinyMCE.get(idElem).focus();
    254267  });
    255268});
  • magic-fields-2/trunk/main.php

    r864350 r906980  
    44Plugin URI: http://magicfields.org
    55Description: Create custom fields for your post types
    6 Version: 2.2.1
     6Version: 2.2.2
    77Author:  Hunk and Gnuget
    88Author URI: http://magicfields.org
     
    238238        /* Load JS and CSS for post page */
    239239        $css_js = new mf_post();
     240        $css_js->check_exist_visual_editor();
    240241        $css_js->load_js_css_base();
    241242        $css_js->load_js_css_fields();
  • magic-fields-2/trunk/mf_extra.php

    r761841 r906980  
    6767
    6868}
     69
     70if( !function_exists('is_wp39') ){
     71
     72  function is_wp39(){
     73    $wp_version = floatval(get_bloginfo('version'));
     74
     75    if( $wp_version >= 3.9 ) return TRUE;
     76
     77    return FALSE;
     78  }
     79
     80}
  • magic-fields-2/trunk/readme.txt

    r864350 r906980  
    22Contributors: hunk, Gnuget
    33Tags: cms, post types, fields, taxonomies
    4 Tested up to: Wordpress 3.8.1
     4Tested up to: Wordpress 3.9
    55Requires at least: 3.1
    66Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=edgar%40programador%2ecom&lc=GB&item_name=Donation%20Magic%20Fields&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
    7 Stable tag: 2.2.1
     7Stable tag: 2.2.2
    88Description:  Magic Fields 2 is a feature rich Wordpress CMS plugin
    99
     
    2626
    2727== Changelog ==
     28
     29= 2.2.2 =
     30* fix for visual editor in WP 3.9
    2831
    2932= 2.2.1 =
Note: See TracChangeset for help on using the changeset viewer.