',
));
// Register additional extra widget areas:
# $bfa_ata_extra_widget_areas = get_option('bfa_widget_areas');
if(isset($bfa_ata['bfa_widget_areas'])) $bfa_ata_extra_widget_areas = $bfa_ata['bfa_widget_areas'];
else $bfa_ata_extra_widget_areas = '';
if ($bfa_ata_extra_widget_areas != '') {
foreach ($bfa_ata_extra_widget_areas as $widget_area) {
register_sidebar(array(
'name' => $widget_area['name'],
'before_widget' => $widget_area['before_widget'],
'after_widget' => $widget_area['after_widget'],
'before_title' => $widget_area['before_title'],
'after_title' => $widget_area['after_title']
));
}
}
}
#global $bfa_ata;
// Load functions
include_once (TEMPLATEPATH . '/functions/bfa_header_config.php');
include_once (TEMPLATEPATH . '/functions/bfa_meta_tags.php');
include_once (TEMPLATEPATH . '/functions/bfa_hor_cats.php');
include_once (TEMPLATEPATH . '/functions/bfa_hor_pages.php');
// New WP3 menus:
include_once (TEMPLATEPATH . '/functions/bfa_new_wp3_menus.php');
include_once (TEMPLATEPATH . '/functions/bfa_footer.php');
include_once (TEMPLATEPATH . '/functions/bfa_recent_comments.php');
include_once (TEMPLATEPATH . '/functions/bfa_popular_posts.php');
include_once (TEMPLATEPATH . '/functions/bfa_popular_in_cat.php');
include_once (TEMPLATEPATH . '/functions/bfa_subscribe.php');
include_once (TEMPLATEPATH . '/functions/bfa_postinfo.php');
include_once (TEMPLATEPATH . '/functions/bfa_rotating_header_images.php');
include_once (TEMPLATEPATH . '/functions/bfa_next_previous_links.php');
include_once (TEMPLATEPATH . '/functions/bfa_post_parts.php');
if (!function_exists('paged_comments'))
include_once (TEMPLATEPATH . '/functions/bfa_custom_comments.php');
// Since 3.5.2: JSON for PHP 4 & 5.1:
if (!function_exists('json_decode')) {
include_once (TEMPLATEPATH . '/functions/JSON.php');
function json_encode($data) { $json = new Services_JSON(); return( $json->encode($data) ); }
function json_decode($data) { $json = new Services_JSON(); return( $json->decode($data) ); }
}
function toArray($data) {
if (is_object($data)) $data = get_object_vars($data);
return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
}
// old, propretiary bodyclasses() of Atahualpa. Usage: bodyclasses()
// include_once (TEMPLATEPATH . '/functions/bfa_bodyclasses.php');
// new, default Wordpress body_class(). usage: body_class()
// include only in WP 2.3 - WP 2.7 . From WP 2.8 on it is a core Wordpress function:
/*
if (!function_exists('body_class'))
include_once (TEMPLATEPATH . '/functions/bfa_body_class.php');
*/
// For plugin "Sociable":
if (function_exists('sociable_html'))
include_once (TEMPLATEPATH . '/functions/bfa_sociable2.php');
// "Find in directory" function, needed for finding header images on WPMU
if (file_exists(ABSPATH."/wpmu-settings.php"))
include_once (TEMPLATEPATH . '/functions/bfa_m_find_in_dir.php');
// CSS for admin area
include_once (TEMPLATEPATH . '/functions/bfa_css_admin_head.php');
// Add the CSS to the ... of the theme option admin area
add_action('admin_head', 'bfa_add_stuff_admin_head');
include_once (TEMPLATEPATH . '/functions/bfa_ata_add_admin.php');
include_once (TEMPLATEPATH . '/functions/bfa_ata_admin.php');
add_action('admin_menu', 'bfa_ata_add_admin');
// Escape single & double quotes
function bfa_escape($string) {
$string = str_replace('"', '"', $string);
$string = str_replace("'", ''', $string);
return $string;
}
function footer_output($footer_content) {
global $bfa_ata;
$footer_content .= ' Powered by WordPress & Atahualpa';
return $footer_content;
}
// Move Featured Content Gallery down in script order in wp_head(), so that jQuery can finish before mootools
// Since 3.6 this probably won't work because as per the new WP rules wp_head() must be right before
function remove_featured_gallery_scripts() {
remove_action('wp_head', 'gallery_styles');
}
add_action('init','remove_featured_gallery_scripts', 1);
function addscripts_featured_gallery() {
if(!function_exists('gallery_styles')) return;
gallery_styles();
}
add_action('wp_head', 'addscripts_featured_gallery', 12);
/*
* Add custom header inserts through wp_head
*
* wp_head is supposed to be right before , but html_inserts_header should be after/at the bottom of wp_head
*
@ since 3.6.5
*/
function add_html_inserts_header() {
global $bfa_ata;
if( $bfa_ata['html_inserts_header'] != '' ) bfa_incl('html_inserts_header');
}
add_action('wp_head', 'add_html_inserts_header', 20);
// new comment template for WP 2.7+, legacy template for old WP 2.6 and older
// Since 3.6.: ToDo: Remove legacy.comments.php after a while. Older WP's won't work anyway
// with the new WP requirements to REPLACE older functions with newer ones introduced in 2.8 (i.e. get_the_author_meta)
if ( !function_exists('paged_comments') ) {
include_once (TEMPLATEPATH . '/functions/bfa_custom_comments.php');
function legacy_comments($file) {
if( !function_exists('wp_list_comments') )
$file = TEMPLATEPATH . '/legacy.comments.php';
return $file;
}
add_filter('comments_template', 'legacy_comments');
}
// remove WP default inline CSS for ".recentcomments a" from header
function remove_wp_widget_recent_comments_style() {
remove_filter('wp_head', 'wp_widget_recent_comments_style' );
}
add_filter( 'wp_head', 'remove_wp_widget_recent_comments_style', 1 );
/* Remove plugin CSS & JS and include them in the theme's main CSS and JS files
This will be extended and improved in upcoming versions */
// remove WP Pagenavi CSS, will be included in css.php
if (function_exists('wp_pagenavi')) {
remove_action('wp_head', 'pagenavi_css');
}
// If the plugin Share This is activated, disable its auto-output so we can control it
// through the Atahualpa Theme Options
if ( function_exists('akst_share_link') ) {
@define('AKST_ADDTOCONTENT', false);
@define('AKST_ADDTOFOOTER', false);
}
/* EXTERNAL OR INTERNAL CSS & JS, PLUS COMPRESSION & DEBUG */
// Register new query variables "bfa_ata_file" and "bfa_debug" with Wordpress
add_filter('query_vars', 'add_new_var_to_wp');
function add_new_var_to_wp($public_query_vars) {
$public_query_vars[] = 'bfa_ata_file';
$public_query_vars[] = 'bfa_debug';
return $public_query_vars;
}
// if debug add/remove info
if ( function_exists('wp_generator') ) {
remove_action('wp_head', 'wp_generator');
}
add_action('wp_head', 'bfa_debug');
function bfa_debug() {
global $bfa_ata, $bfa_ata_version;
$debug = get_query_var('bfa_debug');
if ( $debug == 1 ) {
echo '' . "\n";
if ( function_exists('the_generator') ) {
the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
}
echo ''."\n";
}
}
// redirect the template if new var "bfa_ata_file" or "bfa_debug" exists in URL
add_action('template_redirect', 'bfa_css_js_redirect');
add_action('wp_head', 'bfa_inline_css_js');
// since 3.4.3
function add_js_link() {
global $bfa_ata, $homeURL;
if ( $bfa_ata['javascript_external'] == "External" ) { ?>
Successfully deleted option \'bfa_ata4\' ...';
else echo 'Something went wrong...';
die();
}
// add_action ( 'wp_ajax_' + [name of "action" in jQuery.ajax, see functions/bfa_css_admin_head.php], [name of function])
add_action( 'wp_ajax_bfa_delete_bfa_ata4', 'bfa_delete_bfa_ata4' );
// Custom Excerpts
function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed
global $bfa_ata, $post;
if ( '' <> $text ) {
// an manual excerpt exists, stick on the 'custom read more' and we're done
$words = preg_split("/\s+/u", $text);
$custom_read_more = str_replace('%permalink%', get_permalink(), $bfa_ata['custom_read_more']);
if ( get_the_title() == '' ) {
$custom_read_more = str_replace('%title%', 'Permalink', $custom_read_more);
} else {
$custom_read_more = str_replace('%title%', the_title('','',FALSE), $custom_read_more);
}
array_push($words, $custom_read_more);
$text = implode(' ', $words);
return $text;
}
$text = get_the_content('');
$words = preg_split ("/\s+/u", $text);
$post_content = $post->post_content;
$post_content_length = count(preg_split("/\s+/u", $post_content));
// Build the excerpt from the post
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text, $bfa_ata['dont_strip_excerpts']);
$excerpt_length = $bfa_ata['excerpt_length'];
$words = preg_split("/\s+/u", $text, $excerpt_length + 1);
// this is to handle the case where the number of words
// in the post equals the excerpt length
if ($post_content_length > $excerpt_length) {
array_pop($words);
// array_pop($words);
$custom_read_more = str_replace('%permalink%', get_permalink(), $bfa_ata['custom_read_more']);
$custom_read_more = str_replace('%title%', the_title('','',FALSE), $custom_read_more);
array_push($words, $custom_read_more);
}
$text = implode(' ', $words);
return $text;
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'bfa_wp_trim_excerpt');
/* Custom widget areas.
Usage:
Example:
&after_widget='); ?>
Can be used anywhere in templates, and in theme option text areas that allow usage of PHP code.
Available paramaters:
Mandatory:
name Name under which all cells of this widget area will be listed at Site Admin -> Appearance -> Widgets
A widget area with 3 cells and a name of "My widget area" creates 3 widget cells which appear as
"My widget area 1", "My widget area 2" and "My widget area 3",
with the CSS ID's "my_widget_area_1", "my_widget_area_2" and "my_widget_area_3".
Optional:
cells Amount of (table) cells. Each cell is a new widget area. Default: 1
align Default alignment for all cells. Default: 2 (= center top). 1 = center middle, 2 = center top, 3 = right top, 4 = right middle,
5 = right bottom, 6 = center bottom, 7 = left bottom, 8 = left middle, 9 = left top.
align_1 Alignment for cell 1: align_2, align_3 ... Non-specified cells get the default value of "align", which, if not defined, is 2 (= center top).
width_1 Width of cell 1: width_1, width_2, width_3 ... Non-specified cells get a equal share of the remaining width of the whole table
containing all the widget area cells.
before_widget HTML before each widget in any cell of this widget area. Default:
after_widget HMTL after each widget ... Default:
before_title HTML before the title of each widget in any cell of this widget area: Default:
',
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$area_id = strtolower(str_replace(" ", "_", $r['name']));
# $bfa_widget_areas = get_option('bfa_widget_areas');
$bfa_widget_areas = $bfa_ata['bfa_widget_areas'];
// If there are more than 1 cell, use a table, otherwise just a DIV:
if ( $r['cells'] > 1 ) {
echo '
';
// If a width was set for any of the widget area cells:
# if ( strpos($args,'width_') !== FALSE ) {
// Since 3.6.7
$colgroup = 'no'; // If all table cells have the same width, this can be achieved by table-layout:fixed alone, without the colgroup element.
// Check if any of the cells have a set width
for ( $i = 1; $i <= $r['cells']; $i++ ) {
if ( array_key_exists('width_' . $i, $r) AND !empty($r['width_' . $i]) ) {
$colgroup = 'yes';
}
}
if ($colgroup == 'yes') {
echo "\n