2017-08-18 2 views
0

変更出力tamplateが必要です。 exempleについて:フック付きのfoogalleryで出力入力テンプレートを変更するには?

今、私は、このテンプレートを持っているが、データベース

<div id="foogallery-gallery-67" class="foogallery-container foogallery-default foogallery-link-image foogallery-lightbox-foobox-free spacing-width-10 hover-effect-zoom3 border-style-square-white alignment-center hover-caption-simple foogallery-default-loading"> 
    <a href="http://wordpress.local/wp-content/uploads/2017/08/222-1.jpg" data-caption-title="Title" data-caption-desc="description text" data-attachment-id="128" class=""> 
     <img src="http://wordpress.local/wp-content/uploads/cache/2017/08/222-1/705461751.jpg" width="150" height="150" /> 
    </a> 
</div> 

に店をWICH私は私が追加できることを知っている1つのデータ - を追加する必要があります*属性(データ・カスタム)

<div id="foogallery-gallery-67" class="foogallery-container foogallery-default foogallery-link-image foogallery-lightbox-foobox-free spacing-width-10 hover-effect-zoom3 border-style-square-white alignment-center hover-caption-simple foogallery-default-loading"> 
    <a href="http://wordpress.local/wp-content/uploads/2017/08/222-1.jpg" data-caption-title="Title" data-caption-desc="description text" data-attachment-id="128" data-custom="" class=""> 
     <img src="http://wordpress.local/wp-content/uploads/cache/2017/08/222-1/705461751.jpg" width="150" height="150" /> 
    </a> 
</div> 

直接データベースに、私はどのように出力と入力関数を再定義することができますので、将来問題がないことに興味があります。

class Plugin() 
{ 
    public function __construct() 
    { 

    } 
} 

$startPlugin = new Plugin(); 

そして、我々は、出力にFooGallaryテンプレートを変更する必要があります。

答えて

0

そして再び、私たちは、プラグインのような構造を持っている自分の質問例えば

にお答えします。 FooGallaryにはこのフィルタがあり、出力タンプをfoogallery_attachment_html_link_attributesに変更できます。今度はクラスを変更して、このフィルタを助けてください。

class Plugin() 
{ 
    public function __construct() 
    { 
     add_filter('foogallery_attachment_html_link_attributes', array($this, 'addFoogalleryCategory'), 10, 3); 
    } 

    public function addFoogalleryCategory($attr, $args, $attachment) 
    { 
     $attr['data-category'] = 'category'; 
     return $attr; 
    } 
} 

$startPlugin = new Plugin(); 

私はすぐに解決策を見つけることはできませんでした。たぶん私は誰かを助けた。

関連する問題