2014-06-06 62 views
5

Wordpress 3.9.1 kullanıyorum ve çalışmakta olan özel bir kod yazdım ama biraz özel yapmak istiyorum Kısa kodumu kullandığımda, bu benim admin sayfasında göster: [toggles title = "zaez"] aezaezae [/ toggles]WordPress özel kısa kod düzenleyici [BackboneJS & TinyMCE]

"aezaezae" metnine yazı ekleyebilir veya metin ekleyebilirim. Ve bu davranışı devam ettirmek ama bakmak daha iyi yapmak istiyorum.

yüzden wordpress (galerinin kodu) ait bazı kodları kullanılır ve yaptığını:

(function($){ 

var views = {}, 
    instances = {}, 
    media = wp.media, 
    viewOptions = ['encodedText']; 

// Create the `wp.mce` object if necessary. 
wp.mce = wp.mce || {}; 

wp.mce.toggles = { 
    shortcode: 'toggles', 
    toView: function(content) { 
     var match = wp.shortcode.next(this.shortcode, content); 

     if (! match) { 
      return; 
     } 

     return { 
      index: match.index, 
      content: match.content, 
      options: { 
       shortcode: match.shortcode 
      } 
     }; 
    }, 
    View: wp.mce.View.extend({ 
     className: 'editor-toggles', 
     template: media.template('editor-toggles'), 

     // The fallback post ID to use as a parent for galleries that don't 
     // specify the `ids` or `include` parameters. 
     // 
     // Uses the hidden input on the edit posts page by default. 
     postID: $('#post_ID').val(), 

     initialize: function(options) { 
      this.shortcode = options.shortcode; 
     }, 

     getHtml: function() { 
      var attrs = this.shortcode.attrs.named, 
       content = this.shortcode.content, 
       options; 

      options = { 
       content: content, 
       title: attrs.title 
      }; 

      return this.template(options); 

     } 
    }) 

}; 
wp.mce.views.register('toggles', wp.mce.toggles); 

} (jQuery));

Ve bu Çok çalışıyor

<script type="text/html" id="tmpl-editor-toggles"> 
    <div class="toolbar"> 
     <div class="dashicons dashicons-edit edit"></div><div class="dashicons dashicons-no-alt remove"></div> 
    </div> 
    <# if (data.title) { #> 

      <h2>{{ data.title }}</h2> 
      <hr> 
      <p data-wpview-pad="1">{{ data.content }}</p> 
      <hr> 

    <# } #> 
</script> 

denir şablon, ancak şu anda artık benim içeriği düzenleyemezsiniz. Galerinin fonksiyonuna baktım, ama başka bir pencere (wp.media.gallery) aradı ve bu varsayılan editörde düzenleme yapabilmeyi isterdim ...

Birisi bana mümkün olup olmadığını söyleyebilir mi? bana bir ipucu ver ? bunu buldum ama dediğim gibi o benim shortcode düzenlemek için yeni bir pencere çağırmak bıraktıysanız Ben yaparım ama gerçekten bilmiyorum Custom wp.media with arguments support

medya (resim ... videolar) için var ..

Teşekkürler! Saygılarımızla Thomas

+0

nasıl nihayet bu yönetilen vermedi shortcode parametre türüne bize ister görünür? Burada, düzenlenebilir olmayan bir Mce Görünümü oluşturuyorsunuz (bu amaçlanan davranış). Görünüm içinde düzenleme araçları sağlamanız gerekir (metnin bir "" elemanıyla değiştirilmesi ve düzenlemelerin JavaScript ile kontrol edilmesi gibi). [Contenteditable tek satırlı giriş] –

+0

olası kopyası (http://stackoverflow.com/questions/6831482/contenteditable-single-line-input) –

cevap

İlgili konular