@@ -1,94 +1,329 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// http://foolswisdom.com/wp-activate-theme-actio/
|
if (is_admin() && isset($_GET['activated']) && 'themes.php' == $GLOBALS['pagenow']) {
|
||||||
|
wp_redirect(admin_url('themes.php?page=theme_activation_options'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
global $pagenow;
|
function roots_theme_activation_options_init() {
|
||||||
if (is_admin() && $pagenow === 'themes.php' && isset( $_GET['activated'])) {
|
if (roots_get_theme_activation_options() === false) {
|
||||||
|
add_option('roots_theme_activation_options', roots_get_default_theme_activation_options());
|
||||||
// on theme activation make sure there's a Home page
|
|
||||||
// create it if there isn't and set the Home page menu order to -1
|
|
||||||
// set WordPress to have the front page display the Home page as a static page
|
|
||||||
$default_pages = array('Home');
|
|
||||||
$existing_pages = get_pages();
|
|
||||||
$temp = array();
|
|
||||||
|
|
||||||
foreach ($existing_pages as $page) {
|
|
||||||
$temp[] = $page->post_title;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$pages_to_create = array_diff($default_pages, $temp);
|
register_setting(
|
||||||
|
'roots_activation_options',
|
||||||
foreach ($pages_to_create as $new_page_title) {
|
'roots_theme_activation_options',
|
||||||
|
'roots_theme_activation_options_validate'
|
||||||
// create post object
|
|
||||||
$add_default_pages = array(
|
|
||||||
'post_title' => $new_page_title,
|
|
||||||
'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat, orci ac laoreet cursus, dolor sem luctus lorem, eget consequat magna felis a magna. Aliquam scelerisque condimentum ante, eget facilisis tortor lobortis in. In interdum venenatis justo eget consequat. Morbi commodo rhoncus mi nec pharetra. Aliquam erat volutpat. Mauris non lorem eu dolor hendrerit dapibus. Mauris mollis nisl quis sapien posuere consectetur. Nullam in sapien at nisi ornare bibendum at ut lectus. Pellentesque ut magna mauris. Nam viverra suscipit ligula, sed accumsan enim placerat nec. Cras vitae metus vel dolor ultrices sagittis. Duis venenatis augue sed risus laoreet congue ac ac leo. Donec fermentum accumsan libero sit amet iaculis. Duis tristique dictum enim, ac fringilla risus bibendum in. Nunc ornare, quam sit amet ultricies gravida, tortor mi malesuada urna, quis commodo dui nibh in lacus. Nunc vel tortor mi. Pellentesque vel urna a arcu adipiscing imperdiet vitae sit amet neque. Integer eu lectus et nunc dictum sagittis. Curabitur commodo vulputate fringilla. Sed eleifend, arcu convallis adipiscing congue, dui turpis commodo magna, et vehicula sapien turpis sit amet nisi.',
|
|
||||||
'post_status' => 'publish',
|
|
||||||
'post_type' => 'page'
|
|
||||||
);
|
|
||||||
|
|
||||||
// insert the post into the database
|
|
||||||
$result = wp_insert_post($add_default_pages);
|
|
||||||
}
|
|
||||||
|
|
||||||
$home = get_page_by_title('Home');
|
|
||||||
update_option('show_on_front', 'page');
|
|
||||||
update_option('page_on_front', $home->ID);
|
|
||||||
|
|
||||||
$home_menu_order = array(
|
|
||||||
'ID' => $home->ID,
|
|
||||||
'menu_order' => -1
|
|
||||||
);
|
);
|
||||||
wp_update_post($home_menu_order);
|
}
|
||||||
|
|
||||||
// set the permalink structure
|
add_action('admin_init', 'roots_theme_activation_options_init');
|
||||||
if (get_option('permalink_structure') !== '/%year%/%postname%/') {
|
|
||||||
update_option('permalink_structure', '/%year%/%postname%/');
|
|
||||||
}
|
|
||||||
|
|
||||||
$wp_rewrite->init();
|
function roots_activation_options_page_capability($capability) {
|
||||||
$wp_rewrite->flush_rules();
|
return 'edit_theme_options';
|
||||||
|
}
|
||||||
|
|
||||||
// don't organize uploads by year and month
|
add_filter('option_page_capability_roots_activation_options', 'roots_activation_options_page_capability');
|
||||||
update_option('uploads_use_yearmonth_folders', 0);
|
|
||||||
update_option('upload_path', 'assets');
|
|
||||||
|
|
||||||
// automatically create menus and set their locations
|
function roots_theme_activation_options_add_page() {
|
||||||
// add all pages to the Primary Navigation
|
$roots_activation_options = roots_get_theme_activation_options();
|
||||||
$roots_nav_theme_mod = false;
|
if (!$roots_activation_options['first_run']) {
|
||||||
|
$theme_page = add_theme_page(
|
||||||
if (!has_nav_menu('primary_navigation')) {
|
__('Theme Activation', 'roots'),
|
||||||
$primary_nav_id = wp_create_nav_menu('Primary Navigation', array('slug' => 'primary_navigation'));
|
__('Theme Activation', 'roots'),
|
||||||
$roots_nav_theme_mod['primary_navigation'] = $primary_nav_id;
|
'edit_theme_options',
|
||||||
}
|
'theme_activation_options',
|
||||||
|
'roots_theme_activation_options_render_page'
|
||||||
if (!has_nav_menu('utility_navigation')) {
|
);
|
||||||
$utility_nav_id = wp_create_nav_menu('Utility Navigation', array('slug' => 'utility_navigation'));
|
} else {
|
||||||
$roots_nav_theme_mod['utility_navigation'] = $utility_nav_id;
|
if (is_admin() && isset($_GET['page']) && $_GET['page'] === 'theme_activation_options') {
|
||||||
}
|
wp_redirect(admin_url('themes.php?page=theme_options'));
|
||||||
|
exit;
|
||||||
if ($roots_nav_theme_mod) {
|
}
|
||||||
set_theme_mod('nav_menu_locations', $roots_nav_theme_mod);
|
|
||||||
}
|
|
||||||
|
|
||||||
$primary_nav = wp_get_nav_menu_object('Primary Navigation');
|
|
||||||
|
|
||||||
$primary_nav_term_id = (int) $primary_nav->term_id;
|
|
||||||
$menu_items= wp_get_nav_menu_items($primary_nav_term_id);
|
|
||||||
if (!$menu_items || empty($menu_items)) {
|
|
||||||
$pages = get_pages();
|
|
||||||
foreach($pages as $page) {
|
|
||||||
$item = array(
|
|
||||||
'menu-item-object-id' => $page->ID,
|
|
||||||
'menu-item-object' => 'page',
|
|
||||||
'menu-item-type' => 'post_type',
|
|
||||||
'menu-item-status' => 'publish'
|
|
||||||
);
|
|
||||||
wp_update_nav_menu_item($primary_nav_term_id, 0, $item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
add_action('admin_menu', 'roots_theme_activation_options_add_page', 50);
|
||||||
|
|
||||||
|
function roots_get_default_theme_activation_options() {
|
||||||
|
$default_theme_activation_options = array(
|
||||||
|
'first_run' => false,
|
||||||
|
'create_front_page' => false,
|
||||||
|
'change_permalink_structure' => false,
|
||||||
|
'change_uploads_folder' => false,
|
||||||
|
'create_navigation_menus' => false,
|
||||||
|
'add_pages_to_primary_navigation' => false,
|
||||||
|
);
|
||||||
|
|
||||||
|
return apply_filters('roots_default_theme_activation_options', $default_theme_activation_options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function roots_get_theme_activation_options() {
|
||||||
|
return get_option('roots_theme_activation_options', roots_get_default_theme_activation_options());
|
||||||
|
}
|
||||||
|
|
||||||
|
function roots_theme_activation_options_render_page() { ?>
|
||||||
|
|
||||||
|
<div class="wrap">
|
||||||
|
<?php screen_icon(); ?>
|
||||||
|
<h2><?php printf(__('%s Theme Activation', 'roots'), get_current_theme()); ?></h2>
|
||||||
|
<?php settings_errors(); ?>
|
||||||
|
|
||||||
|
<form method="post" action="options.php">
|
||||||
|
|
||||||
|
<?php
|
||||||
|
settings_fields('roots_activation_options');
|
||||||
|
$roots_activation_options = roots_get_theme_activation_options();
|
||||||
|
$roots_default_activation_options = roots_get_default_theme_activation_options();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<input type="hidden" value="1" name="roots_theme_activation_options[first_run]" />
|
||||||
|
|
||||||
|
<table class="form-table">
|
||||||
|
|
||||||
|
<tr valign="top"><th scope="row"><?php _e('Create static front page?', 'roots'); ?></th>
|
||||||
|
<td>
|
||||||
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Create static front page?', 'roots'); ?></span></legend>
|
||||||
|
<select name="roots_theme_activation_options[create_front_page]" id="create_front_page">
|
||||||
|
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
|
||||||
|
<option value="no"><?php echo _e('No', 'roots'); ?></option>
|
||||||
|
</select>
|
||||||
|
<br />
|
||||||
|
<small class="description"><?php printf(__('Create a page called Home and set it to be the static front page', 'roots')); ?></small>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top"><th scope="row"><?php _e('Change permalink structure?', 'roots'); ?></th>
|
||||||
|
<td>
|
||||||
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Update permalink structure?', 'roots'); ?></span></legend>
|
||||||
|
<select name="roots_theme_activation_options[change_permalink_structure]" id="change_permalink_structure">
|
||||||
|
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
|
||||||
|
<option value="no"><?php echo _e('No', 'roots'); ?></option>
|
||||||
|
</select>
|
||||||
|
<br />
|
||||||
|
<small class="description"><?php printf(__('Change permalink structure to /%postname%/', 'roots')); ?></small>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top"><th scope="row"><?php _e('Change uploads folder?', 'roots'); ?></th>
|
||||||
|
<td>
|
||||||
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Update uploads folder?', 'roots'); ?></span></legend>
|
||||||
|
<select name="roots_theme_activation_options[change_uploads_folder]" id="change_uploads_folder">
|
||||||
|
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
|
||||||
|
<option value="no"><?php echo _e('No', 'roots'); ?></option>
|
||||||
|
</select>
|
||||||
|
<br />
|
||||||
|
<small class="description"><?php printf(__('Change uploads folder to /assets/ instead of /wp-content/uploads/', 'roots')); ?></small>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top"><th scope="row"><?php _e('Create navigation menus?', 'roots'); ?></th>
|
||||||
|
<td>
|
||||||
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Create navigation menus?', 'roots'); ?></span></legend>
|
||||||
|
<select name="roots_theme_activation_options[create_navigation_menus]" id="create_navigation_menus">
|
||||||
|
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
|
||||||
|
<option value="no"><?php echo _e('No', 'roots'); ?></option>
|
||||||
|
</select>
|
||||||
|
<br />
|
||||||
|
<small class="description"><?php printf(__('Create the Primary and Utility Navigation menus and set their locations', 'roots')); ?></small>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top"><th scope="row"><?php _e('Add pages to menu?', 'roots'); ?></th>
|
||||||
|
<td>
|
||||||
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Add pages to menu?', 'roots'); ?></span></legend>
|
||||||
|
<select name="roots_theme_activation_options[add_pages_to_primary_navigation]" id="add_pages_to_primary_navigation">
|
||||||
|
<option selected="selected" value="yes"><?php echo _e('Yes', 'roots'); ?></option>
|
||||||
|
<option value="no"><?php echo _e('No', 'roots'); ?></option>
|
||||||
|
</select>
|
||||||
|
<br />
|
||||||
|
<small class="description"><?php printf(__('Add all current published pages to the Primary Navigation', 'roots')); ?></small>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php submit_button(); ?>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php }
|
||||||
|
|
||||||
|
function roots_theme_activation_options_validate($input) {
|
||||||
|
$output = $defaults = roots_get_default_theme_activation_options();
|
||||||
|
|
||||||
|
if (isset($input['first_run'])) {
|
||||||
|
if ($input['first_run'] === '1') {
|
||||||
|
$input['first_run'] = true;
|
||||||
|
}
|
||||||
|
$output['first_run'] = $input['first_run'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($input['create_front_page'])) {
|
||||||
|
if ($input['create_front_page'] === 'yes') {
|
||||||
|
$input['create_front_page'] = true;
|
||||||
|
}
|
||||||
|
if ($input['create_front_page'] === 'no') {
|
||||||
|
$input['create_front_page'] = false;
|
||||||
|
}
|
||||||
|
$output['create_front_page'] = $input['create_front_page'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($input['change_permalink_structure'])) {
|
||||||
|
if ($input['change_permalink_structure'] === 'yes') {
|
||||||
|
$input['change_permalink_structure'] = true;
|
||||||
|
}
|
||||||
|
if ($input['change_permalink_structure'] === 'no') {
|
||||||
|
$input['change_permalink_structure'] = false;
|
||||||
|
}
|
||||||
|
$output['change_permalink_structure'] = $input['change_permalink_structure'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($input['change_uploads_folder'])) {
|
||||||
|
if ($input['change_uploads_folder'] === 'yes') {
|
||||||
|
$input['change_uploads_folder'] = true;
|
||||||
|
}
|
||||||
|
if ($input['change_uploads_folder'] === 'no') {
|
||||||
|
$input['change_uploads_folder'] = false;
|
||||||
|
}
|
||||||
|
$output['change_uploads_folder'] = $input['change_uploads_folder'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($input['create_navigation_menus'])) {
|
||||||
|
if ($input['create_navigation_menus'] === 'yes') {
|
||||||
|
$input['create_navigation_menus'] = true;
|
||||||
|
}
|
||||||
|
if ($input['create_navigation_menus'] === 'no') {
|
||||||
|
$input['create_navigation_menus'] = false;
|
||||||
|
}
|
||||||
|
$output['create_navigation_menus'] = $input['create_navigation_menus'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($input['add_pages_to_primary_navigation'])) {
|
||||||
|
if ($input['add_pages_to_primary_navigation'] === 'yes') {
|
||||||
|
$input['add_pages_to_primary_navigation'] = true;
|
||||||
|
}
|
||||||
|
if ($input['add_pages_to_primary_navigation'] === 'no') {
|
||||||
|
$input['add_pages_to_primary_navigation'] = false;
|
||||||
|
}
|
||||||
|
$output['add_pages_to_primary_navigation'] = $input['add_pages_to_primary_navigation'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return apply_filters('roots_theme_activation_options_validate', $output, $input, $defaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
function roots_theme_activation_action(){
|
||||||
|
$roots_theme_activation_options = roots_get_theme_activation_options();
|
||||||
|
|
||||||
|
if ($roots_theme_activation_options['create_front_page']) {
|
||||||
|
$roots_theme_activation_options['create_front_page'] = false;
|
||||||
|
|
||||||
|
$default_pages = array('Home');
|
||||||
|
$existing_pages = get_pages();
|
||||||
|
$temp = array();
|
||||||
|
|
||||||
|
foreach ($existing_pages as $page) {
|
||||||
|
$temp[] = $page->post_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pages_to_create = array_diff($default_pages, $temp);
|
||||||
|
|
||||||
|
foreach ($pages_to_create as $new_page_title) {
|
||||||
|
$add_default_pages = array(
|
||||||
|
'post_title' => $new_page_title,
|
||||||
|
'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat, orci ac laoreet cursus, dolor sem luctus lorem, eget consequat magna felis a magna. Aliquam scelerisque condimentum ante, eget facilisis tortor lobortis in. In interdum venenatis justo eget consequat. Morbi commodo rhoncus mi nec pharetra. Aliquam erat volutpat. Mauris non lorem eu dolor hendrerit dapibus. Mauris mollis nisl quis sapien posuere consectetur. Nullam in sapien at nisi ornare bibendum at ut lectus. Pellentesque ut magna mauris. Nam viverra suscipit ligula, sed accumsan enim placerat nec. Cras vitae metus vel dolor ultrices sagittis. Duis venenatis augue sed risus laoreet congue ac ac leo. Donec fermentum accumsan libero sit amet iaculis. Duis tristique dictum enim, ac fringilla risus bibendum in. Nunc ornare, quam sit amet ultricies gravida, tortor mi malesuada urna, quis commodo dui nibh in lacus. Nunc vel tortor mi. Pellentesque vel urna a arcu adipiscing imperdiet vitae sit amet neque. Integer eu lectus et nunc dictum sagittis. Curabitur commodo vulputate fringilla. Sed eleifend, arcu convallis adipiscing congue, dui turpis commodo magna, et vehicula sapien turpis sit amet nisi.',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'post_type' => 'page'
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = wp_insert_post($add_default_pages);
|
||||||
|
}
|
||||||
|
|
||||||
|
$home = get_page_by_title('Home');
|
||||||
|
update_option('show_on_front', 'page');
|
||||||
|
update_option('page_on_front', $home->ID);
|
||||||
|
|
||||||
|
$home_menu_order = array(
|
||||||
|
'ID' => $home->ID,
|
||||||
|
'menu_order' => -1
|
||||||
|
);
|
||||||
|
wp_update_post($home_menu_order);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($roots_theme_activation_options['change_permalink_structure']) {
|
||||||
|
$roots_theme_activation_options['change_permalink_structure'] = false;
|
||||||
|
|
||||||
|
if (get_option('permalink_structure') !== '/%postname%/') {
|
||||||
|
update_option('permalink_structure', '/%postname%/');
|
||||||
|
}
|
||||||
|
|
||||||
|
global $wp_rewrite;
|
||||||
|
$wp_rewrite->init();
|
||||||
|
$wp_rewrite->flush_rules();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($roots_theme_activation_options['change_uploads_folder']) {
|
||||||
|
$roots_theme_activation_options['change_uploads_folder'] = false;
|
||||||
|
|
||||||
|
update_option('uploads_use_yearmonth_folders', 0);
|
||||||
|
update_option('upload_path', 'assets');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($roots_theme_activation_options['create_navigation_menus']) {
|
||||||
|
$roots_theme_activation_options['create_navigation_menus'] = false;
|
||||||
|
|
||||||
|
$roots_nav_theme_mod = false;
|
||||||
|
|
||||||
|
if (!has_nav_menu('primary_navigation')) {
|
||||||
|
$primary_nav_id = wp_create_nav_menu('Primary Navigation', array('slug' => 'primary_navigation'));
|
||||||
|
$roots_nav_theme_mod['primary_navigation'] = $primary_nav_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has_nav_menu('utility_navigation')) {
|
||||||
|
$utility_nav_id = wp_create_nav_menu('Utility Navigation', array('slug' => 'utility_navigation'));
|
||||||
|
$roots_nav_theme_mod['utility_navigation'] = $utility_nav_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($roots_nav_theme_mod) {
|
||||||
|
set_theme_mod('nav_menu_locations', $roots_nav_theme_mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($roots_theme_activation_options['add_pages_to_primary_navigation']){
|
||||||
|
$roots_theme_activation_options['add_pages_to_primary_navigation'] = false;
|
||||||
|
|
||||||
|
$primary_nav = wp_get_nav_menu_object('Primary Navigation');
|
||||||
|
$primary_nav_term_id = (int) $primary_nav->term_id;
|
||||||
|
$menu_items= wp_get_nav_menu_items($primary_nav_term_id);
|
||||||
|
if (!$menu_items || empty($menu_items)) {
|
||||||
|
$pages = get_pages();
|
||||||
|
foreach($pages as $page) {
|
||||||
|
$item = array(
|
||||||
|
'menu-item-object-id' => $page->ID,
|
||||||
|
'menu-item-object' => 'page',
|
||||||
|
'menu-item-type' => 'post_type',
|
||||||
|
'menu-item-status' => 'publish'
|
||||||
|
);
|
||||||
|
wp_update_nav_menu_item($primary_nav_term_id, 0, $item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update_option('roots_theme_activation_options', $roots_theme_activation_options);
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action('admin_init','roots_theme_activation_action');
|
||||||
|
|
||||||
|
function roots_deactivation_action() {
|
||||||
|
update_option('roots_theme_activation_options', roots_get_default_theme_activation_options());
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action('switch_theme', 'roots_deactivation_action');
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -419,7 +419,7 @@ function roots_notice_tagline() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_option('blogdescription') === 'Just another WordPress site') {
|
if ((get_option('blogdescription') === 'Just another WordPress site') && isset($_GET['page']) != 'theme_activation_options') {
|
||||||
add_action('admin_notices', 'roots_notice_tagline');
|
add_action('admin_notices', 'roots_notice_tagline');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,7 +428,7 @@ function roots_notice_tagline_ignore() {
|
|||||||
$user_id = $current_user->ID;
|
$user_id = $current_user->ID;
|
||||||
if (isset($_GET['tagline_notice_ignore']) && '0' == $_GET['tagline_notice_ignore']) {
|
if (isset($_GET['tagline_notice_ignore']) && '0' == $_GET['tagline_notice_ignore']) {
|
||||||
add_user_meta($user_id, 'ignore_tagline_notice', 'true', true);
|
add_user_meta($user_id, 'ignore_tagline_notice', 'true', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('admin_init', 'roots_notice_tagline_ignore');
|
add_action('admin_init', 'roots_notice_tagline_ignore');
|
||||||
|
|||||||
@@ -27,16 +27,19 @@ function roots_option_page_capability($capability) {
|
|||||||
add_filter('option_page_capability_roots_options', 'roots_option_page_capability');
|
add_filter('option_page_capability_roots_options', 'roots_option_page_capability');
|
||||||
|
|
||||||
function roots_theme_options_add_page() {
|
function roots_theme_options_add_page() {
|
||||||
$theme_page = add_theme_page(
|
|
||||||
__('Theme Options', 'roots'),
|
|
||||||
__('Theme Options', 'roots'),
|
|
||||||
'edit_theme_options',
|
|
||||||
'theme_options',
|
|
||||||
'roots_theme_options_render_page'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$theme_page)
|
$roots_options = roots_get_theme_options();
|
||||||
return;
|
$roots_activation_options = roots_get_theme_activation_options();
|
||||||
|
if ($roots_activation_options['first_run']) {
|
||||||
|
$theme_page = add_theme_page(
|
||||||
|
__('Theme Options', 'roots'),
|
||||||
|
__('Theme Options', 'roots'),
|
||||||
|
'edit_theme_options',
|
||||||
|
'theme_options',
|
||||||
|
'roots_theme_options_render_page'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
add_action('admin_menu', 'roots_theme_options_add_page');
|
add_action('admin_menu', 'roots_theme_options_add_page');
|
||||||
|
|
||||||
@@ -44,10 +47,10 @@ function roots_admin_bar_render() {
|
|||||||
global $wp_admin_bar;
|
global $wp_admin_bar;
|
||||||
|
|
||||||
$wp_admin_bar->add_menu(array(
|
$wp_admin_bar->add_menu(array(
|
||||||
'parent' => 'appearance',
|
'parent' => 'appearance',
|
||||||
'id' => 'theme_options',
|
'id' => 'theme_options',
|
||||||
'title' => __('Theme Options', 'roots'),
|
'title' => __('Theme Options', 'roots'),
|
||||||
'href' => admin_url( 'themes.php?page=theme_options')
|
'href' => admin_url('themes.php?page=theme_options')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
add_action('wp_before_admin_bar_render', 'roots_admin_bar_render');
|
add_action('wp_before_admin_bar_render', 'roots_admin_bar_render');
|
||||||
@@ -55,7 +58,7 @@ add_action('wp_before_admin_bar_render', 'roots_admin_bar_render');
|
|||||||
global $roots_css_frameworks;
|
global $roots_css_frameworks;
|
||||||
$roots_css_frameworks = array(
|
$roots_css_frameworks = array(
|
||||||
'blueprint' => array(
|
'blueprint' => array(
|
||||||
'name' => 'blueprint',
|
'name' => 'blueprint',
|
||||||
'label' => __('Blueprint CSS', 'roots'),
|
'label' => __('Blueprint CSS', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'span-24',
|
'container' => 'span-24',
|
||||||
@@ -64,12 +67,12 @@ $roots_css_frameworks = array(
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
'960gs_12' => array(
|
'960gs_12' => array(
|
||||||
'name' => '960gs_12',
|
'name' => '960gs_12',
|
||||||
'label' => __('960gs (12 cols)', 'roots'),
|
'label' => __('960gs (12 cols)', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container_12',
|
'container' => 'container_12',
|
||||||
'main' => 'grid_7 suffix_1',
|
'main' => 'grid_7 suffix_1',
|
||||||
'sidebar' => 'grid_4'
|
'sidebar' => 'grid_4'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'960gs_16' => array(
|
'960gs_16' => array(
|
||||||
@@ -77,80 +80,80 @@ $roots_css_frameworks = array(
|
|||||||
'label' => __('960gs (16 cols)', 'roots'),
|
'label' => __('960gs (16 cols)', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container_16',
|
'container' => 'container_16',
|
||||||
'main' => 'grid_9 suffix_1',
|
'main' => 'grid_9 suffix_1',
|
||||||
'sidebar' => 'grid_6'
|
'sidebar' => 'grid_6'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'960gs_24' => array(
|
'960gs_24' => array(
|
||||||
'name' => '960gs_24',
|
'name' => '960gs_24',
|
||||||
'label' => __('960gs (24 cols)', 'roots'),
|
'label' => __('960gs (24 cols)', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container_24',
|
'container' => 'container_24',
|
||||||
'main' => 'grid_15 suffix_1',
|
'main' => 'grid_15 suffix_1',
|
||||||
'sidebar' => 'grid_8'
|
'sidebar' => 'grid_8'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'1140' => array(
|
'1140' => array(
|
||||||
'name' => '1140',
|
'name' => '1140',
|
||||||
'label' => __('1140', 'roots'),
|
'label' => __('1140', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => '',
|
'container' => '',
|
||||||
'main' => 'eightcol',
|
'main' => 'eightcol',
|
||||||
'sidebar' => 'fourcol last'
|
'sidebar' => 'fourcol last'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'adapt' => array(
|
'adapt' => array(
|
||||||
'name' => 'adapt',
|
'name' => 'adapt',
|
||||||
'label' => __('Adapt.js', 'roots'),
|
'label' => __('Adapt.js', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container_12 clearfix',
|
'container' => 'container_12 clearfix',
|
||||||
'main' => 'grid_7 suffix_1',
|
'main' => 'grid_7 suffix_1',
|
||||||
'sidebar' => 'grid_4'
|
'sidebar' => 'grid_4'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'less' => array(
|
'less' => array(
|
||||||
'name' => 'less',
|
'name' => 'less',
|
||||||
'label' => __('Less Framework 4', 'roots'),
|
'label' => __('Less Framework 4', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'container',
|
'container' => 'container',
|
||||||
'main' => '',
|
'main' => '',
|
||||||
'sidebar' => ''
|
'sidebar' => ''
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'foundation' => array(
|
'foundation' => array(
|
||||||
'name' => 'foundation',
|
'name' => 'foundation',
|
||||||
'label' => __('Foundation', 'roots'),
|
'label' => __('Foundation', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'row',
|
'container' => 'row',
|
||||||
'main' => 'eight columns',
|
'main' => 'eight columns',
|
||||||
'sidebar' => 'four columns'
|
'sidebar' => 'four columns'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'bootstrap' => array(
|
'bootstrap' => array(
|
||||||
'name' => 'bootstrap',
|
'name' => 'bootstrap',
|
||||||
'label' => __('Bootstrap', 'roots'),
|
'label' => __('Bootstrap', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'row',
|
'container' => 'row',
|
||||||
'main' => 'span11',
|
'main' => 'span11',
|
||||||
'sidebar' => 'span5'
|
'sidebar' => 'span5'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'bootstrap_less' => array(
|
'bootstrap_less' => array(
|
||||||
'name' => 'bootstrap_less',
|
'name' => 'bootstrap_less',
|
||||||
'label' => __('Bootstrap w/ Less', 'roots'),
|
'label' => __('Bootstrap w/ Less', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => 'row',
|
'container' => 'row',
|
||||||
'main' => 'span11',
|
'main' => 'span11',
|
||||||
'sidebar' => 'span5'
|
'sidebar' => 'span5'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'none' => array(
|
'none' => array(
|
||||||
'name' => 'none',
|
'name' => 'none',
|
||||||
'label' => __('None', 'roots'),
|
'label' => __('None', 'roots'),
|
||||||
'classes' => array(
|
'classes' => array(
|
||||||
'container' => '',
|
'container' => '',
|
||||||
'main' => '',
|
'main' => '',
|
||||||
'sidebar' => ''
|
'sidebar' => ''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -180,7 +183,7 @@ function roots_get_default_theme_options($default_framework = '') {
|
|||||||
'root_relative_urls' => true,
|
'root_relative_urls' => true,
|
||||||
'clean_menu' => true,
|
'clean_menu' => true,
|
||||||
'bootstrap_javascript' => false,
|
'bootstrap_javascript' => false,
|
||||||
'bootstrap_less_javascript' => false
|
'bootstrap_less_javascript' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
return apply_filters('roots_default_theme_options', $default_theme_options);
|
return apply_filters('roots_default_theme_options', $default_theme_options);
|
||||||
@@ -192,6 +195,7 @@ function roots_get_theme_options() {
|
|||||||
|
|
||||||
function roots_theme_options_render_page() {
|
function roots_theme_options_render_page() {
|
||||||
global $roots_css_frameworks;
|
global $roots_css_frameworks;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?php screen_icon(); ?>
|
<?php screen_icon(); ?>
|
||||||
@@ -204,7 +208,7 @@ function roots_theme_options_render_page() {
|
|||||||
$roots_options = roots_get_theme_options();
|
$roots_options = roots_get_theme_options();
|
||||||
$roots_default_options = roots_get_default_theme_options($roots_options['css_framework']);
|
$roots_default_options = roots_get_default_theme_options($roots_options['css_framework']);
|
||||||
?>
|
?>
|
||||||
|
<input type="hidden" value="1" name="roots_theme_options[first_run]" />
|
||||||
<table class="form-table">
|
<table class="form-table">
|
||||||
|
|
||||||
<tr valign="top" class="radio-option"><th scope="row"><?php _e('CSS Grid Framework', 'roots'); ?></th>
|
<tr valign="top" class="radio-option"><th scope="row"><?php _e('CSS Grid Framework', 'roots'); ?></th>
|
||||||
@@ -224,7 +228,7 @@ function roots_theme_options_render_page() {
|
|||||||
<fieldset><legend class="screen-reader-text"><span><?php _e('#main CSS Classes', 'roots'); ?></span></legend>
|
<fieldset><legend class="screen-reader-text"><span><?php _e('#main CSS Classes', 'roots'); ?></span></legend>
|
||||||
<input type="text" name="roots_theme_options[main_class]" id="main_class" value="<?php echo esc_attr($roots_options['main_class']); ?>" class="regular-text" />
|
<input type="text" name="roots_theme_options[main_class]" id="main_class" value="<?php echo esc_attr($roots_options['main_class']); ?>" class="regular-text" />
|
||||||
<br />
|
<br />
|
||||||
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['main_class']; ?></span></small>
|
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['main_class']; ?></span></small>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -234,12 +238,12 @@ function roots_theme_options_render_page() {
|
|||||||
<fieldset><legend class="screen-reader-text"><span><?php _e('#sidebar CSS Classes', 'roots'); ?></span></legend>
|
<fieldset><legend class="screen-reader-text"><span><?php _e('#sidebar CSS Classes', 'roots'); ?></span></legend>
|
||||||
<input type="text" name="roots_theme_options[sidebar_class]" id="sidebar_class" value="<?php echo esc_attr($roots_options['sidebar_class']); ?>" class="regular-text" />
|
<input type="text" name="roots_theme_options[sidebar_class]" id="sidebar_class" value="<?php echo esc_attr($roots_options['sidebar_class']); ?>" class="regular-text" />
|
||||||
<br />
|
<br />
|
||||||
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['sidebar_class']; ?></span></small>
|
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['sidebar_class']; ?></span></small>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php if($roots_options['css_framework'] == 'bootstrap') { ?>
|
<?php if($roots_options['css_framework'] == 'bootstrap') { ?>
|
||||||
<tr valign="top"><th scope="row"><?php _e('Bootstrap Javascript Packages', 'roots'); ?></th>
|
<tr valign="top"><th scope="row"><?php _e('Bootstrap Javascript Packages', 'roots'); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<fieldset class="roots_bootstrap_js"><legend class="screen-reader-text"><span><?php _e('Enable Bootstrap Javascript', 'roots'); ?></span></legend>
|
<fieldset class="roots_bootstrap_js"><legend class="screen-reader-text"><span><?php _e('Enable Bootstrap Javascript', 'roots'); ?></span></legend>
|
||||||
@@ -252,7 +256,7 @@ function roots_theme_options_render_page() {
|
|||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if($roots_options['css_framework'] == 'bootstrap_less') { ?>
|
<?php if($roots_options['css_framework'] == 'bootstrap_less') { ?>
|
||||||
<tr valign="top"><th scope="row"><?php _e('Bootstrap Javascript Packages', 'roots'); ?></th>
|
<tr valign="top"><th scope="row"><?php _e('Bootstrap Javascript Packages', 'roots'); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<fieldset class="roots_bootstrap_js"><legend class="screen-reader-text"><span><?php _e('Enable Bootstrap Javascript', 'roots'); ?></span></legend>
|
<fieldset class="roots_bootstrap_js"><legend class="screen-reader-text"><span><?php _e('Enable Bootstrap Javascript', 'roots'); ?></span></legend>
|
||||||
@@ -373,4 +377,4 @@ function roots_theme_options_validate($input) {
|
|||||||
return apply_filters('roots_theme_options_validate', $output, $input, $defaults);
|
return apply_filters('roots_theme_options_validate', $output, $input, $defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user