__('Header top menu', 'cc'),
'primary' => __('Header bottom menu', 'cc'),
));
// This theme allows users to set a custom background
if ($cap->add_custom_background == true) {
add_theme_support('custom-background');
}
// Your changeable header business starts here
define('HEADER_TEXTCOLOR', '888888');
// No CSS, just an IMG call. The %s is a placeholder for the theme template directory URI.
define('HEADER_IMAGE', '%s/images/default-header.png');
// The height and width of your custom header. You can hook into the theme's own filters to change these values.
// Add a filter to cc_header_image_width and cc_header_image_height to change these values.
define('HEADER_IMAGE_WIDTH', apply_filters('cc_header_image_width', 1000));
define('HEADER_IMAGE_HEIGHT', apply_filters('cc_header_image_height', 233));
// Add a way for the custom header to be styled in the admin panel that controls
// custom headers. See cc_admin_header_style(), below.
if ($cap->add_custom_image_header == true) {
$defaults = array(
/* 'default-image' => '',
'random-default' => false,
'width' => 0,
'height' => 0,
'flex-height' => false,
'flex-width' => false,
'default-text-color' => '',
'header-text' => true,
'uploads' => true, */
// 'wp-head-callback' => 'cc_admin_header_style',
// 'admin-head-callback' => 'cc_header_style',
'admin-preview-callback' => 'cc_admin_header_image',
);
add_theme_support('custom-header', $defaults);
//add_custom_image_header( 'cc_header_style', 'cc_admin_header_style', 'cc_admin_header_image' );
}
// Define Content with
$content_width = "670";
if ($cap->sidebar_position == "left and right") {
$content_width = "432";
}
// Define disable the admin bar
if ($cap->bp_login_bar_top == 'off' || $cap->bp_login_bar_top == __('off', 'cc')) {
define('BP_DISABLE_ADMIN_BAR', true);
}
}
endif;
if (!function_exists('cc_admin_header_image')) :
/**
* Custom header image markup displayed on the Appearance > Header admin panel.
*
* Referenced via add_custom_image_header() in cc_setup().
*
*/
function cc_admin_header_image() {
?>
'
)
);
}
if ($cap->buddydev_search == true && defined('BP_VERSION') && function_exists('bp_is_active')) {
//* Add these code to your functions.php to allow Single Search page for all buddypress components*/
// Remove Buddypress search drowpdown for selecting members etc
add_filter("bp_search_form_type_select", "cc_remove_search_dropdown");
function cc_remove_search_dropdown($select_html) {
return '';
}
remove_action('init', 'bp_core_action_search_site', 5); //force buddypress to not process the search/redirect
add_action('init', 'cc_bp_buddydev_search', 10); // custom handler for the search
function cc_bp_buddydev_search() {
global $bp;
if ($bp->current_component == BP_SEARCH_SLUG)//if thids is search page
bp_core_load_template(apply_filters('bp_core_template_search_template', 'search-single')); //load the single searh template
}
add_action("advance-search", "cc_show_search_results", 1); //highest priority
/* we just need to filter the query and change search_term=The search text */
function cc_show_search_results() {
//filter the ajaxquerystring
add_filter("bp_ajax_querystring", "cc_global_search_qs", 100, 2);
}
//show the search results for member*/
function cc_show_member_search() { ?>
';
}
}
function cc_get_add_rate_us_message() {
return 'Please rate for Custom Community theme on WordPress.org';
}
/**
* Ajax processor for show/hide Please rate for
*/
add_action('wp_ajax_dismiss_activation_message', 'cc_dismiss_activation_message');
function cc_dismiss_activation_message() {
echo update_option('cc_hide_activation_message', $_POST['value']);
die();
}
/**
* Ajax processor for show/hide Please info for
*/
add_action('wp_ajax_cc_dismiss_info_messages', 'cc_dismiss_info_messages');
function cc_dismiss_info_messages() {
echo update_option($_POST['action'], $_POST['value']);
die();
}
/**
* Add css
*/
function cc_add_styles() {
global $cap;
if ($cap->cc_responsive_enable) {
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/_inc/css/bootstrap-responsive.css');
wp_enqueue_style('custom', get_template_directory_uri() . '/_inc/css/custom-responsive.css');
}
}
add_action('wp_head', 'cc_add_styles', 10);
/**
* Add class span%2 for menu items
* @param string $items
* @param array $args
* @return string items with new class
*/
function cc_add_spanclass($items, $args) {
$items = explode('', $items);
$newitems = array();
// loop through the menu items, and add the new link at the right position
foreach ($items as $item) {
$newitems[] = str_replace('class="', 'class="span2 ', $item);
}
// finally put all the menu items back together into a string using the ending
' . __('Something went wrong here. Some help: Check your theme settings and write a post with an featured image! Have a look how to setup your Slideshow or check out our Support if you still get stuck.', 'cc') . '
' . chr(13);
$tmp .='
' . chr(13);
}
wp_reset_query();
// js vars
$cc_js['slideshow'][] = array(
'id' => $id,
'time_in_ms' => $time_in_ms
);
return $tmp . chr(13);
}
/**
* Get class by sidebar position settings in Themes Options
*/
function cc_get_class_by_sidebar_position() {
global $cap, $post;
if(empty($post)){
return FALSE;
}
$class = '';
$tmp = get_post_meta($post->ID, '_wp_page_template', true);
switch ($cap->sidebar_position) {
case "left and right": $class = 'left-right-sidebar';
break;
case 'full-width' : $class = 'full-width';
break;
};
switch ($tmp) {
case '_pro/tpl-search-right-and-left-sidebar.php': $class .= ' left-right-template';
break;
case 'tpl-search-full-width.php': $class .= ' full-search-width';
break;
}
switch ($cap->archive_template) {
case __("left and right", 'cc'): $class .= ' archive-width';
}
return $class;
}
/**
* Add info before tabs in Theme Options
*/
function cc_add_settins_info($tab_id) {
if ('cap_slideshow' == $tab_id) {
$show = get_option('cc_dismiss_info_messages', FALSE);
if (empty($show)) {
_e('
Slideshow settings of the single pages are stronger and will overwrite the global slideshow settings
', CC_TRANSLATE_DOMAIN);
}
}
}
add_action('cc_before_settings_tab', 'cc_add_settins_info');
/**
* Add rotate function to jquery iu 1.9
*/
function cc_add_rotate_tabs() {
global $cap;
wp_enqueue_script('cc_rotate', get_template_directory_uri() . '/_inc/js/jquery-ui-tabs-rotate.js', array('jquery', 'jquery-ui-tabs'));
wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) );
wp_localize_script('dtheme-ajax-js', 'cc_settings', array(
'open_new_tab' => $cap->open_new_tab
));
}
add_action('wp_enqueue_scripts', 'cc_add_rotate_tabs');
/**
* Enqueue theme javascript safely for admin console
*
* @see http://codex.wordpress.org/Function_Reference/wp_enqueue_script
* @since 1.9.1
*/
function admin_dtheme_enqueue_scripts() {
global $cap;
$cap = new autoconfig();
//add for imadiatly view settings after save options
$responsive = !empty($_POST) && !empty($_POST['custom_community_theme_options']) ?
$_POST['custom_community_theme_options']['cap_cc_responsive_enable'] == __('Enabled', 'cc') ? 1 : 0 : $cap->cc_responsive_enable;
// Enqueue the global JS - Ajax will not work without it
wp_register_script('autogrow-textarea', get_template_directory_uri() . "/admin/js/jquery.autogrow-textarea.js", array(), true);
wp_enqueue_script('cc-theme-admin-js', get_template_directory_uri() . '/_inc/js/admin.js', array('jquery', 'autogrow-textarea'));
wp_localize_script('cc-theme-admin-js', 'admin_params', array(
'ajax_url' => site_url('/wp-admin/admin-ajax.php'),
'blog' => __('blog', 'cc'),
'flux_slider' => __('flux slider', 'cc'),
'default_slider' => __('default', 'cc'),
'responsive' => $responsive
)
);
}
add_action('admin_enqueue_scripts', 'admin_dtheme_enqueue_scripts');
/**
* WooCommerce 2.0+ Support
* since version 1.15
*/
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'cc_wc_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'cc_wc_wrapper_end', 10);
function cc_wc_wrapper_start() {
echo '
';
}
function cc_wc_wrapper_end() {
echo '
';
}
add_theme_support( 'woocommerce' );
/**
* Edit readmore links urls
* @param string $link
* @return string $link without
*/
function cc_remove_more_link_scroll( $link ) {
$link = preg_replace( '|#more-[0-9]+|', '', $link );
return $link;
}
add_filter( 'the_content_more_link', 'cc_remove_more_link_scroll' );
function get_posts_titles($title, $post_id){
global $cap, $post;
if(empty($cap->titles_post_types) || in_array($post->post_type, $cap->titles_post_types)){
$is_title_hidden = get_post_meta($post_id, '_cc_hide_title', TRUE);
if($is_title_hidden == 'yes'){
return FALSE;
}
$center_title = get_post_meta($post_id, '_cc_center_title', TRUE);
?>
ID )) {
$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
echo '' . chr(13);
}
}
add_action( 'wp_head', 'insert_image_src_rel_in_head', 5 );
/**
* Get body class for responsive/not responsive
* @global object $cap
* @return string body class
*/
function get_responcive_class(){
global $cap;
if($cap->cc_responsive_enable){
return 'responsive';
} else {
return 'not-responsive';
}
}
/**
* Add styles to front end wp editor
* @global type $editor_styles
*/
function cc_add_editor_styles() {
$stylesheet = '_inc/css/editor-style.css';
add_theme_support( 'editor-style' );
global $editor_styles;
$editor_styles = (array) $editor_styles;
$stylesheet = (array) $stylesheet;
if ( is_rtl() ) {
$rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]);
$stylesheet[] = $rtl_stylesheet;
}
$editor_styles = array_merge( $editor_styles, $stylesheet );
}
add_action( 'init', 'cc_add_editor_styles' );
/**
* Add scripts to admin part
*/
function cc_add_admin_editor_styles(){
add_editor_style('_inc/css/editor-styles.php');
wp_enqueue_style('admin_post_wodth', get_template_directory_uri() .'/_inc/css/width-calculators.php');
}
add_action('init', 'cc_add_admin_editor_styles', 100);
add_filter( 'wp_nav_menu_items', 'add_home_link', 10, 2 );
function add_home_link($items, $args) {
global $cap;
$community_item = $homeMenuItem = '';
if($cap->menue_disable_home == true){
ob_start();
?>
class="span2 current-menu-item">
menue_enable_community == true){
ob_start();
?>
class="span2 page_item current-menu-item">
class="selected">
class="selected">
class="selected">
class="selected">
class="selected">
='):
return ($key >= __($value, 'cc') || $key >= $value);
case ('<='):
return ($key <= __($value, 'cc') || $key <= $value);
case ('<'):
return ($key < __($value, 'cc') || $key < $value);
case ('>'):
return ($key > __($value, 'cc') || $key > $value);
case ('==='):
return ($key === __($value, 'cc') || $key === $value);
}
}
function cc_author_link(){
global $post;
if (defined('BP_VERSION')) {
echo sprintf( __('by %s', 'cc'), bp_core_get_userlink($post->post_author) );
}else{
echo sprintf( __('by %s', 'cc'), ''. get_the_author_meta( 'display_name' ) .'' );
}
}
/*
* Checking posts order on different archive pages
*/
function archive_post_order($query_string){
global $cap, $authordata;
if((is_category() && check_value($cap->posts_lists_category_order,'ASC','===')) ||
(is_tag() && check_value($cap->posts_lists_tag_order,'ASC','===')) ||
(is_author() && check_value($cap->posts_lists_author_order,'ASC','===')) ||
(is_date() && check_value($cap->posts_lists_date_order,'ASC','==='))){
query_posts($query_string.'&order=ASC');
}
}
function cc_exclude_home_3_posts( $query ) {
global $cap;
if (($cap->default_homepage_last_posts == 'show' || $cap->default_homepage_last_posts == __('show','cc')) &&
$query->is_home() && $query->is_main_query()
) {
$query->set( 'offset', '3' );
}
}
add_action( 'pre_get_posts', 'cc_exclude_home_3_posts' );
/*
* Alternative author archive check
*/
function custom_is_author(){
var_dump(is_archive());
return (is_archive() && !is_category() && !is_tag() && !is_date())? true:false;
}