Genesis Framework

设置Genesis后台选项默认值

如果你需要:

  • 设置Genesis Framework后台选项的默认值,不比没做一个新站都重新设置一遍
  • 防止客户不小心修改了后台选项,导致已经设置好的网站出问题
  • 对客户隐藏后台功能

那么这里与你需要的东西。

隐藏后台选项

在子模板的functions.php中添加如下代码

remove_theme_support('genesis-admin-menu');

隐藏post和page编辑界面选择布局的功能

remove_theme_support('genesis-inpost-layouts');

为Theme Settings设置默认值

// Define Genesis Options
add_filter('genesis_options', 'define_genesis_setting_custom', 10, 2);

function define_genesis_setting_custom($options, $setting) {
    if ($setting == GENESIS_SETTINGS_FIELD) {
        $options['update'] = 1;
        $options['blog_title'] = 'text';
        $options['header_right'] = 0;
        $options['site_layout'] = 'content-sidebar';
        $options['nav'] = 1;
        $options['nav_superfish'] = 1;
        $options['nav_home'] = 1;
        $options['nav_type'] = 'pages';
        $options['nav_pages_sort'] = 'menu_order';
        $options['nav_categories_sort'] = 'name';
        $options['nav_depth'] = 0;
        $options['nav_extras_enable'] = 0;
        $options['nav_extras'] = 'date';
        $options['nav_extras_twitter_id'] = '';
        $options['nav_extras_twitter_text'] = 'Follow me on Twitter';
        $options['subnav'] = 0;
        $options['subnav_superfish'] = 1;
        $options['subnav_home'] = 0;
        $options['subnav_type'] = 'categories';
        $options['subnav_pages_sort'] = 'menu_order';
        $options['subnav_categories_sort'] = 'name';
        $options['subnav_depth'] = 0;
        $options['feed_uri'] = '';
        $options['comments_feed_uri'] = '';
        $options['redirect_feeds'] = 0;
        $options['comments_pages'] = 0;
        $options['comments_posts'] = 1;
        $options['trackbacks_pages'] = 0;
        $options['trackbacks_posts'] = 1;
        $options['author_box_single'] = 1;
        $options['breadcrumb_home'] = 1;
        $options['breadcrumb_single'] = 1;
        $options['breadcrumb_page'] = 1;
        $options['breadcrumb_archive'] = 1;
        $options['breadcrumb_404'] = 1;
        $options['content_archive'] = 'full';
        $options['content_archive_thumbnail'] = 0;
        $options['posts_nav'] = 'older-newer';
        $options['blog_cat'] = '';
        $options['blog_cat_exclude'] = '';
        $options['blog_cat_num'] = 10;
        $options['header_scripts'] = '';
        $options['footer_scripts'] = '';
        $options['theme_version'] = PARENT_THEME_VERSION;
    }
    return $options;
}

设置默认值后,即使不隐藏后台选项,用户也无法更改这些选项,请酌情使用。