sarahn

http://wpml.org/forums/topic/custom-language-switcher-8/

Apr 18th, 2013
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*-----------------------------------------------------------------------------------*/
  3. /* Start WooThemes Functions - Please refrain from editing this section */
  4. /*-----------------------------------------------------------------------------------*/
  5.  
  6. // Set path to WooFramework and theme specific functions
  7. $functions_path = TEMPLATEPATH . '/functions/';
  8. $includes_path = TEMPLATEPATH . '/includes/';
  9.  
  10. // Don't load alt stylesheet from WooFramework
  11. if (!function_exists( 'woo_output_alt_stylesheet')) {
  12. function woo_output_alt_stylesheet() {}
  13. }
  14.  
  15. // Define the theme-specific key to be sent to PressTrends.
  16. define( 'WOO_PRESSTRENDS_THEMEKEY', 'tnla49pj66y028vef95h2oqhkir0tf3jr' );
  17.  
  18. // WooFramework
  19. require_once ( $functions_path . 'admin-init.php' ); // Framework Init
  20.  
  21. if ( get_option( 'woo_woo_tumblog_switch' ) == 'true' ) {
  22. //Enable Tumblog Functionality and theme is upgraded
  23. update_option( 'woo_needs_tumblog_upgrade', 'false' );
  24. update_option( 'tumblog_woo_tumblog_upgraded', 'true' );
  25. update_option( 'tumblog_woo_tumblog_upgraded_posts_done', 'true' );
  26. require_once ( $functions_path . 'admin-tumblog-quickpress.php' ); // Tumblog Dashboard Functionality
  27. }
  28.  
  29. /*-----------------------------------------------------------------------------------*/
  30. /* Load the theme-specific files, with support for overriding via a child theme.
  31. /*-----------------------------------------------------------------------------------*/
  32.  
  33. $includes = array(
  34. 'includes/theme-options.php', // Options panel settings and custom settings
  35. 'includes/theme-functions.php', // Custom theme functions
  36. 'includes/theme-actions.php', // Theme actions & user defined hooks
  37. 'includes/theme-comments.php', // Custom comments/pingback loop
  38. 'includes/theme-js.php', // Load JavaScript via wp_enqueue_script
  39. 'includes/sidebar-init.php', // Initialize widgetized areas
  40. 'includes/theme-widgets.php' // Theme widgets
  41. );
  42.  
  43. // Theme-Specific
  44. $includes[] = 'includes/theme-advanced.php'; // Advanced Theme Functions
  45. $includes[] = 'includes/theme-shortcodes.php'; // Custom theme shortcodes
  46. // Modules
  47. $includes[] = 'includes/woo-layout/woo-layout.php';
  48. $includes[] = 'includes/woo-meta/woo-meta.php';
  49. $includes[] = 'includes/woo-hooks/woo-hooks.php';
  50.  
  51. // Allow child themes/plugins to add widgets to be loaded.
  52. $includes = apply_filters( 'woo_includes', $includes );
  53.  
  54. foreach ( $includes as $i ) {
  55. locate_template( $i, true );
  56. }
  57.  
  58. // Load WooCommerce functions, if applicable.
  59. if ( is_woocommerce_activated() ) {
  60. locate_template( 'includes/theme-woocommerce.php', true );
  61. }
  62.  
  63. if ( get_option( 'woo_woo_tumblog_switch' ) == 'true' ) {
  64.  
  65. define( 'WOOTUMBLOG_ACTIVE', true ); // Define a constant for use in our theme's templating engine.
  66.  
  67. require_once ( $includes_path . 'tumblog/theme-tumblog.php' ); // Tumblog Output Functions
  68. // Test for Post Formats
  69. if ( get_option( 'woo_tumblog_content_method' ) == 'post_format' ) {
  70. // Tumblog Post Format Class
  71. require_once( $includes_path . 'tumblog/wootumblog_postformat.class.php' );
  72. } else {
  73. // Tumblog Custom Taxonomy Class
  74. require_once ($includes_path . 'tumblog/theme-custom-post-types.php' ); // Custom Post Types and Taxonomies
  75. }
  76.  
  77. // Test for Post Formats
  78. if ( get_option( 'woo_tumblog_content_method' ) == 'post_format' ) {
  79. //Tumblog Post Formats
  80. global $woo_tumblog_post_format;
  81. $woo_tumblog_post_format = new WooTumblogPostFormat();
  82. if ( $woo_tumblog_post_format->woo_tumblog_upgrade_existing_taxonomy_posts_to_post_formats()) {
  83. update_option( 'woo_tumblog_post_formats_upgraded', 'true' );
  84. }
  85.  
  86. }
  87. }
  88.  
  89. // Output stylesheet and custom.css after Canvas custom styling
  90. remove_action( 'wp_head', 'woothemes_wp_head' );
  91. add_action( 'woo_head', 'woothemes_wp_head' );
  92. if ( get_option( 'woo_woo_tumblog_switch' ) == 'true' && get_option( 'woo_custom_rss' ) == 'true' ) {
  93. add_filter( 'the_excerpt_rss', 'woo_custom_tumblog_rss_output' );
  94. add_filter( 'the_content_rss', 'woo_custom_tumblog_rss_output' );
  95. }
  96.  
  97. /*-----------------------------------------------------------------------------------*/
  98. /* You can add custom functions below */
  99. /*-----------------------------------------------------------------------------------*/
  100.  
  101. // Filter wp_nav_menu() to add additional links and other output
  102. add_filter('wp_nav_menu_items', 'new_nav_menu_items', 10);
  103. function new_nav_menu_items($items){
  104. if (function_exists('icl_get_languages')){
  105. $languages = icl_get_languages('skip_missing=0');
  106. if(!empty($languages)){
  107. foreach($languages as $l){
  108. // flag with translated name
  109. $items = $items . '<li class="menu-item"><a href="' . $l['url'] . '"><img src="' . $l['country_flag_url'] . '" height="12" alt="' . $l['language_code'] . '" width="18" /> ' . $l['translated_name'] . '</a></li>';
  110. }
  111. }
  112. }
  113. return $items;
  114. }
  115.  
  116.  
  117. /*-----------------------------------------------------------------------------------*/
  118. /* Don't add any code below here or the sky will fall down */
  119. /*-----------------------------------------------------------------------------------*/
  120. ?>
Add Comment
Please, Sign In to add comment