brasofilo

Dandelion MOD - functions.php

Nov 8th, 2011
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $themename = "Dandelion";
  3. $shortname = "dandelion";
  4.  
  5. $functions_path= TEMPLATEPATH . '/functions/';
  6. add_action('admin_menu', 'mytheme_add_admin');
  7.  
  8. if(is_admin()){
  9. require('update-notifier.php');
  10. }
  11.  
  12. /* ------------------------------------------------------------------------*
  13.  * DEFINE THE MAIN CONSTANTS THAT WILL BE USED WITHIN THE THEME
  14.  * ------------------------------------------------------------------------*/
  15.  
  16. define("PEXETO_FUNCTIONS_PATH", TEMPLATEPATH . '/functions/');
  17. define("PEXETO_FUNCTIONS_URL", get_template_directory_uri().'/functions/');
  18. define("PEXETO_TIMTHUMB_URL", PEXETO_FUNCTIONS_URL.'timthumb.php');
  19. define("PEXETO_OPTIONS_URL", get_template_directory_uri().'/functions/options/');
  20. define("PEXETO_OPTIONS_PATH", PEXETO_FUNCTIONS_PATH.'/options/');
  21. define("PEXETO_IMAGES_URL", PEXETO_OPTIONS_URL.'images/');
  22. define("PEXETO_CSS_URL", PEXETO_OPTIONS_URL.'css/');
  23. define("PEXETO_SCRIPT_URL", PEXETO_OPTIONS_URL.'script/');
  24. define("PEXETO_PATTERNS_URL", PEXETO_OPTIONS_URL.'images/pattern_samples/');
  25. define("PEXETO_SEPARATOR", '|*|');
  26.  
  27. define("PEXETO_SHORTNAME", $shortname);
  28.  
  29. $theme_data = get_theme_data(TEMPLATEPATH . '/style.css');
  30. define("PEXETO_VERSION", $theme_data['Version']);
  31.  
  32. $uploadsdir=wp_upload_dir();
  33. define("PEXETO_UPLOADS_URL", $uploadsdir['url']);
  34.  
  35.  
  36. define("OPTIONS_HEADING", 'This is the '.$themename.' options page where you can do most of the theme settings. Please note
  37. that there is a documentation included where all the theme customization settings are explained. The documentation
  38. is located within the <strong>documentation</strong> folder. <br/><br/>
  39. <strong>If you have any questions, please refer to the Support section of the documentation.</strong>');
  40.  
  41. /* ------------------------------------------------------------------------*
  42.  * INCLUDE THE FUNCTIONS FILES
  43.  * ------------------------------------------------------------------------*/
  44. require_once (PEXETO_FUNCTIONS_PATH.'general.php');  //some main common functions
  45. require_once (PEXETO_FUNCTIONS_PATH.'sidebars.php');  //the sidebar functionality
  46. require_once (PEXETO_OPTIONS_PATH.'options.php');  //the theme options functionality
  47. require_once (PEXETO_FUNCTIONS_PATH.'portfolio.php');  //portfolio functionality
  48. require_once (PEXETO_FUNCTIONS_PATH.'comments.php');  //the comments functionality
  49. require_once (PEXETO_FUNCTIONS_PATH.'meta.php');  //adds the custom meta fields to the posts and pages
  50. require_once (PEXETO_FUNCTIONS_PATH.'shortcodes.php');  //the shortcodes functionality
  51.  
  52.  
  53.  
  54.  
  55. add_action('admin_enqueue_scripts', 'pexeto_admin_init');
  56.  
  57. /**
  58.  * Enqueues the JavaScript files needed depending on the current section.
  59.  */
  60. function pexeto_admin_init(){
  61.     global $current_screen;
  62.    
  63.     //enqueue the script and CSS files for the TinyMCE editor formatting buttons
  64.     if($current_screen->base=='post'){
  65.         wp_enqueue_script('jquery');
  66.         wp_enqueue_script('jquery-ui-dialog');
  67.        
  68.         //set the style files
  69.         add_editor_style('functions/formatting-buttons/custom-editor-style.css');
  70.         wp_enqueue_style('pexeto-page-style',PEXETO_CSS_URL.'page_style.css');
  71.     }
  72.    
  73.     if(isset($_GET['page']) && $_GET['page']=='options'){
  74.         //enqueue the scripts for the Options page
  75.         wp_enqueue_script('jquery');
  76.         wp_enqueue_script('jquery-ui-core');
  77.         wp_enqueue_script('jquery-ui-sortable');
  78.         wp_enqueue_script('jquery-ui-dialog');
  79.         wp_enqueue_script('pexeto-jquery-co',PEXETO_SCRIPT_URL.'jquery-co.js');
  80.         wp_enqueue_script('pexeto-ajaxupload',PEXETO_SCRIPT_URL.'ajaxupload.js');
  81.         wp_enqueue_script('pexeto-colorpicker',PEXETO_SCRIPT_URL.'colorpicker.js');
  82.         wp_enqueue_script('pexeto-options',PEXETO_SCRIPT_URL.'options.js');
  83.  
  84.         //enqueue the styles for the Options page
  85.         wp_enqueue_style('pexeto-admin-style',PEXETO_CSS_URL.'admin_style.css');
  86.         wp_enqueue_style('pexeto-colorpicker-style',PEXETO_CSS_URL.'colorpicker.css');
  87.     }
  88.    
  89.     if($current_screen->id=='portfolio'){
  90.         //enqueue the scripts needed for the add/edit portfolio post
  91.         wp_enqueue_script('pexeto-ajaxupload',PEXETO_SCRIPT_URL.'ajaxupload.js');
  92.         wp_enqueue_script('pexeto-options',PEXETO_SCRIPT_URL.'options.js');
  93.     }
  94.  
  95.     if($current_screen->id=='page'){
  96.         //enqueue the scripts needed for the add/edit page page
  97.         wp_enqueue_script('pexeto-options',PEXETO_SCRIPT_URL.'page-options.js');
  98.     }
  99. }
  100.  
  101.  
  102. /**
  103.  * Load all the CSS and JavaScript files needed for the Pexeto Panel.
  104.  */
  105. function admin_head_add()
  106. {
  107.     if(isset($_GET['page']) && $_GET['page']=='options'){
  108.        
  109.         //init the options js functionality
  110.         echo '<script>jQuery(function(){
  111.                 pexetoOptions.init({cookie:true});
  112.                            
  113.             });</script>
  114.             <!--[if IE 9]>
  115.         <style type="text/css">
  116.         .tab_navigation ul li.ui-tabs-selected a.tab span, .tab_navigation ul li.ui-tabs-selected a.tab span{
  117.         top:-1px;
  118.         position:relative;
  119.         }
  120.        
  121.         .tab_navigation ul li.ui-tabs-selected a.tab{
  122.         position:relative;
  123.         top:1px;
  124.         }
  125.         </style>
  126.         <![endif]-->';
  127.     }
  128. }
  129.  
  130.  
  131.  
  132.  
  133.  
  134. /* MOD brasofilo */
  135. // REMOVE WP-CONTENT
  136. // Rewrites DO NOT happen for child themes
  137.  
  138. if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
  139.     function roots_htaccess_writable() {
  140.         if (!is_writable(get_home_path() . '.htaccess')) {
  141.             add_action('admin_notices', create_function('', "echo '<div class=\"error\"><p>" . sprintf(__('Please make sure your <a href="%s">.htaccess</a> file is writeable ', 'roots'), admin_url('options-permalink.php')) . "</p></div>';"));
  142.         };
  143.     }
  144.    
  145.     add_action('admin_init', 'roots_htaccess_writable');
  146.    
  147.    
  148.     function roots_flush_rewrites() {
  149.         global $wp_rewrite;
  150.         $wp_rewrite->flush_rules();
  151.     }
  152.    
  153.     function roots_add_rewrites($content) {
  154.         $theme_name = next(explode('/themes/', get_stylesheet_directory()));
  155.         global $wp_rewrite;
  156.         $roots_new_non_wp_rules = array(
  157.             'css/(.*)'      => 'wp-content/themes/'. $theme_name . '/css/$1',
  158.             'script/(.*)'       => 'wp-content/themes/'. $theme_name . '/script/$1',
  159.             'images/(.*)'      => 'wp-content/themes/'. $theme_name . '/images/$1',
  160.             'plugins/(.*)'  => 'wp-content/plugins/$1'
  161.         );
  162.         $wp_rewrite->non_wp_rules += $roots_new_non_wp_rules;
  163.     }
  164.    
  165.     add_action('admin_init', 'roots_flush_rewrites');
  166.    
  167.     function roots_clean_assets($content) {
  168.         $theme_name = next(explode('/themes/', $content));
  169.         $current_path = '/wp-content/themes/' . $theme_name;
  170.         $new_path = '';
  171.         $content = str_replace($current_path, $new_path, $content);
  172.         return $content;
  173.     }
  174.    
  175.     function roots_clean_plugins($content) {
  176.         $current_path = '/wp-content/plugins';
  177.         $new_path = '/plugins';
  178.         $content = str_replace($current_path, $new_path, $content);
  179.         return $content;
  180.     }
  181.    
  182.     // only use clean urls if the theme isn't a child or an MU (Network) install
  183.     if (!is_multisite() && !is_child_theme()) {
  184.         add_action('generate_rewrite_rules', 'roots_add_rewrites');
  185.         if (!is_admin()) {
  186.             //add_filter('plugins_url', 'roots_clean_plugins');
  187.             add_filter('bloginfo', 'roots_clean_assets');
  188.             add_filter('stylesheet_directory_uri', 'roots_clean_assets');
  189.             add_filter('template_directory_uri', 'roots_clean_assets');
  190.             //add_filter('script_loader_src', 'roots_clean_plugins');
  191.             //add_filter('style_loader_src', 'roots_clean_plugins');
  192.         }
  193.     }
  194.    
  195.     function roots_add_h5bp_htaccess($rules) {
  196.         global $wp_filesystem;
  197.    
  198.         if (!defined('FS_METHOD')) define('FS_METHOD', 'direct');
  199.         if (is_null($wp_filesystem)) WP_Filesystem(array(), ABSPATH);
  200.        
  201.         if (!defined('WP_CONTENT_DIR'))
  202.         define('WP_CONTENT_DIR', ABSPATH . 'wp-content');  
  203.    
  204.         $theme_name = next(explode('/themes/', get_template_directory()));
  205.         $filename = WP_CONTENT_DIR . '/themes/' . $theme_name . '/inc/h5bp-htaccess';
  206.    
  207.         $rules .= $wp_filesystem->get_contents($filename);
  208.        
  209.         return $rules;
  210.     }
  211.    
  212.     add_action('mod_rewrite_rules', 'roots_add_h5bp_htaccess');
  213. }
  214. add_action('roots_stylesheets', 'roots_get_stylesheets');
  215.  
  216. if (!is_admin()){
  217.   wp_deregister_script('l10n');
  218. }
  219.  
RAW Paste Data