'#000000', 'bodyBackground' => '#000000', 'baseFontFamily' => '#000000', 'baseFontSize' => '#000000', 'baseLineHeight' => '#000000', 'linkColor' => '#000000', 'linkColorHover' => '#000000', 'mainBackground' => '#ffffff' ); /** * * JS global variables * **/ function cherry_js_global_variables(){ $output = ""; echo $output; } add_action('wp_head', 'cherry_js_global_variables'); add_action('admin_head', 'cherry_js_global_variables'); /** * * Definition current theme * **/ function getCurrentTheme() { if ( function_exists('wp_get_theme') ) { $theme = wp_get_theme(); if ( $theme->exists() ) { $theme_name = $theme->Name; } } else { $theme_name = get_current_theme(); } $theme_name = preg_replace("/\W/", "_", strtolower($theme_name) ); return $theme_name; } /** * * Definition theme version * @param string $theme_name Directory name for the theme * **/ function cherry_get_theme_version($theme_name) { if ( function_exists('wp_get_theme') ) { $theme = wp_get_theme($theme_name); if ( $theme->exists() ) { $theme_ver = $theme->Version; } } else { $theme_data = get_theme_data( get_theme_root() . '/' . $theme_name . '/style.css' ); $theme_ver = $theme_data['Version']; } return $theme_ver; } /** * * Comment some value from variables.less * **/ if ( CURRENT_THEME != 'cherry' ) add_action('cherry_activation_hook', 'comment_child_var'); function comment_child_var() { global $variablesArray; $file = CHILD_DIR .'/bootstrap/less/variables.less'; if ( file_exists($file) ) { $allVariablessArray = file($file); foreach ($variablesArray as $key => $value) { foreach ($allVariablessArray as $k => $v) { $pos = strpos($v, $key); if ( $pos!==false && $pos == 1 ) { $allVariablessArray[$k] = '// ' . $v; break; } } } file_put_contents($file, $allVariablessArray); } } /** * Helper function to return the theme option value. * If no value has been saved, it returns $default. * Needed because options are saved as serialized strings. **/ if ( !function_exists( 'of_get_option' ) ) { function of_get_option($name, $default = false) { $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id $option_name = $optionsframework_settings['id']; if ( get_option($option_name) ) { $options = get_option($option_name); } if ( isset($options[$name]) ) { return $options[$name]; } else { return $default; } } } /** * * Unlink less cache files * **/ add_action('cherry_activation_hook', 'clean_less_cache'); function clean_less_cache() { if ( CURRENT_THEME == 'cherry' ) { $bootstrapInput = PARENT_DIR .'/less/bootstrap.less'; $themeInput = PARENT_DIR .'/less/style.less'; } else { $bootstrapInput = CHILD_DIR .'/bootstrap/less/bootstrap.less'; $themeInput = CHILD_DIR .'/style.less'; } $cacheFile1 = $bootstrapInput.".cache"; $cacheFile2 = $themeInput.".cache"; if (file_exists($cacheFile1)) unlink($cacheFile1); if (file_exists($cacheFile2)) unlink($cacheFile2); } if ( (is_admin() && ($pagenow == "themes.php")) && FILE_WRITEABLE ) { do_action('cherry_activation_hook'); } if ( !function_exists('cherry_theme_setup')) { function cherry_theme_setup() { //Loading theme textdomain load_theme_textdomain( CURRENT_THEME, PARENT_DIR . '/languages' ); //Localization functions include_once (PARENT_DIR . '/includes/locals.php'); //Plugin Activation include_once (CHILD_DIR . '/includes/register-plugins.php'); //Setup MotoPress include_once (PARENT_DIR . '/includes/register-motopress.php'); //Include shop if ( file_exists(get_stylesheet_directory().'/shop.php') ) { include_once (CHILD_DIR . '/shop.php'); } } add_action('after_setup_theme', 'cherry_theme_setup'); } //WPML compatibility //WPML filter for correct posts IDs for the current language Solution if ( function_exists( 'wpml_get_language_information' )) { update_option('suppress_filters', 0); } else { update_option('suppress_filters', 1); } //Register text for translation function cherry_wpml_translate_filter( $value, $name ) { return icl_translate( 'cherry', $name, $value ); } //Check if WPML is activated if ( function_exists( 'icl_translate' ) ) { add_filter( 'cherry_text_translate', 'cherry_wpml_translate_filter', 10, 2 ); } //Loading Custom function include_once (CHILD_DIR . '/includes/custom-function.php'); //Loading jQuery and Scripts include_once (PARENT_DIR . '/includes/theme-scripts.php'); //Sidebar include_once (CHILD_DIR . '/includes/sidebar-init.php'); //Theme initialization include_once (CHILD_DIR . '/includes/theme-init.php'); //Additional function include_once (PARENT_DIR . '/includes/theme-function.php'); //Aqua Resizer for image cropping and resizing on the fly include_once (PARENT_DIR . '/includes/aq_resizer.php'); //Add the pagemeta include_once (PARENT_DIR . '/includes/theme-pagemeta.php'); //Add the postmeta include_once (PARENT_DIR . '/includes/theme-postmeta.php'); //Add the postmeta to Portfolio posts include_once (PARENT_DIR . '/includes/theme-portfoliometa.php'); //Add the postmeta to Slider posts include_once (PARENT_DIR . '/includes/theme-slidermeta.php'); //Add the postmeta to Testimonials include_once (PARENT_DIR . '/includes/theme-testimeta.php'); //Add the postmeta to Our Team posts include_once (PARENT_DIR . '/includes/theme-teammeta.php'); //Loading options.php for theme customizer include_once (CHILD_DIR . '/options.php'); include_once (PARENT_DIR . '/framework_options.php'); //Framework Data Management include_once (PARENT_DIR . '/admin/data_management/data_management_interface.php'); //SEO Settings include_once (PARENT_DIR . '/admin/seo/seo_settings_page.php'); //WP Pointers include_once (PARENT_DIR . '/includes/class.wp-help-pointers.php'); //Embedding LESS compile if ( !class_exists('lessc') ) { include_once (PARENT_DIR .'/includes/lessc.inc.php'); } include_once (PARENT_DIR .'/includes/less-compile.php'); // Olark Live Chat. if ( is_child_theme() && file_exists( CHILD_DIR . '/includes/live-chat.php' ) ) { include_once ( CHILD_DIR . '/includes/live-chat.php' ); } else { include_once ( PARENT_DIR . '/includes/live-chat.php' ); } // TM Live Chat. if ( 'yes' == of_get_option( 'tm_live_chat', 'yes' ) ) { include_once ( PARENT_DIR . '/includes/tm-chat/class-cherry-tm-chat.php' ); } // removes detailed login error information for security add_filter('login_errors',create_function('$a', "return null;")); /* * Loads the Options Panel * * If you're loading from a child theme use stylesheet_directory * instead of template_directory */ if ( !function_exists( 'optionsframework_init' ) ) { define( 'OPTIONS_FRAMEWORK_DIRECTORY', PARENT_URL . '/admin/' ); include_once dirname( __FILE__ ) . '/admin/options-framework.php'; } /* * Removes Trackbacks from the comment count * */ if ( !function_exists('comment_count') ) { add_filter('get_comments_number', 'comment_count', 0); function comment_count( $count ) { if ( ! is_admin() ) { global $id; $args = 'status=approve&post_id=' . $id; $comments = get_comments( $args, ARRAY_A ); $comments_by_type = separate_comments( $comments ); return count($comments_by_type['comment']); } else { return $count; } } } /* * Post Formats * */ $formats = array( 'aside', 'gallery', 'link', 'image', 'quote', 'audio', 'video'); add_theme_support( 'post-formats', $formats ); add_post_type_support( 'post', 'post-formats' ); /* * Custom excpert length * */ if(!function_exists('new_excerpt_length')) { function new_excerpt_length($length) { return 60; } add_filter('excerpt_length', 'new_excerpt_length'); } add_filter( 'the_excerpt', 'do_shortcode' ); // enable shortcodes in sidebar add_filter('widget_text', 'do_shortcode'); // custom excerpt ellipses for 2.9+ if(!function_exists('custom_excerpt_more')) { function custom_excerpt_more($more) { return theme_locals("read_more").' »'; } add_filter('excerpt_more', 'custom_excerpt_more'); } // no more jumping for read more link if(!function_exists('no_more_jumping')) { function no_more_jumping($post) { return ' '.theme_locals("continue_reading").''; } add_filter('excerpt_more', 'no_more_jumping'); } // category id in body and post class if(!function_exists('category_id_class')) { function category_id_class($classes) { global $post; foreach((get_the_category()) as $category) $classes [] = 'cat-' . $category->cat_ID . '-id'; return $classes; } add_filter('post_class', 'category_id_class'); add_filter('body_class', 'category_id_class'); } // Threaded Comments if(!function_exists('enable_threaded_comments')) { function enable_threaded_comments() { if (!is_admin()) { if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) { wp_enqueue_script('comment-reply'); } } } add_action('get_header', 'enable_threaded_comments'); } //remove auto loading rel=next post link in header remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); // WP Pointers if (!function_exists('myHelpPointers')) { add_action('admin_enqueue_scripts', 'myHelpPointers'); function myHelpPointers() { //First we define our pointers $pointers = array( array( 'id' => 'xyz1', // unique id for this pointer 'screen' => 'themes', // this is the page hook we want our pointer to show on 'target' => '#toplevel_page_options-framework', // the css selector for the pointer to be tied to, best to use ID's 'title' => theme_locals("import_sample_data"), 'content' => theme_locals("import_sample_data_desc"), 'position' => array( 'edge' => 'left', //top, bottom, left, right 'align' => 'left', //top, bottom, left, right, middle ) ), array( 'id' => 'xyz2', // unique id for this pointer 'screen' => 'toplevel_page_options-framework', // this is the page hook we want our pointer to show on 'target' => '#toplevel_page_cherry-plugin-page', // the css selector for the pointer to be tied to, best to use ID's 'title' => theme_locals("import_sample_data"), 'content' => theme_locals("import_sample_data_desc"), 'position' => array( 'edge' => 'left', //top, bottom, left, right 'align' => 'left', //top, bottom, left, right, middle ) ) // more as needed ); //Now we instantiate the class and pass our pointer array to the constructor $myPointers = new WP_Help_Pointer($pointers); }; } /* * Navigation with description * */ if (! class_exists('description_walker')) { class description_walker extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); $class_names = ' class="'. esc_attr( $class_names ) . '"'; $output .= $indent . '