[wordpress插件] Blade刀

wordpress 插件 文章 2020-03-06 03:50 514 0 全屏看文

AI助手支持GPT4.0

评分
80
描述

Blade is the template engine for Laravel, a very popular php framework, developed by Taylor Otwell.

Blade是Laravel的模板引擎,Laravel是由Taylor Otwell开发的非常流行的php框架。

This plugin brings the same template engine to wordpress.

此插件为Wordpress带来了相同的模板引擎。

Using a template engine will result in much cleaner template files and quicker development.

使用模板引擎将使模板文件更整洁并加快开发速度。

Normal php can still be used in the template files.

普通的php仍然可以在模板文件中使用。

The plugin also adds a wordpress specific snippet to blade.

该插件还向刀片添加了wordpress特定的代码段。

Check out the examples for more info.

查看示例以获取更多信息。

echo/print

回显/打印

{{$foo}}

  {{$$ foo}}

Turns into…    

变成...    

if()

if()

@if(has_post_thumbnail())    

  @if(has_post_thumbnail())    

{{the_post_thumbnail() }}

{{the_post_thumbnail()}}

@else    

@其他    

@endif

@万一

Turns into…

变成...

{{the_title()}}

{{the_title()}}

@wpempty    

@wpempty    

404

404

@wpend

@wpend

Turns into…

变成...

404

404

wordpress query

wordpress查询

      

      @wpquery(array('post_type' => 'post'))    

      @wpquery(array('post_type'=>'post'))    

    • {{the_title()}}
    • {{the_title()}}

      @wpempty    

      @wpempty    

    • {{ __('Sorry, no posts matched your criteria.') }}
    • {{__('对不起,没有符合您条件的帖子。')}}

      @wpend

      @wpend

    Turns into….

    变成...。

           

             

        ‘post’) );

        “帖子”));

        ?>
            

        ?>
            

        have_posts() ) : ?>
                

        have_posts()):?>
                

        have_posts() ) : $query->the_post();

        have_posts()):$ query-> the_post();

        ?>

        ?>

      Advanced Custom Fields

      高级自定义字段

            

          
              

          @acfrepeater('images')        

          @acfrepeater('图像')        

        • {{ get_sub_field( 'image' ) }}
        •     

        • {{get_sub_field('image')}}     

          @acfend

          @acfend

        Turns into…

        变成...

安装步骤

    1. Upload folder blade to the /wp-content/plugins/ directory
    2. 将文件夹 blade 上载到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

    5. Make sure that /wp-content/plugins/blade/storage/views/ is writable by php
    6. 确保 / wp-content / plugins / blade / storage / views / 可被php写入

    7. Done!

    8. 完成!

      You can now use Blade in your theme

    9. 您现在可以在主题中使用Blade

    More options

    更多选项

    It is recommended thay you change the path to the location where the compiled views are stored to within your theme.

    建议您将路径更改为主题中已编译视图存储的位置。

    This will fix problems with wpml.

    这将解决wpml的问题。

    To do so, put the following code in your theme folder and create the folder/directory “bladecache” in your theme folder.
        

    为此,请将以下代码放在主题文件夹中,然后在主题文件夹中创建文件夹/目录“ bladecache”。
        

    if(function_exists(‘blade_set_storage_path’)){
            

    if(function_exists('blade_set_storage_path')){
            

    blade_set_storage_path(get_template_directory().’/bladecache’);
        

    blade_set_storage_path(get_template_directory()。’/ bladecache’);
        

    }

    }

下载地址
https://downloads.wordpress.org/plugin/blade.0.3.7.zip
-EOF-

AI助手支持GPT4.0