',
));
// Register additional extra widget areas:
$bfa_ata_extra_widget_areas = maybe_unserialize(get_option('bfa_widget_areas'));
for ($i =0; $i < count($bfa_ata_extra_widget_areas); $i++) {
register_sidebar(array(
'name' => $bfa_ata_extra_widget_areas[$i]['name'],
'before_widget' => $bfa_ata_extra_widget_areas[$i]['before_widget'],
'after_widget' => $bfa_ata_extra_widget_areas[$i]['after_widget'],
'before_title' => $bfa_ata_extra_widget_areas[$i]['before_title'],
'after_title' => $bfa_ata_extra_widget_areas[$i]['after_title']
));
}
}
// Load functions
include_once (TEMPLATEPATH . '/functions/bfa_header_config.php');
include_once (TEMPLATEPATH . '/functions/bfa_hor_cats.php');
include_once (TEMPLATEPATH . '/functions/bfa_hor_pages.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');
// 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.7 and older. From WP 2.8 it's 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');
// get the theme options
include_once (TEMPLATEPATH . '/functions/bfa_theme_options.php');
// add jquery function only to theme page or widgets won't work in 2.3 and older
#if ( $_GET['page'] == basename(__FILE__) ) {
// 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;
}
// change them back
function bfa_unescape($string) {
$string = str_replace('"', '"', $string);
$string = str_replace(''', "'", $string);
return $string;
}
function bfa_escapelt($string) {
$string = str_replace('<', '<', $string);
$string = str_replace('>', '>', $string);
return $string;
}
function footer_output($footer_content) {
$footer_content .= ' Powered by WordPress & the Atahualpa WP Theme by BytesForAll. Now with Tutorials & Support';
return $footer_content;
}
// new comment template for WP 2.7+, legacy template for old WP 2.6 and older
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');
}
// Javascript packer
include_once (TEMPLATEPATH . '/functions/JavaScriptPacker.phpp');
// remove WP default inline CSS for ".recentcomments a" from header
function remove_wp_widget_recent_comments_style() {
if ( has_filter('wp_head', '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');
}
// remove Sociable CSS & JS, will be included in css.php and js.php
# if (function_exists('sociable_html')) {
# remove_action('wp_head', 'sociable_wp_head');
# }
// uncomment to remove meta tag from header
# remove_action('wp_head', 'wp_generator');
// 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);
}
// Register new query variable "bfa_ata_file" 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';
return $public_query_vars;
}
/* redirect the template if new var "bfa_ata_file" exists in URL
and is "css" or "js". That means that a request for
mydomain.com/?bfa_ata_file=css would not try to display a
normal page but do whatever we define below. In this
case "get the saved options and display the CSS file" */
add_action('template_redirect', 'bfa_css_js_redirect');
function bfa_css_js_redirect() {
$bfa_ata_file_value = get_query_var('bfa_ata_file');
$bfa_ata_preview = get_query_var('preview');
if ( $bfa_ata_file_value == "css" OR $bfa_ata_file_value == "js" ) {
include_once (TEMPLATEPATH . '/functions/bfa_get_options.php');
include_once (TEMPLATEPATH . '/' . $bfa_ata_file_value . '.php');
exit; // this stops WordPress entirely
}
/* The above code doesn't work if the theme is being previewed.
In this case we're just including the css.php inline in the header. Otherwise
the theme would look broken in the preview due to the missing CSS */
if ( $bfa_ata_preview == 1 ) {
add_action('wp_head', 'bfa_inline_css');
function bfa_inline_css() {
$bfa_ata_preview = 1;
include_once (TEMPLATEPATH . '/' . 'css.php');
}
}
}
// Custom Excerpts
function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed
global $bfa_ata;
if ( '' == $text ) {
$text = get_the_content('');
$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 = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
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), $bfa_ata['custom_read_more']);
array_push($words, $custom_read_more);
$text = implode(' ', $words);
}
}
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:
';
update_option("bfa_widget_areas", $bfa_ata_widget_areas);
}
function bfa_table_cell_align($align_type) {
switch ($align_type) {
case 1: $string = 'align="center" valign="middle"'; break;
case 2: $string = 'align="center" valign="top"'; break;
case 3: $string = 'align="right" valign="top"'; break;
case 4: $string = 'align="right" valign="middle"'; break;
case 5: $string = 'align="right" valign="bottom"'; break;
case 6: $string = 'align="center" valign="bottom"'; break;
case 7: $string = 'align="left" valign="bottom"'; break;
case 8: $string = 'align="left" valign="middle"'; break;
case 9: $string = 'align="left" valign="top"';
}
return $string;
}
// This adds arbitrary content at various places in the center (= content) column:
function bfa_center_content($center_content) {
global $bfa_ata;
// PHP
// not for WPMU
if ( !file_exists(ABSPATH."/wpmu-settings.php") ) {
if ( strpos($center_content,''.$center_content);
$center_content = ob_get_contents();
ob_end_clean();
}
}
echo $center_content;
}
/* CUSTOM BODY TITLE and meta title, meta keywords, meta description */
/* Use the admin_menu action to define the custom boxes */
add_action('admin_menu', 'bfa_ata_add_custom_box');
/* Use the save_post action to do something with the data entered */
add_action('save_post', 'bfa_ata_save_postdata');
/* Adds a custom section to the "advanced" Post and Page edit screens */
function bfa_ata_add_custom_box() {
if( function_exists( 'add_meta_box' )) {
add_meta_box( 'bfa_ata_sectionid', __( 'Atahualpa Post Options', 'myplugin_textdomain' ),
'bfa_ata_inner_custom_box', 'post', 'normal', 'high' );
add_meta_box( 'bfa_ata_sectionid', __( 'Atahualpa Page Options', 'myplugin_textdomain' ),
'bfa_ata_inner_custom_box', 'page', 'normal', 'high' );
} else {
add_action('dbx_post_advanced', 'bfa_ata_old_custom_box' );
add_action('dbx_page_advanced', 'bfa_ata_old_custom_box' );
}
}
/* Prints the inner fields for the custom post/page section */
function bfa_ata_inner_custom_box() {
global $post;
// Use nonce for verification
echo '';
// The actual fields for data entry
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$meta_title = get_post_meta($post->ID, 'bfa_ata_meta_title', true);
$meta_keywords = get_post_meta($post->ID, 'bfa_ata_meta_keywords', true);
$meta_description = get_post_meta($post->ID, 'bfa_ata_meta_description', true);
$body_title = get_post_meta($post->ID, 'bfa_ata_body_title', true);
if ( get_post_meta($post->ID, 'bfa_ata_body_title_saved', true) != 1 ) {
$body_title = $title;
}
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
echo '
';
}
/* Prints the edit form for pre-WordPress 2.5 post/page */
function bfa_ata_old_custom_box() {
echo '
' . "\n";
echo '
\n";
}
/* When the post is saved, save our custom data */
function bfa_ata_save_postdata( $post_id ) {
/* verify this came from the our screen and with proper authorization,
because save_post can be triggered at other times */
if ( !wp_verify_nonce( $_POST['bfa_ata_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ))
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ))
return $post_id;
}
// Save the data
$new_body_title = $_POST['bfa_ata_body_title'];
$new_body_title_saved = $_POST['bfa_ata_body_title_saved'];
$new_meta_title = $_POST['bfa_ata_meta_title'];
$new_meta_keywords = $_POST['bfa_ata_meta_keywords'];
$new_meta_description = $_POST['bfa_ata_meta_description'];
add_post_meta($post_id, 'bfa_ata_body_title_saved', $new_body_title_saved, true)
OR update_post_meta($post_id, 'bfa_ata_body_title_saved', $new_body_title_saved);
add_post_meta($post_id, 'bfa_ata_meta_title', $new_meta_title, true)
OR update_post_meta($post_id, 'bfa_ata_meta_title', $new_meta_title);
add_post_meta($post_id, 'bfa_ata_meta_keywords', $new_meta_keywords, true)
OR update_post_meta($post_id, 'bfa_ata_meta_keywords', $new_meta_keywords);
add_post_meta($post_id, 'bfa_ata_meta_description', $new_meta_description, true)
OR update_post_meta($post_id, 'bfa_ata_meta_description', $new_meta_description);
add_post_meta($post_id, 'bfa_ata_body_title', $new_body_title, true)
OR update_post_meta($post_id, 'bfa_ata_body_title', $new_body_title);
}
?>