Whitespace fixes
Replaced all hard tabs with spaces. Removed all trailing whitespace.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
add_action('roots_head', 'roots_google_analytics');
|
||||
add_action('roots_head', 'roots_fout_b_gone');
|
||||
@@ -12,68 +12,68 @@ add_action('roots_footer_after', 'roots_1140_footer_after');
|
||||
add_action('roots_post_inside_before', 'roots_page_breadcrumb');
|
||||
|
||||
function roots_google_analytics() {
|
||||
global $roots_options;
|
||||
$roots_google_analytics_id = $roots_options['google_analytics_id'];
|
||||
$get_roots_google_analytics_id = esc_attr($roots_options['google_analytics_id']);
|
||||
if ($roots_google_analytics_id !== '') {
|
||||
echo "\n\t<script>\n";
|
||||
echo "\t\tvar _gaq=[['_setAccount','$get_roots_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
|
||||
echo "\t\t(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];\n";
|
||||
echo "\t\tg.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';\n";
|
||||
echo "\t\ts.parentNode.insertBefore(g,s)}(document,'script'));\n";
|
||||
echo "\t</script>\n";
|
||||
}
|
||||
global $roots_options;
|
||||
$roots_google_analytics_id = $roots_options['google_analytics_id'];
|
||||
$get_roots_google_analytics_id = esc_attr($roots_options['google_analytics_id']);
|
||||
if ($roots_google_analytics_id !== '') {
|
||||
echo "\n\t<script>\n";
|
||||
echo "\t\tvar _gaq=[['_setAccount','$get_roots_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
|
||||
echo "\t\t(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];\n";
|
||||
echo "\t\tg.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';\n";
|
||||
echo "\t\ts.parentNode.insertBefore(g,s)}(document,'script'));\n";
|
||||
echo "\t</script>\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_fout_b_gone() {
|
||||
global $roots_options;
|
||||
$roots_fout_b_gone = $roots_options['fout_b_gone'];
|
||||
$template_uri = get_template_directory_uri();
|
||||
if ($roots_fout_b_gone === true) {
|
||||
echo "\t<script src=\"$template_uri/js/libs/foutbgone.min.js\"></script>\n";
|
||||
echo "\t<script>\n";
|
||||
echo "\t\tfbg.hideFOUT('asap', 100);\n";
|
||||
echo "\t</script>";
|
||||
}
|
||||
global $roots_options;
|
||||
$roots_fout_b_gone = $roots_options['fout_b_gone'];
|
||||
$template_uri = get_template_directory_uri();
|
||||
if ($roots_fout_b_gone === true) {
|
||||
echo "\t<script src=\"$template_uri/js/libs/foutbgone.min.js\"></script>\n";
|
||||
echo "\t<script>\n";
|
||||
echo "\t\tfbg.hideFOUT('asap', 100);\n";
|
||||
echo "\t</script>";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_1140_head() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
$template_uri = get_template_directory_uri();
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo "\t<script src=\"$template_uri/js/libs/css3-mediaqueries.js\"></script>";
|
||||
}
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
$template_uri = get_template_directory_uri();
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo "\t<script src=\"$template_uri/js/libs/css3-mediaqueries.js\"></script>";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_adapt_head() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
$template_uri = get_template_directory_uri();
|
||||
if ($roots_css_framework === 'adapt') {
|
||||
echo "\n\t<script>\n";
|
||||
echo "\t\tvar ADAPT_CONFIG = {\n";
|
||||
echo "\t\t\tpath: '$template_uri/css/adapt/',\n";
|
||||
echo "\t\t\tdynamic: true,\n";
|
||||
echo "\t\t\trange: [\n";
|
||||
echo "\t\t\t\t'0px to 760px = mobile.css',\n";
|
||||
echo "\t\t\t\t'760px to 980px = 720.css',\n";
|
||||
echo "\t\t\t\t'980px to 1280px = 960.css',\n";
|
||||
echo "\t\t\t\t'1280px to 1600px = 1200.css',\n";
|
||||
echo "\t\t\t\t'1600px to 1920px = 1560.css',\n";
|
||||
echo "\t\t\t\t'1920px = fluid.css'\n";
|
||||
echo "\t\t\t]\n";
|
||||
echo "\t\t};\n";
|
||||
echo "\t</script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/libs/adapt.min.js\"></script>";
|
||||
}
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
$template_uri = get_template_directory_uri();
|
||||
if ($roots_css_framework === 'adapt') {
|
||||
echo "\n\t<script>\n";
|
||||
echo "\t\tvar ADAPT_CONFIG = {\n";
|
||||
echo "\t\t\tpath: '$template_uri/css/adapt/',\n";
|
||||
echo "\t\t\tdynamic: true,\n";
|
||||
echo "\t\t\trange: [\n";
|
||||
echo "\t\t\t\t'0px to 760px = mobile.css',\n";
|
||||
echo "\t\t\t\t'760px to 980px = 720.css',\n";
|
||||
echo "\t\t\t\t'980px to 1280px = 960.css',\n";
|
||||
echo "\t\t\t\t'1280px to 1600px = 1200.css',\n";
|
||||
echo "\t\t\t\t'1600px to 1920px = 1560.css',\n";
|
||||
echo "\t\t\t\t'1920px = fluid.css'\n";
|
||||
echo "\t\t\t]\n";
|
||||
echo "\t\t};\n";
|
||||
echo "\t</script>\n";
|
||||
echo "\t<script src=\"$template_uri/js/libs/adapt.min.js\"></script>";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_get_stylesheets() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
|
||||
$styles = '';
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
|
||||
$styles = '';
|
||||
|
||||
switch ($roots_css_framework) {
|
||||
case 'blueprint' :
|
||||
@@ -102,15 +102,15 @@ function roots_get_stylesheets() {
|
||||
case 'less' :
|
||||
$styles .= stylesheet_link_tag('/less/less.css');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('RGForms')) {
|
||||
$styles .= "\t<link rel=\"stylesheet\" href=\"" . plugins_url(). "/gravityforms/css/forms.css\">\n";
|
||||
}
|
||||
if (class_exists('RGForms')) {
|
||||
$styles .= "\t<link rel=\"stylesheet\" href=\"" . plugins_url(). "/gravityforms/css/forms.css\">\n";
|
||||
}
|
||||
|
||||
if (is_child_theme()) {
|
||||
$styles .= stylesheet_link_tag('/style.css', 1);
|
||||
$styles .= "\t<link rel=\"stylesheet\" href=\"" . get_stylesheet_uri(). "\">\n";
|
||||
$styles .= "\t<link rel=\"stylesheet\" href=\"" . get_stylesheet_uri(). "\">\n";
|
||||
} else {
|
||||
$styles .= stylesheet_link_tag('/style.css', 1);
|
||||
}
|
||||
@@ -122,9 +122,9 @@ function roots_get_stylesheets() {
|
||||
case '1140' :
|
||||
$styles .= "\t<!--[if lt IE 8]>" . stylesheet_link_tag('/1140/ie.css', 0, false) . "<![endif]-->\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
echo $styles;
|
||||
echo $styles;
|
||||
}
|
||||
|
||||
function stylesheet_link_tag($file, $tabs = 0, $newline = true) {
|
||||
@@ -133,46 +133,46 @@ function stylesheet_link_tag($file, $tabs = 0, $newline = true) {
|
||||
}
|
||||
|
||||
function roots_1140_header_before() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo '<div class="container"><div class="row">', "\n";
|
||||
}
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo '<div class="container"><div class="row">', "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_1140_header_after() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo "</div></div><!-- /.row /.container -->\n";
|
||||
echo '<div class="container"><div class="row">', "\n";
|
||||
}
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo "</div></div><!-- /.row /.container -->\n";
|
||||
echo '<div class="container"><div class="row">', "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_1140_footer_before() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo "</div></div><!-- /.row /.container -->\n";
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo "</div></div><!-- /.row /.container -->\n";
|
||||
echo '<div class="container"><div class="row">', "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function roots_1140_footer_after() {
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo "</div></div><!-- /.row /.container -->\n";
|
||||
}
|
||||
global $roots_options;
|
||||
$roots_css_framework = $roots_options['css_framework'];
|
||||
if ($roots_css_framework === '1140') {
|
||||
echo "</div></div><!-- /.row /.container -->\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_page_breadcrumb() {
|
||||
global $post;
|
||||
if (function_exists('yoast_breadcrumb')) {
|
||||
if (is_page() && $post->post_parent) {
|
||||
yoast_breadcrumb('<p id="breadcrumbs">','</p>');
|
||||
}
|
||||
}
|
||||
global $post;
|
||||
if (function_exists('yoast_breadcrumb')) {
|
||||
if (is_page() && $post->post_parent) {
|
||||
yoast_breadcrumb('<p id="breadcrumbs">','</p>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -5,73 +5,73 @@
|
||||
global $pagenow;
|
||||
if (is_admin() && $pagenow === 'themes.php' && isset( $_GET['activated'])) {
|
||||
|
||||
// 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();
|
||||
// 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;
|
||||
}
|
||||
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) {
|
||||
|
||||
// create post object
|
||||
$add_default_pages = array(
|
||||
// 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(
|
||||
// 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
|
||||
if (get_option('permalink_structure') !== '/%year%/%postname%/') {
|
||||
update_option('permalink_structure', '/%year%/%postname%/');
|
||||
wp_update_post($home_menu_order);
|
||||
|
||||
// set the permalink structure
|
||||
if (get_option('permalink_structure') !== '/%year%/%postname%/') {
|
||||
update_option('permalink_structure', '/%year%/%postname%/');
|
||||
}
|
||||
|
||||
$wp_rewrite->init();
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
// don't organize uploads by year and month
|
||||
update_option('uploads_use_yearmonth_folders', 0);
|
||||
update_option('upload_path', 'assets');
|
||||
|
||||
// automatically create menus and set their locations
|
||||
// add all pages to the Primary Navigation
|
||||
$roots_nav_theme_mod = false;
|
||||
$wp_rewrite->init();
|
||||
$wp_rewrite->flush_rules();
|
||||
|
||||
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;
|
||||
}
|
||||
// don't organize uploads by year and month
|
||||
update_option('uploads_use_yearmonth_folders', 0);
|
||||
update_option('upload_path', 'assets');
|
||||
|
||||
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;
|
||||
}
|
||||
// automatically create menus and set their locations
|
||||
// add all pages to the Primary Navigation
|
||||
$roots_nav_theme_mod = false;
|
||||
|
||||
if ($roots_nav_theme_mod) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
$primary_nav = wp_get_nav_menu_object('Primary Navigation');
|
||||
|
||||
$primary_nav_term_id = (int) $primary_nav->term_id;
|
||||
@@ -91,4 +91,4 @@ if (is_admin() && $pagenow === 'themes.php' && isset( $_GET['activated'])) {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
// redirect /?s to /search/
|
||||
// http://txfx.net/wordpress-plugins/nice-search/
|
||||
function roots_nice_search_redirect() {
|
||||
if (is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/search/') === false) {
|
||||
wp_redirect(home_url('/search/' . str_replace(array(' ', '%20'), array('+', '+'), urlencode(get_query_var( 's' )))), 301);
|
||||
exit();
|
||||
}
|
||||
if (is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/search/') === false) {
|
||||
wp_redirect(home_url('/search/' . str_replace(array(' ', '%20'), array('+', '+'), urlencode(get_query_var( 's' )))), 301);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
add_action('template_redirect', 'roots_nice_search_redirect');
|
||||
|
||||
function roots_search_query($escaped = true) {
|
||||
$query = apply_filters('roots_search_query', get_query_var('s'));
|
||||
if ($escaped) {
|
||||
$query = esc_attr($query);
|
||||
}
|
||||
return urldecode($query);
|
||||
$query = apply_filters('roots_search_query', get_query_var('s'));
|
||||
if ($escaped) {
|
||||
$query = esc_attr($query);
|
||||
}
|
||||
return urldecode($query);
|
||||
}
|
||||
|
||||
add_filter('get_search_query', 'roots_search_query');
|
||||
@@ -25,90 +25,90 @@ add_filter('get_search_query', 'roots_search_query');
|
||||
// inspired by http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/
|
||||
// thanks to Scott Walkinshaw (scottwalkinshaw.com)
|
||||
function roots_root_relative_url($input) {
|
||||
$output = preg_replace_callback(
|
||||
'!(https?://[^/|"]+)([^"]+)?!',
|
||||
create_function(
|
||||
'$matches',
|
||||
// if full URL is site_url, return a slash for relative root
|
||||
'if (isset($matches[0]) && $matches[0] === site_url()) { return "/";' .
|
||||
// if domain is equal to site_url, then make URL relative
|
||||
'} elseif (isset($matches[0]) && strpos($matches[0], site_url()) !== false) { return $matches[2];' .
|
||||
// if domain is not equal to site_url, do not make external link relative
|
||||
'} else { return $matches[0]; };'
|
||||
),
|
||||
$input
|
||||
);
|
||||
return $output;
|
||||
$output = preg_replace_callback(
|
||||
'!(https?://[^/|"]+)([^"]+)?!',
|
||||
create_function(
|
||||
'$matches',
|
||||
// if full URL is site_url, return a slash for relative root
|
||||
'if (isset($matches[0]) && $matches[0] === site_url()) { return "/";' .
|
||||
// if domain is equal to site_url, then make URL relative
|
||||
'} elseif (isset($matches[0]) && strpos($matches[0], site_url()) !== false) { return $matches[2];' .
|
||||
// if domain is not equal to site_url, do not make external link relative
|
||||
'} else { return $matches[0]; };'
|
||||
),
|
||||
$input
|
||||
);
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Terrible workaround to remove the duplicate subfolder in the src of JS/CSS tags
|
||||
// Example: /subfolder/subfolder/css/style.css
|
||||
// Example: /subfolder/subfolder/css/style.css
|
||||
function roots_fix_duplicate_subfolder_urls($input) {
|
||||
$output = roots_root_relative_url($input);
|
||||
preg_match_all('!([^/]+)/([^/]+)!', $output, $matches);
|
||||
if (isset($matches[1]) && isset($matches[2])) {
|
||||
if ($matches[1][0] === $matches[2][0]) {
|
||||
$output = substr($output, strlen($matches[1][0]) + 1);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
$output = roots_root_relative_url($input);
|
||||
preg_match_all('!([^/]+)/([^/]+)!', $output, $matches);
|
||||
if (isset($matches[1]) && isset($matches[2])) {
|
||||
if ($matches[1][0] === $matches[2][0]) {
|
||||
$output = substr($output, strlen($matches[1][0]) + 1);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
$roots_options = roots_get_theme_options();
|
||||
if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) && $roots_options['root_relative_urls']) {
|
||||
add_filter('bloginfo_url', 'roots_root_relative_url');
|
||||
add_filter('theme_root_uri', 'roots_root_relative_url');
|
||||
add_filter('stylesheet_directory_uri', 'roots_root_relative_url');
|
||||
add_filter('template_directory_uri', 'roots_root_relative_url');
|
||||
add_filter('script_loader_src', 'roots_fix_duplicate_subfolder_urls');
|
||||
add_filter('style_loader_src', 'roots_fix_duplicate_subfolder_urls');
|
||||
add_filter('plugins_url', 'roots_root_relative_url');
|
||||
add_filter('the_permalink', 'roots_root_relative_url');
|
||||
add_filter('wp_list_pages', 'roots_root_relative_url');
|
||||
add_filter('wp_list_categories', 'roots_root_relative_url');
|
||||
add_filter('wp_nav_menu', 'roots_root_relative_url');
|
||||
add_filter('the_content_more_link', 'roots_root_relative_url');
|
||||
add_filter('the_tags', 'roots_root_relative_url');
|
||||
add_filter('get_pagenum_link', 'roots_root_relative_url');
|
||||
add_filter('get_comment_link', 'roots_root_relative_url');
|
||||
add_filter('month_link', 'roots_root_relative_url');
|
||||
add_filter('day_link', 'roots_root_relative_url');
|
||||
add_filter('year_link', 'roots_root_relative_url');
|
||||
add_filter('tag_link', 'roots_root_relative_url');
|
||||
add_filter('the_author_posts_link', 'roots_root_relative_url');
|
||||
add_filter('bloginfo_url', 'roots_root_relative_url');
|
||||
add_filter('theme_root_uri', 'roots_root_relative_url');
|
||||
add_filter('stylesheet_directory_uri', 'roots_root_relative_url');
|
||||
add_filter('template_directory_uri', 'roots_root_relative_url');
|
||||
add_filter('script_loader_src', 'roots_fix_duplicate_subfolder_urls');
|
||||
add_filter('style_loader_src', 'roots_fix_duplicate_subfolder_urls');
|
||||
add_filter('plugins_url', 'roots_root_relative_url');
|
||||
add_filter('the_permalink', 'roots_root_relative_url');
|
||||
add_filter('wp_list_pages', 'roots_root_relative_url');
|
||||
add_filter('wp_list_categories', 'roots_root_relative_url');
|
||||
add_filter('wp_nav_menu', 'roots_root_relative_url');
|
||||
add_filter('the_content_more_link', 'roots_root_relative_url');
|
||||
add_filter('the_tags', 'roots_root_relative_url');
|
||||
add_filter('get_pagenum_link', 'roots_root_relative_url');
|
||||
add_filter('get_comment_link', 'roots_root_relative_url');
|
||||
add_filter('month_link', 'roots_root_relative_url');
|
||||
add_filter('day_link', 'roots_root_relative_url');
|
||||
add_filter('year_link', 'roots_root_relative_url');
|
||||
add_filter('tag_link', 'roots_root_relative_url');
|
||||
add_filter('the_author_posts_link', 'roots_root_relative_url');
|
||||
}
|
||||
|
||||
// remove root relative URLs on any attachments in the feed
|
||||
function roots_root_relative_attachment_urls() {
|
||||
$roots_options = roots_get_theme_options();
|
||||
if (!is_feed() && $roots_options['root_relative_urls']) {
|
||||
add_filter('wp_get_attachment_url', 'roots_root_relative_url');
|
||||
add_filter('wp_get_attachment_link', 'roots_root_relative_url');
|
||||
}
|
||||
$roots_options = roots_get_theme_options();
|
||||
if (!is_feed() && $roots_options['root_relative_urls']) {
|
||||
add_filter('wp_get_attachment_url', 'roots_root_relative_url');
|
||||
add_filter('wp_get_attachment_link', 'roots_root_relative_url');
|
||||
}
|
||||
}
|
||||
|
||||
add_action('pre_get_posts', 'roots_root_relative_attachment_urls');
|
||||
|
||||
// set lang="en" as default (rather than en-US)
|
||||
function roots_language_attributes() {
|
||||
$attributes = array();
|
||||
$output = '';
|
||||
if (function_exists('is_rtl')) {
|
||||
if (is_rtl() == 'rtl') {
|
||||
$attributes[] = 'dir="rtl"';
|
||||
}
|
||||
}
|
||||
|
||||
$lang = get_bloginfo('language');
|
||||
if ($lang && $lang !== 'en-US') {
|
||||
$attributes[] = "lang=\"$lang\"";
|
||||
} else {
|
||||
$attributes[] = 'lang="en"';
|
||||
}
|
||||
$attributes = array();
|
||||
$output = '';
|
||||
if (function_exists('is_rtl')) {
|
||||
if (is_rtl() == 'rtl') {
|
||||
$attributes[] = 'dir="rtl"';
|
||||
}
|
||||
}
|
||||
|
||||
$output = implode(' ', $attributes);
|
||||
$output = apply_filters('roots_language_attributes', $output);
|
||||
return $output;
|
||||
$lang = get_bloginfo('language');
|
||||
if ($lang && $lang !== 'en-US') {
|
||||
$attributes[] = "lang=\"$lang\"";
|
||||
} else {
|
||||
$attributes[] = 'lang="en"';
|
||||
}
|
||||
|
||||
$output = implode(' ', $attributes);
|
||||
$output = apply_filters('roots_language_attributes', $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
add_filter('language_attributes', 'roots_language_attributes');
|
||||
@@ -119,173 +119,173 @@ add_filter('the_generator', 'roots_no_generator');
|
||||
|
||||
// cleanup wp_head
|
||||
function roots_noindex() {
|
||||
if (get_option('blog_public') === '0') {
|
||||
echo '<meta name="robots" content="noindex,nofollow">', "\n";
|
||||
}
|
||||
}
|
||||
if (get_option('blog_public') === '0') {
|
||||
echo '<meta name="robots" content="noindex,nofollow">', "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function roots_rel_canonical() {
|
||||
if (!is_singular()) {
|
||||
return;
|
||||
}
|
||||
if (!is_singular()) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp_the_query;
|
||||
if (!$id = $wp_the_query->get_queried_object_id()) {
|
||||
return;
|
||||
}
|
||||
global $wp_the_query;
|
||||
if (!$id = $wp_the_query->get_queried_object_id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$link = get_permalink($id);
|
||||
echo "\t<link rel=\"canonical\" href=\"$link\">\n";
|
||||
$link = get_permalink($id);
|
||||
echo "\t<link rel=\"canonical\" href=\"$link\">\n";
|
||||
}
|
||||
|
||||
// remove CSS from recent comments widget
|
||||
function roots_remove_recent_comments_style() {
|
||||
global $wp_widget_factory;
|
||||
if (isset($wp_widget_factory->widgets['WP_Widget_Recent_Comments'])) {
|
||||
remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style'));
|
||||
}
|
||||
global $wp_widget_factory;
|
||||
if (isset($wp_widget_factory->widgets['WP_Widget_Recent_Comments'])) {
|
||||
remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style'));
|
||||
}
|
||||
}
|
||||
|
||||
// remove CSS from gallery
|
||||
function roots_gallery_style($css) {
|
||||
return preg_replace("!<style type='text/css'>(.*?)</style>!s", '', $css);
|
||||
return preg_replace("!<style type='text/css'>(.*?)</style>!s", '', $css);
|
||||
}
|
||||
|
||||
function roots_head_cleanup() {
|
||||
// http://wpengineer.com/1438/wordpress-header/
|
||||
remove_action('wp_head', 'feed_links', 2);
|
||||
remove_action('wp_head', 'feed_links_extra', 3);
|
||||
remove_action('wp_head', 'rsd_link');
|
||||
remove_action('wp_head', 'wlwmanifest_link');
|
||||
remove_action('wp_head', 'index_rel_link');
|
||||
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
|
||||
remove_action('wp_head', 'start_post_rel_link', 10, 0);
|
||||
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
|
||||
remove_action('wp_head', 'wp_generator');
|
||||
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
|
||||
remove_action('wp_head', 'noindex', 1);
|
||||
add_action('wp_head', 'roots_noindex');
|
||||
remove_action('wp_head', 'rel_canonical');
|
||||
add_action('wp_head', 'roots_rel_canonical');
|
||||
add_action('wp_head', 'roots_remove_recent_comments_style', 1);
|
||||
add_filter('gallery_style', 'roots_gallery_style');
|
||||
|
||||
// stop Gravity Forms from outputting CSS since it's linked in header.php
|
||||
if (class_exists('RGForms')) {
|
||||
update_option('rg_gforms_disable_css', 1);
|
||||
}
|
||||
// http://wpengineer.com/1438/wordpress-header/
|
||||
remove_action('wp_head', 'feed_links', 2);
|
||||
remove_action('wp_head', 'feed_links_extra', 3);
|
||||
remove_action('wp_head', 'rsd_link');
|
||||
remove_action('wp_head', 'wlwmanifest_link');
|
||||
remove_action('wp_head', 'index_rel_link');
|
||||
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
|
||||
remove_action('wp_head', 'start_post_rel_link', 10, 0);
|
||||
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
|
||||
remove_action('wp_head', 'wp_generator');
|
||||
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
|
||||
remove_action('wp_head', 'noindex', 1);
|
||||
add_action('wp_head', 'roots_noindex');
|
||||
remove_action('wp_head', 'rel_canonical');
|
||||
add_action('wp_head', 'roots_rel_canonical');
|
||||
add_action('wp_head', 'roots_remove_recent_comments_style', 1);
|
||||
add_filter('gallery_style', 'roots_gallery_style');
|
||||
|
||||
// deregister l10n.js (new since WordPress 3.1)
|
||||
// why you might want to keep it: http://wordpress.stackexchange.com/questions/5451/what-does-l10n-js-do-in-wordpress-3-1-and-how-do-i-remove-it/5484#5484
|
||||
// don't load jQuery through WordPress since it's linked in header.php
|
||||
if (!is_admin()) {
|
||||
wp_deregister_script('l10n');
|
||||
wp_deregister_script('jquery');
|
||||
wp_register_script('jquery', '', '', '', true);
|
||||
}
|
||||
// stop Gravity Forms from outputting CSS since it's linked in header.php
|
||||
if (class_exists('RGForms')) {
|
||||
update_option('rg_gforms_disable_css', 1);
|
||||
}
|
||||
|
||||
// deregister l10n.js (new since WordPress 3.1)
|
||||
// why you might want to keep it: http://wordpress.stackexchange.com/questions/5451/what-does-l10n-js-do-in-wordpress-3-1-and-how-do-i-remove-it/5484#5484
|
||||
// don't load jQuery through WordPress since it's linked in header.php
|
||||
if (!is_admin()) {
|
||||
wp_deregister_script('l10n');
|
||||
wp_deregister_script('jquery');
|
||||
wp_register_script('jquery', '', '', '', true);
|
||||
}
|
||||
}
|
||||
|
||||
add_action('init', 'roots_head_cleanup');
|
||||
|
||||
// cleanup gallery_shortcode()
|
||||
function roots_gallery_shortcode($attr) {
|
||||
global $post, $wp_locale;
|
||||
global $post, $wp_locale;
|
||||
|
||||
static $instance = 0;
|
||||
$instance++;
|
||||
static $instance = 0;
|
||||
$instance++;
|
||||
|
||||
// Allow plugins/themes to override the default gallery template.
|
||||
$output = apply_filters('post_gallery', '', $attr);
|
||||
if ( $output != '' )
|
||||
return $output;
|
||||
// Allow plugins/themes to override the default gallery template.
|
||||
$output = apply_filters('post_gallery', '', $attr);
|
||||
if ( $output != '' )
|
||||
return $output;
|
||||
|
||||
// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
|
||||
if ( isset( $attr['orderby'] ) ) {
|
||||
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
|
||||
if ( !$attr['orderby'] )
|
||||
unset( $attr['orderby'] );
|
||||
}
|
||||
// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
|
||||
if ( isset( $attr['orderby'] ) ) {
|
||||
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
|
||||
if ( !$attr['orderby'] )
|
||||
unset( $attr['orderby'] );
|
||||
}
|
||||
|
||||
extract(shortcode_atts(array(
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order ID',
|
||||
'id' => $post->ID,
|
||||
'icontag' => 'figure',
|
||||
'captiontag' => 'figcaption',
|
||||
'columns' => 3,
|
||||
'size' => 'thumbnail',
|
||||
'include' => '',
|
||||
'exclude' => ''
|
||||
), $attr));
|
||||
extract(shortcode_atts(array(
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order ID',
|
||||
'id' => $post->ID,
|
||||
'icontag' => 'figure',
|
||||
'captiontag' => 'figcaption',
|
||||
'columns' => 3,
|
||||
'size' => 'thumbnail',
|
||||
'include' => '',
|
||||
'exclude' => ''
|
||||
), $attr));
|
||||
|
||||
$id = intval($id);
|
||||
if ( 'RAND' == $order )
|
||||
$orderby = 'none';
|
||||
$id = intval($id);
|
||||
if ( 'RAND' == $order )
|
||||
$orderby = 'none';
|
||||
|
||||
if ( !empty($include) ) {
|
||||
$include = preg_replace( '/[^0-9,]+/', '', $include );
|
||||
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
|
||||
if ( !empty($include) ) {
|
||||
$include = preg_replace( '/[^0-9,]+/', '', $include );
|
||||
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
|
||||
|
||||
$attachments = array();
|
||||
foreach ( $_attachments as $key => $val ) {
|
||||
$attachments[$val->ID] = $_attachments[$key];
|
||||
}
|
||||
} elseif ( !empty($exclude) ) {
|
||||
$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
|
||||
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
|
||||
} else {
|
||||
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
|
||||
}
|
||||
$attachments = array();
|
||||
foreach ( $_attachments as $key => $val ) {
|
||||
$attachments[$val->ID] = $_attachments[$key];
|
||||
}
|
||||
} elseif ( !empty($exclude) ) {
|
||||
$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
|
||||
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
|
||||
} else {
|
||||
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
|
||||
}
|
||||
|
||||
if ( empty($attachments) )
|
||||
return '';
|
||||
if ( empty($attachments) )
|
||||
return '';
|
||||
|
||||
if ( is_feed() ) {
|
||||
$output = "\n";
|
||||
foreach ( $attachments as $att_id => $attachment )
|
||||
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
|
||||
return $output;
|
||||
}
|
||||
if ( is_feed() ) {
|
||||
$output = "\n";
|
||||
foreach ( $attachments as $att_id => $attachment )
|
||||
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
$captiontag = tag_escape($captiontag);
|
||||
$columns = intval($columns);
|
||||
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
|
||||
$float = is_rtl() ? 'right' : 'left';
|
||||
$captiontag = tag_escape($captiontag);
|
||||
$columns = intval($columns);
|
||||
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
|
||||
$float = is_rtl() ? 'right' : 'left';
|
||||
|
||||
$selector = "gallery-{$instance}";
|
||||
$selector = "gallery-{$instance}";
|
||||
|
||||
$gallery_style = $gallery_div = '';
|
||||
if ( apply_filters( 'use_default_gallery_style', true ) )
|
||||
$gallery_style = "";
|
||||
$size_class = sanitize_html_class( $size );
|
||||
$gallery_div = "<section id='$selector' class='clearfix gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
|
||||
$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
|
||||
$gallery_style = $gallery_div = '';
|
||||
if ( apply_filters( 'use_default_gallery_style', true ) )
|
||||
$gallery_style = "";
|
||||
$size_class = sanitize_html_class( $size );
|
||||
$gallery_div = "<section id='$selector' class='clearfix gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
|
||||
$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
|
||||
|
||||
$i = 0;
|
||||
foreach ( $attachments as $id => $attachment ) {
|
||||
// make the gallery link to the file by default instead of the attachment
|
||||
// thanks to Matt Price (countingrows.com)
|
||||
$link = isset($attr['link']) && $attr['link'] === 'attachment' ?
|
||||
wp_get_attachment_link($id, $size, true, false) :
|
||||
$i = 0;
|
||||
foreach ( $attachments as $id => $attachment ) {
|
||||
// make the gallery link to the file by default instead of the attachment
|
||||
// thanks to Matt Price (countingrows.com)
|
||||
$link = isset($attr['link']) && $attr['link'] === 'attachment' ?
|
||||
wp_get_attachment_link($id, $size, true, false) :
|
||||
wp_get_attachment_link($id, $size, false, false);
|
||||
$output .= "
|
||||
<{$icontag} class=\"gallery-item\">
|
||||
$link
|
||||
";
|
||||
if ( $captiontag && trim($attachment->post_excerpt) ) {
|
||||
$output .= "
|
||||
<{$captiontag} class=\"gallery-caption\">
|
||||
" . wptexturize($attachment->post_excerpt) . "
|
||||
</{$captiontag}>";
|
||||
}
|
||||
$output .= "</{$icontag}>";
|
||||
if ( $columns > 0 && ++$i % $columns == 0 )
|
||||
$output .= '';
|
||||
}
|
||||
$output .= "
|
||||
<{$icontag} class=\"gallery-item\">
|
||||
$link
|
||||
";
|
||||
if ( $captiontag && trim($attachment->post_excerpt) ) {
|
||||
$output .= "
|
||||
<{$captiontag} class=\"gallery-caption\">
|
||||
" . wptexturize($attachment->post_excerpt) . "
|
||||
</{$captiontag}>";
|
||||
}
|
||||
$output .= "</{$icontag}>";
|
||||
if ( $columns > 0 && ++$i % $columns == 0 )
|
||||
$output .= '';
|
||||
}
|
||||
|
||||
$output .= "</section>\n";
|
||||
$output .= "</section>\n";
|
||||
|
||||
return $output;
|
||||
return $output;
|
||||
}
|
||||
|
||||
remove_shortcode('gallery');
|
||||
@@ -293,21 +293,21 @@ add_shortcode('gallery', 'roots_gallery_shortcode');
|
||||
|
||||
// http://www.deluxeblogtips.com/2011/01/remove-dashboard-widgets-in-wordpress.html
|
||||
function roots_remove_dashboard_widgets() {
|
||||
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
|
||||
remove_meta_box('dashboard_plugins', 'dashboard', 'normal');
|
||||
remove_meta_box('dashboard_primary', 'dashboard', 'normal');
|
||||
remove_meta_box('dashboard_secondary', 'dashboard', 'normal');
|
||||
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal');
|
||||
remove_meta_box('dashboard_plugins', 'dashboard', 'normal');
|
||||
remove_meta_box('dashboard_primary', 'dashboard', 'normal');
|
||||
remove_meta_box('dashboard_secondary', 'dashboard', 'normal');
|
||||
}
|
||||
|
||||
add_action('admin_init', 'roots_remove_dashboard_widgets');
|
||||
|
||||
// excerpt cleanup
|
||||
function roots_excerpt_length($length) {
|
||||
return 40;
|
||||
return 40;
|
||||
}
|
||||
|
||||
function roots_excerpt_more($more) {
|
||||
return ' … <a href="' . get_permalink() . '">' . __( 'Continued', 'roots' ) . '</a>';
|
||||
return ' … <a href="' . get_permalink() . '">' . __( 'Continued', 'roots' ) . '</a>';
|
||||
}
|
||||
|
||||
add_filter('excerpt_length', 'roots_excerpt_length');
|
||||
@@ -315,72 +315,72 @@ add_filter('excerpt_more', 'roots_excerpt_more');
|
||||
|
||||
// remove container from menus
|
||||
function roots_nav_menu_args($args = '') {
|
||||
$args['container'] = false;
|
||||
return $args;
|
||||
$args['container'] = false;
|
||||
return $args;
|
||||
}
|
||||
|
||||
add_filter('wp_nav_menu_args', 'roots_nav_menu_args');
|
||||
|
||||
class roots_nav_walker extends Walker_Nav_Menu {
|
||||
function start_el(&$output, $item, $depth, $args) {
|
||||
global $wp_query;
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
function start_el(&$output, $item, $depth, $args) {
|
||||
global $wp_query;
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
|
||||
$slug = sanitize_title($item->title);
|
||||
$slug = sanitize_title($item->title);
|
||||
|
||||
$class_names = $value = '';
|
||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||
$class_names = $value = '';
|
||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||
|
||||
$classes = array_filter($classes, 'roots_check_current');
|
||||
$classes = array_filter($classes, 'roots_check_current');
|
||||
|
||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
|
||||
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
|
||||
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||
|
||||
$id = apply_filters( 'nav_menu_item_id', 'menu-' . $slug, $item, $args );
|
||||
$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||
$id = apply_filters( 'nav_menu_item_id', 'menu-' . $slug, $item, $args );
|
||||
$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||
|
||||
$output .= $indent . '<li' . $id . $class_names . '>';
|
||||
$output .= $indent . '<li' . $id . $class_names . '>';
|
||||
|
||||
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
|
||||
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
|
||||
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
|
||||
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
|
||||
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
|
||||
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
|
||||
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
|
||||
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
|
||||
|
||||
$item_output = $args->before;
|
||||
$item_output .= '<a'. $attributes .'>';
|
||||
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
|
||||
$item_output .= '</a>';
|
||||
$item_output .= $args->after;
|
||||
$item_output = $args->before;
|
||||
$item_output .= '<a'. $attributes .'>';
|
||||
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
|
||||
$item_output .= '</a>';
|
||||
$item_output .= $args->after;
|
||||
|
||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||
}
|
||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||
}
|
||||
}
|
||||
|
||||
function roots_check_current($val) {
|
||||
return preg_match('/current-menu/', $val);
|
||||
return preg_match('/current-menu/', $val);
|
||||
}
|
||||
|
||||
// add to robots.txt
|
||||
// http://codex.wordpress.org/Search_Engine_Optimization_for_WordPress#Robots.txt_Optimization
|
||||
function roots_robots() {
|
||||
echo "Disallow: /cgi-bin\n";
|
||||
echo "Disallow: /wp-admin\n";
|
||||
echo "Disallow: /wp-includes\n";
|
||||
echo "Disallow: /wp-content/plugins\n";
|
||||
echo "Disallow: /plugins\n";
|
||||
echo "Disallow: /wp-content/cache\n";
|
||||
echo "Disallow: /wp-content/themes\n";
|
||||
echo "Disallow: /trackback\n";
|
||||
echo "Disallow: /feed\n";
|
||||
echo "Disallow: /comments\n";
|
||||
echo "Disallow: /category/*/*\n";
|
||||
echo "Disallow: */trackback\n";
|
||||
echo "Disallow: */feed\n";
|
||||
echo "Disallow: */comments\n";
|
||||
echo "Disallow: /*?*\n";
|
||||
echo "Disallow: /*?\n";
|
||||
echo "Allow: /wp-content/uploads\n";
|
||||
echo "Allow: /assets";
|
||||
echo "Disallow: /cgi-bin\n";
|
||||
echo "Disallow: /wp-admin\n";
|
||||
echo "Disallow: /wp-includes\n";
|
||||
echo "Disallow: /wp-content/plugins\n";
|
||||
echo "Disallow: /plugins\n";
|
||||
echo "Disallow: /wp-content/cache\n";
|
||||
echo "Disallow: /wp-content/themes\n";
|
||||
echo "Disallow: /trackback\n";
|
||||
echo "Disallow: /feed\n";
|
||||
echo "Disallow: /comments\n";
|
||||
echo "Disallow: /category/*/*\n";
|
||||
echo "Disallow: */trackback\n";
|
||||
echo "Disallow: */feed\n";
|
||||
echo "Disallow: */comments\n";
|
||||
echo "Disallow: /*?*\n";
|
||||
echo "Disallow: /*?\n";
|
||||
echo "Allow: /wp-content/uploads\n";
|
||||
echo "Allow: /assets";
|
||||
}
|
||||
|
||||
add_action('do_robots', 'roots_robots');
|
||||
@@ -388,7 +388,7 @@ add_action('do_robots', 'roots_robots');
|
||||
// we don't need to self-close these tags in html5:
|
||||
// <img>, <input>
|
||||
function roots_remove_self_closing_tags($input) {
|
||||
return str_replace(' />', '>', $input);
|
||||
return str_replace(' />', '>', $input);
|
||||
}
|
||||
|
||||
add_filter('get_avatar', 'roots_remove_self_closing_tags');
|
||||
@@ -400,23 +400,23 @@ add_filter('post_thumbnail_html', 'roots_remove_self_closing_tags');
|
||||
// you want to change this or remove it because it's used as the description in the RSS feed
|
||||
function roots_notice_tagline() {
|
||||
global $current_user;
|
||||
$user_id = $current_user->ID;
|
||||
if (!get_user_meta($user_id, 'ignore_tagline_notice')) {
|
||||
echo '<div class="error">';
|
||||
echo '<p>', sprintf(__('Please update your <a href="%s">site tagline</a> <a href="%s" style="float: right;">Hide Notice</a>', 'roots'), admin_url('options-general.php'), '?tagline_notice_ignore=0'), '</p>';
|
||||
echo '</div>';
|
||||
$user_id = $current_user->ID;
|
||||
if (!get_user_meta($user_id, 'ignore_tagline_notice')) {
|
||||
echo '<div class="error">';
|
||||
echo '<p>', sprintf(__('Please update your <a href="%s">site tagline</a> <a href="%s" style="float: right;">Hide Notice</a>', 'roots'), admin_url('options-general.php'), '?tagline_notice_ignore=0'), '</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (get_option('blogdescription') === 'Just another WordPress site') {
|
||||
add_action('admin_notices', 'roots_notice_tagline');
|
||||
if (get_option('blogdescription') === 'Just another WordPress site') {
|
||||
add_action('admin_notices', 'roots_notice_tagline');
|
||||
}
|
||||
|
||||
function roots_notice_tagline_ignore() {
|
||||
global $current_user;
|
||||
$user_id = $current_user->ID;
|
||||
if (isset($_GET['tagline_notice_ignore']) && '0' == $_GET['tagline_notice_ignore']) {
|
||||
add_user_meta($user_id, 'ignore_tagline_notice', 'true', true);
|
||||
global $current_user;
|
||||
$user_id = $current_user->ID;
|
||||
if (isset($_GET['tagline_notice_ignore']) && '0' == $_GET['tagline_notice_ignore']) {
|
||||
add_user_meta($user_id, 'ignore_tagline_notice', 'true', true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,13 +428,13 @@ if (!defined('WP_POST_REVISIONS')) define('WP_POST_REVISIONS', 5);
|
||||
|
||||
// allow more tags in TinyMCE including iframes
|
||||
function roots_change_mce_options($options) {
|
||||
$ext = 'pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]';
|
||||
if (isset($initArray['extended_valid_elements'])) {
|
||||
$options['extended_valid_elements'] .= ',' . $ext;
|
||||
} else {
|
||||
$options['extended_valid_elements'] = $ext;
|
||||
}
|
||||
return $options;
|
||||
$ext = 'pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]';
|
||||
if (isset($initArray['extended_valid_elements'])) {
|
||||
$options['extended_valid_elements'] .= ',' . $ext;
|
||||
} else {
|
||||
$options['extended_valid_elements'] = $ext;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
add_filter('tiny_mce_before_init', 'roots_change_mce_options');
|
||||
@@ -445,60 +445,60 @@ add_filter('style_loader_tag', 'roots_clean_style_tag');
|
||||
function roots_clean_style_tag($input) {
|
||||
preg_match_all("!<link rel='stylesheet'\s?(id='[^']+')?\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches);
|
||||
//only display media if it's print
|
||||
$media = $matches[3][0] === 'print' ? ' media="print"' : '';
|
||||
$media = $matches[3][0] === 'print' ? ' media="print"' : '';
|
||||
return '<link rel="stylesheet" href="' . $matches[2][0] . '"' . $media . '>' . "\n";
|
||||
}
|
||||
|
||||
function roots_body_class() {
|
||||
$term = get_queried_object();
|
||||
if (is_single())
|
||||
$cat = get_the_category();
|
||||
if(!empty($cat))
|
||||
return $cat[0]->slug;
|
||||
elseif(isset($term->slug))
|
||||
return $term->slug;
|
||||
elseif(isset($term->page_name))
|
||||
return $term->page_name;
|
||||
elseif(isset($term->post_name))
|
||||
return $term->post_name;
|
||||
else
|
||||
return;
|
||||
$term = get_queried_object();
|
||||
if (is_single())
|
||||
$cat = get_the_category();
|
||||
if(!empty($cat))
|
||||
return $cat[0]->slug;
|
||||
elseif(isset($term->slug))
|
||||
return $term->slug;
|
||||
elseif(isset($term->page_name))
|
||||
return $term->page_name;
|
||||
elseif(isset($term->post_name))
|
||||
return $term->post_name;
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
// first and last classes for widgets
|
||||
// http://wordpress.org/support/topic/how-to-first-and-last-css-classes-for-sidebar-widgets
|
||||
function roots_widget_first_last_classes($params) {
|
||||
global $my_widget_num;
|
||||
$this_id = $params[0]['id'];
|
||||
$arr_registered_widgets = wp_get_sidebars_widgets();
|
||||
global $my_widget_num;
|
||||
$this_id = $params[0]['id'];
|
||||
$arr_registered_widgets = wp_get_sidebars_widgets();
|
||||
|
||||
if (!$my_widget_num) {
|
||||
$my_widget_num = array();
|
||||
}
|
||||
if (!$my_widget_num) {
|
||||
$my_widget_num = array();
|
||||
}
|
||||
|
||||
if (!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) {
|
||||
return $params;
|
||||
}
|
||||
if (!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
if (isset($my_widget_num[$this_id])) {
|
||||
$my_widget_num[$this_id] ++;
|
||||
} else {
|
||||
$my_widget_num[$this_id] = 1;
|
||||
}
|
||||
if (isset($my_widget_num[$this_id])) {
|
||||
$my_widget_num[$this_id] ++;
|
||||
} else {
|
||||
$my_widget_num[$this_id] = 1;
|
||||
}
|
||||
|
||||
$class = 'class="widget-' . $my_widget_num[$this_id] . ' ';
|
||||
$class = 'class="widget-' . $my_widget_num[$this_id] . ' ';
|
||||
|
||||
if ($my_widget_num[$this_id] == 1) {
|
||||
$class .= 'widget-first ';
|
||||
} elseif ($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) {
|
||||
$class .= 'widget-last ';
|
||||
}
|
||||
if ($my_widget_num[$this_id] == 1) {
|
||||
$class .= 'widget-first ';
|
||||
} elseif ($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) {
|
||||
$class .= 'widget-last ';
|
||||
}
|
||||
|
||||
$params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']);
|
||||
$params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']);
|
||||
|
||||
return $params;
|
||||
return $params;
|
||||
|
||||
}
|
||||
add_filter('dynamic_sidebar_params', 'roots_widget_first_last_classes');
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
// header.php
|
||||
function roots_head() { do_action('roots_head'); }
|
||||
function roots_stylesheets() { do_action('roots_stylesheets'); }
|
||||
function roots_wrap_before() { do_action('roots_wrap_before'); }
|
||||
function roots_header_before() { do_action('roots_header_before'); }
|
||||
function roots_header_inside() { do_action('roots_header_inside'); }
|
||||
function roots_header_after() { do_action('roots_header_after'); }
|
||||
function roots_head() { do_action('roots_head'); }
|
||||
function roots_stylesheets() { do_action('roots_stylesheets'); }
|
||||
function roots_wrap_before() { do_action('roots_wrap_before'); }
|
||||
function roots_header_before() { do_action('roots_header_before'); }
|
||||
function roots_header_inside() { do_action('roots_header_inside'); }
|
||||
function roots_header_after() { do_action('roots_header_after'); }
|
||||
|
||||
// 404.php, archive.php, front-page.php, index.php, loop-page.php, loop-search.php, loop-single.php, loop.php
|
||||
// page-custom.php, page-full.php, page-sitemap.php, page-subpages.php, page.php, search.php, single.php
|
||||
function roots_content_before() { do_action('roots_content_before'); }
|
||||
function roots_content_after() { do_action('roots_content_after'); }
|
||||
function roots_main_before() { do_action('roots_main_before'); }
|
||||
function roots_main_after() { do_action('roots_main_after'); }
|
||||
function roots_post_before() { do_action('roots_post_before'); }
|
||||
function roots_post_after() { do_action('roots_post_after'); }
|
||||
function roots_post_inside_before() { do_action('roots_post_inside_before'); }
|
||||
function roots_post_inside_after() { do_action('roots_post_inside_after'); }
|
||||
function roots_loop_before() { do_action('roots_loop_before'); }
|
||||
function roots_loop_after() { do_action('roots_loop_after'); }
|
||||
function roots_sidebar_before() { do_action('roots_sidebar_before'); }
|
||||
function roots_sidebar_inside_before() { do_action('roots_sidebar_inside_before'); }
|
||||
function roots_sidebar_inside_after() { do_action('roots_sidebar_inside_after'); }
|
||||
function roots_sidebar_after() { do_action('roots_sidebar_after'); }
|
||||
function roots_content_before() { do_action('roots_content_before'); }
|
||||
function roots_content_after() { do_action('roots_content_after'); }
|
||||
function roots_main_before() { do_action('roots_main_before'); }
|
||||
function roots_main_after() { do_action('roots_main_after'); }
|
||||
function roots_post_before() { do_action('roots_post_before'); }
|
||||
function roots_post_after() { do_action('roots_post_after'); }
|
||||
function roots_post_inside_before() { do_action('roots_post_inside_before'); }
|
||||
function roots_post_inside_after() { do_action('roots_post_inside_after'); }
|
||||
function roots_loop_before() { do_action('roots_loop_before'); }
|
||||
function roots_loop_after() { do_action('roots_loop_after'); }
|
||||
function roots_sidebar_before() { do_action('roots_sidebar_before'); }
|
||||
function roots_sidebar_inside_before() { do_action('roots_sidebar_inside_before'); }
|
||||
function roots_sidebar_inside_after() { do_action('roots_sidebar_inside_after'); }
|
||||
function roots_sidebar_after() { do_action('roots_sidebar_after'); }
|
||||
|
||||
// footer.php
|
||||
function roots_footer_before() { do_action('roots_footer_before'); }
|
||||
function roots_footer_before() { do_action('roots_footer_before'); }
|
||||
function roots_footer_inside() { do_action('roots_footer_inside'); }
|
||||
function roots_footer_after() { do_action('roots_footer_after'); }
|
||||
function roots_footer() { do_action('roots_footer'); }
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -5,82 +5,82 @@
|
||||
// https://github.com/retlehs/roots/wiki/Lighttpd
|
||||
|
||||
if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
|
||||
function roots_htaccess_writable() {
|
||||
if (!is_writable(get_home_path() . '.htaccess')) {
|
||||
if (current_user_can('administrator')) {
|
||||
add_action('admin_notices', create_function('', "echo '<div class=\"error\"><p>" . sprintf(__('Please make sure your <a href="%s">.htaccess</a> file is writable ', 'roots'), admin_url('options-permalink.php')) . "</p></div>';"));
|
||||
}
|
||||
};
|
||||
}
|
||||
function roots_htaccess_writable() {
|
||||
if (!is_writable(get_home_path() . '.htaccess')) {
|
||||
if (current_user_can('administrator')) {
|
||||
add_action('admin_notices', create_function('', "echo '<div class=\"error\"><p>" . sprintf(__('Please make sure your <a href="%s">.htaccess</a> file is writable ', 'roots'), admin_url('options-permalink.php')) . "</p></div>';"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
add_action('admin_init', 'roots_htaccess_writable');
|
||||
add_action('admin_init', 'roots_htaccess_writable');
|
||||
|
||||
// Rewrites DO NOT happen for child themes
|
||||
// rewrite /wp-content/themes/roots/css/ to /css/
|
||||
// rewrite /wp-content/themes/roots/js/ to /js/
|
||||
// rewrite /wp-content/themes/roots/img/ to /js/
|
||||
// rewrite /wp-content/plugins/ to /plugins/
|
||||
// Rewrites DO NOT happen for child themes
|
||||
// rewrite /wp-content/themes/roots/css/ to /css/
|
||||
// rewrite /wp-content/themes/roots/js/ to /js/
|
||||
// rewrite /wp-content/themes/roots/img/ to /js/
|
||||
// rewrite /wp-content/plugins/ to /plugins/
|
||||
|
||||
function roots_flush_rewrites() {
|
||||
global $wp_rewrite;
|
||||
$wp_rewrite->flush_rules();
|
||||
}
|
||||
function roots_flush_rewrites() {
|
||||
global $wp_rewrite;
|
||||
$wp_rewrite->flush_rules();
|
||||
}
|
||||
|
||||
function roots_add_rewrites($content) {
|
||||
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
|
||||
global $wp_rewrite;
|
||||
$roots_new_non_wp_rules = array(
|
||||
'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1',
|
||||
'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1',
|
||||
'img/(.*)' => 'wp-content/themes/'. $theme_name . '/img/$1',
|
||||
'plugins/(.*)' => 'wp-content/plugins/$1'
|
||||
);
|
||||
$wp_rewrite->non_wp_rules += $roots_new_non_wp_rules;
|
||||
}
|
||||
function roots_add_rewrites($content) {
|
||||
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
|
||||
global $wp_rewrite;
|
||||
$roots_new_non_wp_rules = array(
|
||||
'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1',
|
||||
'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1',
|
||||
'img/(.*)' => 'wp-content/themes/'. $theme_name . '/img/$1',
|
||||
'plugins/(.*)' => 'wp-content/plugins/$1'
|
||||
);
|
||||
$wp_rewrite->non_wp_rules += $roots_new_non_wp_rules;
|
||||
}
|
||||
|
||||
add_action('admin_init', 'roots_flush_rewrites');
|
||||
add_action('admin_init', 'roots_flush_rewrites');
|
||||
|
||||
function roots_clean_assets($content) {
|
||||
$theme_name = next(explode('/themes/', $content));
|
||||
$current_path = '/wp-content/themes/' . $theme_name;
|
||||
$new_path = '';
|
||||
$content = str_replace($current_path, $new_path, $content);
|
||||
return $content;
|
||||
}
|
||||
function roots_clean_assets($content) {
|
||||
$theme_name = next(explode('/themes/', $content));
|
||||
$current_path = '/wp-content/themes/' . $theme_name;
|
||||
$new_path = '';
|
||||
$content = str_replace($current_path, $new_path, $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
function roots_clean_plugins($content) {
|
||||
$current_path = '/wp-content/plugins';
|
||||
$new_path = '/plugins';
|
||||
$content = str_replace($current_path, $new_path, $content);
|
||||
return $content;
|
||||
}
|
||||
function roots_clean_plugins($content) {
|
||||
$current_path = '/wp-content/plugins';
|
||||
$new_path = '/plugins';
|
||||
$content = str_replace($current_path, $new_path, $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
// only use clean urls if the theme isn't a child or an MU (Network) install
|
||||
if (!is_multisite() && !is_child_theme()) {
|
||||
add_action('generate_rewrite_rules', 'roots_add_rewrites');
|
||||
if (!is_admin()) {
|
||||
add_filter('plugins_url', 'roots_clean_plugins');
|
||||
add_filter('bloginfo', 'roots_clean_assets');
|
||||
add_filter('stylesheet_directory_uri', 'roots_clean_assets');
|
||||
add_filter('template_directory_uri', 'roots_clean_assets');
|
||||
add_filter('script_loader_src', 'roots_clean_plugins');
|
||||
add_filter('style_loader_src', 'roots_clean_plugins');
|
||||
}
|
||||
}
|
||||
// only use clean urls if the theme isn't a child or an MU (Network) install
|
||||
if (!is_multisite() && !is_child_theme()) {
|
||||
add_action('generate_rewrite_rules', 'roots_add_rewrites');
|
||||
if (!is_admin()) {
|
||||
add_filter('plugins_url', 'roots_clean_plugins');
|
||||
add_filter('bloginfo', 'roots_clean_assets');
|
||||
add_filter('stylesheet_directory_uri', 'roots_clean_assets');
|
||||
add_filter('template_directory_uri', 'roots_clean_assets');
|
||||
add_filter('script_loader_src', 'roots_clean_plugins');
|
||||
add_filter('style_loader_src', 'roots_clean_plugins');
|
||||
}
|
||||
}
|
||||
|
||||
function roots_add_h5bp_htaccess($rules) {
|
||||
global $wp_filesystem;
|
||||
function roots_add_h5bp_htaccess($rules) {
|
||||
global $wp_filesystem;
|
||||
|
||||
if (!defined('FS_METHOD')) define('FS_METHOD', 'direct');
|
||||
if (is_null($wp_filesystem)) WP_Filesystem(array(), ABSPATH);
|
||||
if (!defined('FS_METHOD')) define('FS_METHOD', 'direct');
|
||||
if (is_null($wp_filesystem)) WP_Filesystem(array(), ABSPATH);
|
||||
|
||||
$filename = __DIR__ . '/h5bp-htaccess';
|
||||
$rules .= $wp_filesystem->get_contents($filename);
|
||||
$filename = __DIR__ . '/h5bp-htaccess';
|
||||
$rules .= $wp_filesystem->get_contents($filename);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
add_action('mod_rewrite_rules', 'roots_add_h5bp_htaccess');
|
||||
add_action('mod_rewrite_rules', 'roots_add_h5bp_htaccess');
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,323 +1,323 @@
|
||||
<?php
|
||||
|
||||
function roots_admin_enqueue_scripts($hook_suffix) {
|
||||
if ($hook_suffix !== 'appearance_page_theme_options')
|
||||
return;
|
||||
if ($hook_suffix !== 'appearance_page_theme_options')
|
||||
return;
|
||||
|
||||
wp_enqueue_style('roots-theme-options', get_template_directory_uri() . '/inc/css/theme-options.css');
|
||||
wp_enqueue_script('roots-theme-options', get_template_directory_uri() . '/inc/js/theme-options.js');
|
||||
wp_enqueue_style('roots-theme-options', get_template_directory_uri() . '/inc/css/theme-options.css');
|
||||
wp_enqueue_script('roots-theme-options', get_template_directory_uri() . '/inc/js/theme-options.js');
|
||||
}
|
||||
add_action('admin_enqueue_scripts', 'roots_admin_enqueue_scripts');
|
||||
|
||||
function roots_theme_options_init() {
|
||||
if (false === roots_get_theme_options())
|
||||
add_option('roots_theme_options', roots_get_default_theme_options());
|
||||
if (false === roots_get_theme_options())
|
||||
add_option('roots_theme_options', roots_get_default_theme_options());
|
||||
|
||||
register_setting(
|
||||
'roots_options',
|
||||
'roots_theme_options',
|
||||
'roots_theme_options_validate'
|
||||
);
|
||||
register_setting(
|
||||
'roots_options',
|
||||
'roots_theme_options',
|
||||
'roots_theme_options_validate'
|
||||
);
|
||||
}
|
||||
add_action('admin_init', 'roots_theme_options_init');
|
||||
|
||||
function roots_option_page_capability($capability) {
|
||||
return 'edit_theme_options';
|
||||
return 'edit_theme_options';
|
||||
}
|
||||
add_filter('option_page_capability_roots_options', 'roots_option_page_capability');
|
||||
|
||||
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'
|
||||
);
|
||||
$theme_page = add_theme_page(
|
||||
__('Theme Options', 'roots'),
|
||||
__('Theme Options', 'roots'),
|
||||
'edit_theme_options',
|
||||
'theme_options',
|
||||
'roots_theme_options_render_page'
|
||||
);
|
||||
|
||||
if (!$theme_page)
|
||||
return;
|
||||
if (!$theme_page)
|
||||
return;
|
||||
}
|
||||
add_action('admin_menu', 'roots_theme_options_add_page');
|
||||
|
||||
function roots_admin_bar_render() {
|
||||
global $wp_admin_bar;
|
||||
global $wp_admin_bar;
|
||||
|
||||
$wp_admin_bar->add_menu(array(
|
||||
'parent' => 'appearance',
|
||||
'id' => 'theme_options',
|
||||
'title' => __('Theme Options', 'roots'),
|
||||
'href' => admin_url( 'themes.php?page=theme_options')
|
||||
));
|
||||
$wp_admin_bar->add_menu(array(
|
||||
'parent' => 'appearance',
|
||||
'id' => 'theme_options',
|
||||
'title' => __('Theme Options', 'roots'),
|
||||
'href' => admin_url( 'themes.php?page=theme_options')
|
||||
));
|
||||
}
|
||||
add_action('wp_before_admin_bar_render', 'roots_admin_bar_render');
|
||||
|
||||
global $roots_css_frameworks;
|
||||
$roots_css_frameworks = array(
|
||||
'blueprint' => array(
|
||||
'name' => 'blueprint',
|
||||
'label' => __('Blueprint CSS', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'span-24',
|
||||
'main' => 'span-14 append-1',
|
||||
'sidebar' => 'span-8 prepend-1 last'
|
||||
)
|
||||
),
|
||||
'960gs_12' => array(
|
||||
'name' => '960gs_12',
|
||||
'label' => __('960gs (12 cols)', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container_12',
|
||||
'main' => 'grid_7 suffix_1',
|
||||
'sidebar' => 'grid_4'
|
||||
)
|
||||
),
|
||||
'960gs_16' => array(
|
||||
'name' => '960gs_16',
|
||||
'label' => __('960gs (16 cols)', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container_16',
|
||||
'main' => 'grid_9 suffix_1',
|
||||
'sidebar' => 'grid_6'
|
||||
)
|
||||
),
|
||||
'960gs_24' => array(
|
||||
'name' => '960gs_24',
|
||||
'label' => __('960gs (24 cols)', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container_24',
|
||||
'main' => 'grid_15 suffix_1',
|
||||
'sidebar' => 'grid_8'
|
||||
)
|
||||
),
|
||||
'1140' => array(
|
||||
'name' => '1140',
|
||||
'label' => __('1140', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'twelvecol',
|
||||
'main' => 'eightcol',
|
||||
'sidebar' => 'fourcol last'
|
||||
)
|
||||
),
|
||||
'adapt' => array(
|
||||
'name' => 'adapt',
|
||||
'label' => __('Adapt.js', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container_12 clearfix',
|
||||
'main' => 'grid_7 suffix_1',
|
||||
'sidebar' => 'grid_4'
|
||||
)
|
||||
),
|
||||
'less' => array(
|
||||
'name' => 'less',
|
||||
'label' => __('Less Framework 4', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container',
|
||||
'main' => '',
|
||||
'sidebar' => ''
|
||||
)
|
||||
),
|
||||
'none' => array(
|
||||
'name' => 'none',
|
||||
'label' => __('None', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => '',
|
||||
'main' => '',
|
||||
'sidebar' => ''
|
||||
)
|
||||
)
|
||||
'blueprint' => array(
|
||||
'name' => 'blueprint',
|
||||
'label' => __('Blueprint CSS', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'span-24',
|
||||
'main' => 'span-14 append-1',
|
||||
'sidebar' => 'span-8 prepend-1 last'
|
||||
)
|
||||
),
|
||||
'960gs_12' => array(
|
||||
'name' => '960gs_12',
|
||||
'label' => __('960gs (12 cols)', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container_12',
|
||||
'main' => 'grid_7 suffix_1',
|
||||
'sidebar' => 'grid_4'
|
||||
)
|
||||
),
|
||||
'960gs_16' => array(
|
||||
'name' => '960gs_16',
|
||||
'label' => __('960gs (16 cols)', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container_16',
|
||||
'main' => 'grid_9 suffix_1',
|
||||
'sidebar' => 'grid_6'
|
||||
)
|
||||
),
|
||||
'960gs_24' => array(
|
||||
'name' => '960gs_24',
|
||||
'label' => __('960gs (24 cols)', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container_24',
|
||||
'main' => 'grid_15 suffix_1',
|
||||
'sidebar' => 'grid_8'
|
||||
)
|
||||
),
|
||||
'1140' => array(
|
||||
'name' => '1140',
|
||||
'label' => __('1140', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'twelvecol',
|
||||
'main' => 'eightcol',
|
||||
'sidebar' => 'fourcol last'
|
||||
)
|
||||
),
|
||||
'adapt' => array(
|
||||
'name' => 'adapt',
|
||||
'label' => __('Adapt.js', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container_12 clearfix',
|
||||
'main' => 'grid_7 suffix_1',
|
||||
'sidebar' => 'grid_4'
|
||||
)
|
||||
),
|
||||
'less' => array(
|
||||
'name' => 'less',
|
||||
'label' => __('Less Framework 4', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => 'container',
|
||||
'main' => '',
|
||||
'sidebar' => ''
|
||||
)
|
||||
),
|
||||
'none' => array(
|
||||
'name' => 'none',
|
||||
'label' => __('None', 'roots'),
|
||||
'classes' => array(
|
||||
'container' => '',
|
||||
'main' => '',
|
||||
'sidebar' => ''
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Write the above array of CSS frameworks into a script tag
|
||||
function roots_add_frameworks_object_script() {
|
||||
global $roots_css_frameworks;
|
||||
$json = json_encode($roots_css_frameworks);
|
||||
global $roots_css_frameworks;
|
||||
$json = json_encode($roots_css_frameworks);
|
||||
?>
|
||||
<script>
|
||||
var roots_css_frameworks = <?php echo $json; ?>;
|
||||
</script>
|
||||
<?php
|
||||
<script>
|
||||
var roots_css_frameworks = <?php echo $json; ?>;
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action('admin_head', 'roots_add_frameworks_object_script');
|
||||
|
||||
function roots_get_default_theme_options($default_framework = '') {
|
||||
global $roots_css_frameworks;
|
||||
if ($default_framework == '') { $default_framework = apply_filters('roots_default_css_framework', 'blueprint'); }
|
||||
$default_framework_settings = $roots_css_frameworks[$default_framework];
|
||||
$default_theme_options = array(
|
||||
'css_framework' => $default_framework,
|
||||
'container_class' => $default_framework_settings['classes']['container'],
|
||||
'main_class' => $default_framework_settings['classes']['main'],
|
||||
'sidebar_class' => $default_framework_settings['classes']['sidebar'],
|
||||
'google_analytics_id' => '',
|
||||
'root_relative_urls' => true,
|
||||
'clean_menu' => true,
|
||||
'fout_b_gone' => false
|
||||
);
|
||||
global $roots_css_frameworks;
|
||||
if ($default_framework == '') { $default_framework = apply_filters('roots_default_css_framework', 'blueprint'); }
|
||||
$default_framework_settings = $roots_css_frameworks[$default_framework];
|
||||
$default_theme_options = array(
|
||||
'css_framework' => $default_framework,
|
||||
'container_class' => $default_framework_settings['classes']['container'],
|
||||
'main_class' => $default_framework_settings['classes']['main'],
|
||||
'sidebar_class' => $default_framework_settings['classes']['sidebar'],
|
||||
'google_analytics_id' => '',
|
||||
'root_relative_urls' => true,
|
||||
'clean_menu' => true,
|
||||
'fout_b_gone' => false
|
||||
);
|
||||
|
||||
return apply_filters('roots_default_theme_options', $default_theme_options);
|
||||
return apply_filters('roots_default_theme_options', $default_theme_options);
|
||||
}
|
||||
|
||||
function roots_get_theme_options() {
|
||||
return get_option('roots_theme_options', roots_get_default_theme_options());
|
||||
return get_option('roots_theme_options', roots_get_default_theme_options());
|
||||
}
|
||||
|
||||
function roots_theme_options_render_page() {
|
||||
global $roots_css_frameworks;
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php printf(__('%s Theme Options', 'roots'), get_current_theme()); ?></h2>
|
||||
<?php settings_errors(); ?>
|
||||
global $roots_css_frameworks;
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php printf(__('%s Theme Options', 'roots'), get_current_theme()); ?></h2>
|
||||
<?php settings_errors(); ?>
|
||||
|
||||
<form method="post" action="options.php">
|
||||
<?php
|
||||
settings_fields('roots_options');
|
||||
$roots_options = roots_get_theme_options();
|
||||
$roots_default_options = roots_get_default_theme_options($roots_options['css_framework']);
|
||||
?>
|
||||
<form method="post" action="options.php">
|
||||
<?php
|
||||
settings_fields('roots_options');
|
||||
$roots_options = roots_get_theme_options();
|
||||
$roots_default_options = roots_get_default_theme_options($roots_options['css_framework']);
|
||||
?>
|
||||
|
||||
<table class="form-table">
|
||||
<table class="form-table">
|
||||
|
||||
<tr valign="top" class="radio-option"><th scope="row"><?php _e('CSS Grid Framework', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset class="roots_css_frameworks"><legend class="screen-reader-text"><span><?php _e('CSS Grid Framework', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_options[css_framework]" id="roots_theme_options[css_framework]">
|
||||
<?php foreach ($roots_css_frameworks as $css_framework) { ?>
|
||||
<option value="<?php echo esc_attr($css_framework['name']); ?>" <?php selected($roots_options['css_framework'], $css_framework['name']); ?>><?php echo $css_framework['label']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top" class="radio-option"><th scope="row"><?php _e('CSS Grid Framework', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset class="roots_css_frameworks"><legend class="screen-reader-text"><span><?php _e('CSS Grid Framework', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_options[css_framework]" id="roots_theme_options[css_framework]">
|
||||
<?php foreach ($roots_css_frameworks as $css_framework) { ?>
|
||||
<option value="<?php echo esc_attr($css_framework['name']); ?>" <?php selected($roots_options['css_framework'], $css_framework['name']); ?>><?php echo $css_framework['label']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><th scope="row"><?php _e('#main CSS Classes', 'roots'); ?></th>
|
||||
<td>
|
||||
<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" />
|
||||
<br />
|
||||
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['main_class']; ?></span></small>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('#main CSS Classes', 'roots'); ?></th>
|
||||
<td>
|
||||
<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" />
|
||||
<br />
|
||||
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['main_class']; ?></span></small>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><th scope="row"><?php _e('#sidebar CSS Classes', 'roots'); ?></th>
|
||||
<td>
|
||||
<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" />
|
||||
<br />
|
||||
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['sidebar_class']; ?></span></small>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('#sidebar CSS Classes', 'roots'); ?></th>
|
||||
<td>
|
||||
<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" />
|
||||
<br />
|
||||
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['sidebar_class']; ?></span></small>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><th scope="row"><?php _e('Google Analytics ID', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Google Analytics ID', 'roots'); ?></span></legend>
|
||||
<input type="text" name="roots_theme_options[google_analytics_id]" id="google_analytics_id" value="<?php echo esc_attr($roots_options['google_analytics_id']); ?>" />
|
||||
<br />
|
||||
<small class="description"><?php printf(__('Enter your UA-XXXXX-X ID', 'roots')); ?></small>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('Google Analytics ID', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Google Analytics ID', 'roots'); ?></span></legend>
|
||||
<input type="text" name="roots_theme_options[google_analytics_id]" id="google_analytics_id" value="<?php echo esc_attr($roots_options['google_analytics_id']); ?>" />
|
||||
<br />
|
||||
<small class="description"><?php printf(__('Enter your UA-XXXXX-X ID', 'roots')); ?></small>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><th scope="row"><?php _e('Enable Root Relative URLs', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable Root Relative URLs', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_options[root_relative_urls]" id="roots_theme_options[root_relative_urls]">
|
||||
<option value="yes" <?php selected($roots_options['root_relative_urls'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="no" <?php selected($roots_options['root_relative_urls'], false); ?>><?php echo _e('No', 'roots'); ?></option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('Enable Root Relative URLs', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable Root Relative URLs', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_options[root_relative_urls]" id="roots_theme_options[root_relative_urls]">
|
||||
<option value="yes" <?php selected($roots_options['root_relative_urls'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="no" <?php selected($roots_options['root_relative_urls'], false); ?>><?php echo _e('No', 'roots'); ?></option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><th scope="row"><?php _e('Cleanup Menu Output', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Cleanup Menu Output', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_options[clean_menu]" id="roots_theme_options[clean_menu]">
|
||||
<option value="yes" <?php selected($roots_options['clean_menu'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="no" <?php selected($roots_options['clean_menu'], false); ?>><?php echo _e('No', 'roots'); ?></option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('Cleanup Menu Output', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Cleanup Menu Output', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_options[clean_menu]" id="roots_theme_options[clean_menu]">
|
||||
<option value="yes" <?php selected($roots_options['clean_menu'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="no" <?php selected($roots_options['clean_menu'], false); ?>><?php echo _e('No', 'roots'); ?></option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><th scope="row"><?php _e('Enable FOUT-B-Gone', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable FOUT-B-Gone', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_options[fout_b_gone]" id="roots_theme_options[fout_b_gone]">
|
||||
<option value="yes" <?php selected($roots_options['fout_b_gone'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="no" <?php selected($roots_options['fout_b_gone'], false); ?>><?php echo _e('No', 'roots'); ?></option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('Enable FOUT-B-Gone', 'roots'); ?></th>
|
||||
<td>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable FOUT-B-Gone', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_options[fout_b_gone]" id="roots_theme_options[fout_b_gone]">
|
||||
<option value="yes" <?php selected($roots_options['fout_b_gone'], true); ?>><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="no" <?php selected($roots_options['fout_b_gone'], false); ?>><?php echo _e('No', 'roots'); ?></option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</table>
|
||||
|
||||
<?php submit_button(); ?>
|
||||
</form>
|
||||
</div>
|
||||
<?php submit_button(); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
function roots_theme_options_validate($input) {
|
||||
global $roots_css_frameworks;
|
||||
$output = $defaults = roots_get_default_theme_options();
|
||||
global $roots_css_frameworks;
|
||||
$output = $defaults = roots_get_default_theme_options();
|
||||
|
||||
if (isset($input['css_framework']) && array_key_exists($input['css_framework'], $roots_css_frameworks))
|
||||
$output['css_framework'] = $input['css_framework'];
|
||||
if (isset($input['css_framework']) && array_key_exists($input['css_framework'], $roots_css_frameworks))
|
||||
$output['css_framework'] = $input['css_framework'];
|
||||
|
||||
// set the value of the main container class depending on the selected grid framework
|
||||
$output['container_class'] = $roots_css_frameworks[$output['css_framework']]['classes']['container'];
|
||||
// set the value of the main container class depending on the selected grid framework
|
||||
$output['container_class'] = $roots_css_frameworks[$output['css_framework']]['classes']['container'];
|
||||
|
||||
if (isset($input['main_class'])) {
|
||||
$output['main_class'] = wp_filter_nohtml_kses($input['main_class']);
|
||||
}
|
||||
if (isset($input['main_class'])) {
|
||||
$output['main_class'] = wp_filter_nohtml_kses($input['main_class']);
|
||||
}
|
||||
|
||||
if (isset($input['sidebar_class'])) {
|
||||
$output['sidebar_class'] = wp_filter_nohtml_kses($input['sidebar_class']);
|
||||
}
|
||||
if (isset($input['sidebar_class'])) {
|
||||
$output['sidebar_class'] = wp_filter_nohtml_kses($input['sidebar_class']);
|
||||
}
|
||||
|
||||
if (isset($input['google_analytics_id'])) {
|
||||
if (preg_match('/^ua-\d{4,9}-\d{1,4}$/i', $input['google_analytics_id'])) {
|
||||
$output['google_analytics_id'] = $input['google_analytics_id'];
|
||||
}
|
||||
}
|
||||
if (isset($input['google_analytics_id'])) {
|
||||
if (preg_match('/^ua-\d{4,9}-\d{1,4}$/i', $input['google_analytics_id'])) {
|
||||
$output['google_analytics_id'] = $input['google_analytics_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($input['root_relative_urls'])) {
|
||||
if ($input['root_relative_urls'] === 'yes') {
|
||||
$input['root_relative_urls'] = true;
|
||||
}
|
||||
if ($input['root_relative_urls'] === 'no') {
|
||||
$input['root_relative_urls'] = false;
|
||||
}
|
||||
$output['root_relative_urls'] = $input['root_relative_urls'];
|
||||
}
|
||||
if (isset($input['root_relative_urls'])) {
|
||||
if ($input['root_relative_urls'] === 'yes') {
|
||||
$input['root_relative_urls'] = true;
|
||||
}
|
||||
if ($input['root_relative_urls'] === 'no') {
|
||||
$input['root_relative_urls'] = false;
|
||||
}
|
||||
$output['root_relative_urls'] = $input['root_relative_urls'];
|
||||
}
|
||||
|
||||
if (isset($input['clean_menu'])) {
|
||||
if ($input['clean_menu'] === 'yes') {
|
||||
$input['clean_menu'] = true;
|
||||
}
|
||||
if ($input['clean_menu'] === 'no') {
|
||||
$input['clean_menu'] = false;
|
||||
}
|
||||
$output['clean_menu'] = $input['clean_menu'];
|
||||
}
|
||||
if (isset($input['clean_menu'])) {
|
||||
if ($input['clean_menu'] === 'yes') {
|
||||
$input['clean_menu'] = true;
|
||||
}
|
||||
if ($input['clean_menu'] === 'no') {
|
||||
$input['clean_menu'] = false;
|
||||
}
|
||||
$output['clean_menu'] = $input['clean_menu'];
|
||||
}
|
||||
|
||||
if (isset($input['fout_b_gone'])) {
|
||||
if ($input['fout_b_gone'] === 'yes') {
|
||||
$input['fout_b_gone'] = true;
|
||||
}
|
||||
if ($input['fout_b_gone'] === 'no') {
|
||||
$input['fout_b_gone'] = false;
|
||||
}
|
||||
$output['fout_b_gone'] = $input['fout_b_gone'];
|
||||
}
|
||||
if (isset($input['fout_b_gone'])) {
|
||||
if ($input['fout_b_gone'] === 'yes') {
|
||||
$input['fout_b_gone'] = true;
|
||||
}
|
||||
if ($input['fout_b_gone'] === 'no') {
|
||||
$input['fout_b_gone'] = false;
|
||||
}
|
||||
$output['fout_b_gone'] = $input['fout_b_gone'];
|
||||
}
|
||||
|
||||
return apply_filters('roots_theme_options_validate', $output, $input, $defaults);
|
||||
return apply_filters('roots_theme_options_validate', $output, $input, $defaults);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -2,72 +2,72 @@
|
||||
|
||||
class roots_vcard extends WP_Widget {
|
||||
|
||||
function roots_vcard() {
|
||||
$widget_ops = array('description' => 'Display a vCard');
|
||||
parent::WP_Widget(false, __('Roots: vCard', 'roots'), $widget_ops);
|
||||
}
|
||||
function roots_vcard() {
|
||||
$widget_ops = array('description' => 'Display a vCard');
|
||||
parent::WP_Widget(false, __('Roots: vCard', 'roots'), $widget_ops);
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
extract($args);
|
||||
extract($instance);
|
||||
echo $before_widget;
|
||||
if ($title) {
|
||||
echo $before_title, $title, $after_title;
|
||||
}
|
||||
function widget($args, $instance) {
|
||||
extract($args);
|
||||
extract($instance);
|
||||
echo $before_widget;
|
||||
if ($title) {
|
||||
echo $before_title, $title, $after_title;
|
||||
}
|
||||
?>
|
||||
<p class="vcard">
|
||||
<a class="fn org url" href="<?php echo home_url('/'); ?>"><?php bloginfo('name'); ?></a><br>
|
||||
<span class="adr">
|
||||
<span class="street-address"><?php echo $street_address; ?></span><br>
|
||||
<span class="locality"><?php echo $locality; ?></span>,
|
||||
<span class="region"><?php echo $region; ?></span>
|
||||
<span class="postal-code"><?php echo $postal_code; ?></span><br>
|
||||
</span>
|
||||
<span class="tel"><span class="value"><span class="hidden">+1-</span><?php echo $tel; ?></span></span><br>
|
||||
<a class="email" href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a>
|
||||
</p>
|
||||
<p class="vcard">
|
||||
<a class="fn org url" href="<?php echo home_url('/'); ?>"><?php bloginfo('name'); ?></a><br>
|
||||
<span class="adr">
|
||||
<span class="street-address"><?php echo $street_address; ?></span><br>
|
||||
<span class="locality"><?php echo $locality; ?></span>,
|
||||
<span class="region"><?php echo $region; ?></span>
|
||||
<span class="postal-code"><?php echo $postal_code; ?></span><br>
|
||||
</span>
|
||||
<span class="tel"><span class="value"><span class="hidden">+1-</span><?php echo $tel; ?></span></span><br>
|
||||
<a class="email" href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a>
|
||||
</p>
|
||||
<?php
|
||||
echo $after_widget;
|
||||
}
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
return $new_instance;
|
||||
}
|
||||
function update($new_instance, $old_instance) {
|
||||
return $new_instance;
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title (optional):', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset($instance['title'])) { echo esc_attr($instance['title']); } ?>" class="widefat" id="<?php if (isset($instance['title'])) { echo $this->get_field_id('title'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('street_address'); ?>"><?php _e('Street Address:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('street_address'); ?>" value="<?php if (isset($instance['street_address'])) { echo esc_attr($instance['street_address']); } ?>" class="widefat" id="<?php if (isset($instance['street_address'])) { echo $this->get_field_id('street_address'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('locality'); ?>"><?php _e('City/Locality:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('locality'); ?>" value="<?php if (isset($instance['locality'])) { echo esc_attr($instance['locality']); } ?>" class="widefat" id="<?php if (isset($instance['locality'])) { echo $this->get_field_id('locality'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('region'); ?>"><?php _e('State/Region:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('region'); ?>" value="<?php if (isset($instance['region'])) { echo esc_attr($instance['region']); } ?>" class="widefat" id="<?php if (isset($instance['region'])) { echo $this->get_field_id('region'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('postal_code'); ?>"><?php _e('Zipcode/Postal Code:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('postal_code'); ?>" value="<?php if (isset($instance['postal_code'])) { echo esc_attr($instance['postal_code']); } ?>" class="widefat" id="<?php if (isset($instance['postal_code'])) { echo $this->get_field_id('postal_code'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('tel'); ?>"><?php _e('Telephone:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('tel'); ?>" value="<?php if (isset($instance['tel'])) { echo esc_attr($instance['tel']); } ?>" class="widefat" id="<?php if (isset($instance['tel'])) { echo $this->get_field_id('tel'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('email'); ?>"><?php _e('Email:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('email'); ?>" value="<?php if (isset($instance['email'])) { echo esc_attr($instance['email']); } ?>" class="widefat" id="<?php if (isset($instance['email'])) { echo $this->get_field_id('email'); } ?>" />
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
function form($instance) {
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title (optional):', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset($instance['title'])) { echo esc_attr($instance['title']); } ?>" class="widefat" id="<?php if (isset($instance['title'])) { echo $this->get_field_id('title'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('street_address'); ?>"><?php _e('Street Address:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('street_address'); ?>" value="<?php if (isset($instance['street_address'])) { echo esc_attr($instance['street_address']); } ?>" class="widefat" id="<?php if (isset($instance['street_address'])) { echo $this->get_field_id('street_address'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('locality'); ?>"><?php _e('City/Locality:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('locality'); ?>" value="<?php if (isset($instance['locality'])) { echo esc_attr($instance['locality']); } ?>" class="widefat" id="<?php if (isset($instance['locality'])) { echo $this->get_field_id('locality'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('region'); ?>"><?php _e('State/Region:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('region'); ?>" value="<?php if (isset($instance['region'])) { echo esc_attr($instance['region']); } ?>" class="widefat" id="<?php if (isset($instance['region'])) { echo $this->get_field_id('region'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('postal_code'); ?>"><?php _e('Zipcode/Postal Code:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('postal_code'); ?>" value="<?php if (isset($instance['postal_code'])) { echo esc_attr($instance['postal_code']); } ?>" class="widefat" id="<?php if (isset($instance['postal_code'])) { echo $this->get_field_id('postal_code'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('tel'); ?>"><?php _e('Telephone:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('tel'); ?>" value="<?php if (isset($instance['tel'])) { echo esc_attr($instance['tel']); } ?>" class="widefat" id="<?php if (isset($instance['tel'])) { echo $this->get_field_id('tel'); } ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('email'); ?>"><?php _e('Email:', 'roots'); ?></label>
|
||||
<input type="text" name="<?php echo $this->get_field_name('email'); ?>" value="<?php if (isset($instance['email'])) { echo esc_attr($instance['email']); } ?>" class="widefat" id="<?php if (isset($instance['email'])) { echo $this->get_field_id('email'); } ?>" />
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
register_widget('roots_vcard');
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user