Content of functions.php from minimalissimplistic.zip

without / with line numbers
  1. <?php
  2. /*
  3. File Name: Wordpress Theme Toolkit Implementation for Theme Minimalissimplistic
  4. Version: 1.0
  5. Author: Ozh
  6. Author URI: http://planetOzh.com/
  7. */

  8. /************************************************************************************
  9.  * THEME USERS : don't touch anything !! Or don't ask the theme author for support :)
  10.  ************************************************************************************/

  11. include(dirname(__FILE__).'/themetoolkit.php');

  12. /************************************************************************************
  13.  * THEME AUTHOR : edit the following function call :
  14.  ************************************************************************************/

  15. themetoolkit(
  16.     'mytheme', /* Make yourself at home :
  17.                     * Name of the variable that will contain all the options of
  18.                     * your theme admin menu (in the form of an array)
  19.                     * Name it according to PHP naming rules (http://php.net/variables) */

  20.     array(     /* Variables used by your theme features (i.e. things the end user will
  21.                     * want to customize through the admin menu)
  22.                      * Syntax :
  23.                     * 'option_variable' => 'Option Title ## optionnal explanations',
  24.                     * 'option_variable' => 'Option Title {radio|value1|Text1|value2|Text2} ## optionnal explanations',
  25.                     * 'option_variable' => 'Option Title {textarea|rows|cols} ## optionnal explanations',
  26.                     * 'option_variable' => 'Option Title {checkbox|option_var1|value1|Text1|option_var2|value2|Text2} ## optionnal explanations',
  27.                     * Examples :
  28.                     * 'your_age' => 'Your Age',
  29.                     * 'cc_number' => 'Credit Card Number ## I can swear I will not misuse it :P',
  30.                     * 'gender' => 'Gender {radio|girl|You are a female|boy|You are a male} ## What is your gender ?'
  31.                     * Dont forget the comma at the end of each line ! */
  32.     'width' => 'Overall Width ## Set layout width. Can be pixels, em or percent ("700px", "80%", "56em"). Using em\'s will make the design <em>elastic</em> (too small values can break layout in IE)',
  33.     'floatbar' => 'Sidebar Menu on the {radio|left|Left Hand|right|Right Hand}',
  34.     'textcolor' => 'Text color ## Enter an HTML color ("red", "#abc", "#a1b2c3", etc...)',
  35.     'bgcolor' => 'Page background color',
  36.     'wrapcolor' => 'Layout background color',
  37.     'asides' => 'Asides ## Name of the category for posts that are displayed as "<a href="http://codex.wordpress.org/Adding_Asides">Asides</a>" <br>(Leave empty to display all posts normally)',
  38.     'says' => 'Comment Replies {textarea|6|50} ## New line separated list of synomyms of the word "says", to display readers\' comments (the "<em>nick says</em>" part)',
  39.     'debug' => 'debug',     /* this is a fake entry that will activate the "Programmer's Corner"
  40.                                  * showing you vars and values while you build your theme. Remove it
  41.                                  * when your theme is ready for shipping */
  42.     ),
  43.     __FILE__     /* Parent. DO NOT MODIFY THIS LINE !
  44.                   * This is used to check which file (and thus theme) is calling
  45.                   * the function (useful when another theme with a Theme Toolkit
  46.                   * was installed before */
  47. );
  48.     
  49. /************************************************************************************
  50.  * THEME AUTHOR : Congratulations ! The hard work is all done now :)
  51.  *
  52.  * From now on, you can create functions for your theme that will use the array
  53.  * of variables $mytheme->option. For example there will be now a variable
  54.  * $mytheme->option['your_age'] with value as set by theme end-user in the admin menu.
  55.  ************************************************************************************/

  56. /***************************************
  57.  * Additionnal Features and Functions for
  58.  * Theme 'minimalissimplistic'
  59.  *
  60.  * Create your own functions using the array
  61.  * of user defined variables $mytheme->option.
  62.  * An example of function could be :
  63.  *
  64.  * function creditcard() {
  65.  *        global $mytheme;
  66.  *        print "My Credit Card Number is : ";
  67.  *     print $mytheme->option['creditcard'];
  68.  * }
  69.  *
  70.  **************************************/

  71. /* mytheme_about
  72.     use <?php mytheme_about() ?> to print either what the author
  73.     wrote in his profile (Admin Area, Users page), or a friendly
  74.     message if nothing has been filled in.
  75. */
  76. function mytheme_about() {
  77.     if (get_the_author_description()) {
  78.         print get_the_author_description();
  79.     } else {
  80.         print "The author does not say much about himself";
  81.     }
  82. }


  83. /* mytheme_is_asides
  84.     If an Aside category has been specified, returns TRUE
  85.     when a post belongs to this category, FALSE otherwise
  86.     Usage :
  87.     <?php if (mytheme_is_asides()) { ?>
  88.          html & php if aside
  89.     <?php } else { ?>
  90.          html & php if not aside
  91.     <?php ?>
  92. */
  93. function mytheme_is_asides() {
  94.         global $mytheme;
  95.         $categories = array ();
  96.         /* get all categories for the post we are processing */
  97.         foreach((get_the_category()) as $cat) {
  98.             $categories[] = $cat->cat_name;
  99.         }
  100.         /* is one of these categories the same as our Asides cat ? */
  101.         if (in_array($mytheme->option['asides'],$categories)) {
  102.                 return true;
  103.         } else {
  104.                 return false;
  105.         }
  106. }


  107. /* mytheme_sidebar()
  108.     Prints css style according to what has been defined
  109.     in the admin pannel
  110. */
  111. function mytheme_sidebar() {
  112.     global $mytheme;
  113.     if ($mytheme->option['floatbar'] == 'right') {
  114.         echo '
  115.         /* Menu on the Right */
  116.         #content {float: left;}
  117.         #menu {float: right;}
  118.         ';
  119.     } else {
  120.         echo '
  121.         /* Menu of the Left */
  122.         #content {float: right;}
  123.         #menu {float: left;}
  124.         ';
  125.     }    
  126. }


  127. /* mytheme_width()
  128.     Prints css style according to what has been defined
  129.     in the admin pannel
  130. */
  131. function mytheme_width() {
  132.     global $mytheme;
  133.     if ( $mytheme->option['width'] ) print '#wrap{width:' .$mytheme->option['width']." ;}\n";
  134. }


  135. /* mytheme_colors()
  136.     Prints css style according to what has been defined
  137.     in the admin pannel
  138. */
  139. function mytheme_colors() {
  140.     global $mytheme;
  141.     if ( $mytheme->option['textcolor'] or $mytheme->option['bgcolor'] ) print "body {\n";
  142.         if ($mytheme->option['textcolor']) print 'color: '. $mytheme->option['textcolor'] . ";\n";
  143.         if ($mytheme->option['bgcolor']) print 'background: '. $mytheme->option['bgcolor'] .";\n";
  144.     if ($mytheme->option['textcolor'] or $mytheme->option['bgcolor']) print "}\n";
  145.     if ($mytheme->option['textcolor']) print 'a{color: '. $mytheme->option['textcolor'] . ";}\n";
  146.     if ($mytheme->option['wrapcolor']) print '#wrap{background: '. $mytheme->option['wrapcolor'] . ";}\n";
  147. }


  148. /* mytheme_says()
  149.     Print a random element of the list defined in the admin pannel
  150.     Use it to replace "Someone says" with "Someone thought", "Someone
  151.     wrote", "Someone declared that", etc...
  152. */
  153. function mytheme_says() {
  154.     global $mytheme;
  155.     if (!$mytheme->option['says']) {
  156.         print "Says";
  157.     } else {
  158.         srand((float) microtime()*1000000);
  159.         $replies = split("\n",$mytheme->option['says']);
  160.         print (trim($replies[rand(1,count($replies)-1)],"\r\n"));
  161.     }
  162. }

  163. ?>
  164.  

Return to listing of minimalissimplistic.zip