最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Double Curly Brackets in Php

programmeradmin2浏览0评论

I have below code when developing theme to reach upper array keys and value. Use {{image-about}} to reach attachments array first key 'image-about' => ...

  add_theme_support( 'starter-content', [
        'widgets'                           => [
            // Place three core-defined widgets in the sidebar area
            'ju_sidebar'                    => [
                'text_business_info', 'search', 'text_about',
                ]
            ],

            // Create the custom image attachments used as post thumbnails for pages
            'attachments'                    => [
                'image-about'                => [
                    'post_title'             => __('About','udemy'),
                    'file'                   => 'assets/images/about/1.jpg',
                    ],
            ],
            'posts'                          => [
                'home'                       => [
                    'thumbnail'              => '{{image-about}}'
                    ], 
                'about'                      => [
                    'thumbnail'              => '{{image-about}}'
                    ], 
                'contact'                    => [
                    'thumbnail'              => '{{image-about}}'
                    ], 
                'blog'                       => [
                    'thumbnail'              => '{{image-about}}'
                    ], 
                'homepage-section'           => [
                    'thumbnail'              => '{{image-about}}'
                    ],
            ],
            'options'                        => [
                'show_on_front'              => 'page',
                'page_on_front'              => '{{home}}',
                'page_for_posts'             => '{{blog}}',
            ],
            'theme_mods'                     => [
                'ju_facebook_handle'         => 'udemy',
                'ju_twitter_handle'          => 'udemy',
                'ju_instagram_handle'        => 'udemy',
                'ju_email'                   => 'udemy',
                'ju_phone_number'            => 'udemy',
                'ju_header_show_search'      => 'yes',
                'ju_header_show_cart'        => 'yes',
            ],
            'nav_menus'                      => [
                'primary'                    => array(
                    'name'                   => __('Primary Menu','udemy'),
                    'items'                  => array(
                        'link_home',
                        'page_about',
                        'page_block',
                        'page_contact',
                    ),
                ),
                'secondary'                    => array(
                    'name'                   => __('Secondary Menu','udemy'),
                    'items'                  => array(
                        'link_home',
                        'page_about',
                        'page_block',
                        'page_contact',
                    ),
                ),
            ]
    ]);

I couldn't find any response related to those double curly braces. Only find for wp.customize javascript notation or angular.js but none of them explains this situation.

Any information about that would be very helpful

I have below code when developing theme to reach upper array keys and value. Use {{image-about}} to reach attachments array first key 'image-about' => ...

  add_theme_support( 'starter-content', [
        'widgets'                           => [
            // Place three core-defined widgets in the sidebar area
            'ju_sidebar'                    => [
                'text_business_info', 'search', 'text_about',
                ]
            ],

            // Create the custom image attachments used as post thumbnails for pages
            'attachments'                    => [
                'image-about'                => [
                    'post_title'             => __('About','udemy'),
                    'file'                   => 'assets/images/about/1.jpg',
                    ],
            ],
            'posts'                          => [
                'home'                       => [
                    'thumbnail'              => '{{image-about}}'
                    ], 
                'about'                      => [
                    'thumbnail'              => '{{image-about}}'
                    ], 
                'contact'                    => [
                    'thumbnail'              => '{{image-about}}'
                    ], 
                'blog'                       => [
                    'thumbnail'              => '{{image-about}}'
                    ], 
                'homepage-section'           => [
                    'thumbnail'              => '{{image-about}}'
                    ],
            ],
            'options'                        => [
                'show_on_front'              => 'page',
                'page_on_front'              => '{{home}}',
                'page_for_posts'             => '{{blog}}',
            ],
            'theme_mods'                     => [
                'ju_facebook_handle'         => 'udemy',
                'ju_twitter_handle'          => 'udemy',
                'ju_instagram_handle'        => 'udemy',
                'ju_email'                   => 'udemy',
                'ju_phone_number'            => 'udemy',
                'ju_header_show_search'      => 'yes',
                'ju_header_show_cart'        => 'yes',
            ],
            'nav_menus'                      => [
                'primary'                    => array(
                    'name'                   => __('Primary Menu','udemy'),
                    'items'                  => array(
                        'link_home',
                        'page_about',
                        'page_block',
                        'page_contact',
                    ),
                ),
                'secondary'                    => array(
                    'name'                   => __('Secondary Menu','udemy'),
                    'items'                  => array(
                        'link_home',
                        'page_about',
                        'page_block',
                        'page_contact',
                    ),
                ),
            ]
    ]);

I couldn't find any response related to those double curly braces. Only find for wp.customize javascript notation or angular.js but none of them explains this situation.

Any information about that would be very helpful

Share Improve this question asked Apr 30, 2020 at 11:33 O.kO.k 34 bronze badges 2
  • This appears to be code from a theme or plugin purchased from Udemy? My guess is that the content in {{...}} is placeholder text, meant to be replaced by some function or other, but your best bet is to check with Udemy's help streams. – Pat J Commented Apr 30, 2020 at 13:58
  • Yes, this is sample theme from udemy. But those theme support starter is pre-built wordpress functionality which leads to display default content on customization panel opened. So, actually those double curly braces pointed out the upper array's key and value to be replaced. – O.k Commented Apr 30, 2020 at 14:15
Add a comment  | 

1 Answer 1

Reset to default 1

In your example {{image-about}} tells WordPress to use the image defined in ['attachments']['image-about'] as the thumbnail for those posts in the 'starter content'. This functionality is specific to the "Starter Content" feature added in WordPress 4.7, which is described here, and not a PHP language feature.

发布评论

评论列表(0)

  1. 暂无评论