Private Themes

From The Lyceum Wiki

Jump to: navigation, search

For those who wants private themes these are the instructions to do it.

I've changed the following files:

  • lib/wp-includes/functions.php
   1. Around line 1748  ( function get_theme_data() ) add the 
      following lines:
      if ( preg_match("|Blog Owner:(.*)|i", $theme_data, $bOwner) )
         $blog_owner = trim( $bOwner[1] );
      else
         $blog_owner = "all";
  
   2. Next in the return array of the function get_theme_data add a 
      key like this 'Blog Owner' => $blog_owner.
  
   3. Go to  get_themes() function right after get_theme_data()
      function, look for the following lines:
       $theme_data = get_theme_data("$theme_root/$theme_file");
       $name = $theme_data['Name'];
       $title = $theme_data['Title'];
       $description = wptexturize($theme_data['Description']);
       $version = $theme_data['Version'];
       $author = $theme_data['Author'];
       $template = $theme_data['Template'];
     
      and add this line:
      $blog_owner = $theme_data['Blog Owner'];
      in the same get_themes() function look for this line:
   $themes[$name] = array('Name' => $name, 'Title' => $title,
   'Description' => $description, 'Author' => $author, 
   'Version' => $version, 'Template' => $template, 
   'Stylesheet' => $stylesheet, 'Template Files' => $template_files,
   'Stylesheet Files' => $stylesheet_files, 'Template Dir' =>
   $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' =>
   $theme_data['Status'], 'Screenshot' => $screenshot);
   and add the following key to the array: 
   'Blog Owner' => $blog_owner
  • lyceum/wp-admin/themes.php
   Around line 76 add this line of code:
   $owner = $themes[$theme_name]['Blog Owner'];
  
   two lines after that add this one:
   
   $currentSlug = $wpdb->get_var("SELECT slug FROM $wpdb->blogs 
   WHERE id = '$blogdata->id'");
   right after that add this line:
   if ( ( $owner == $currentSlug ) || ( $owner == "all" ) ){
   then look for this line:
   <?php } // end foreach theme_names ?> 
   and add a } like this:
   
   <?php }} // end foreach theme_names ?>

That's it for the files that can get it all done, now we need to add an owner to the theme

  • lyceum/wp-content/<your-theme>/style.css
   To add an owner to the theme just add a line to the header in the
   style.css of your theme that you want to be private, a line that
   should look like this:
   Blog Owner: slugname
   where slugname is the slug of the blog that owns the theme.  
   PD: if you want your themes to be public just don't add the Blog
   Owner line in style.css, remember is in the header of this file that 
   begin with /* and end with */.

That's it!, this is for those who wants the theme can be only show for one user and not for all of them, i will try to make it for a lager number of users.


For more info contact me:

Tirso Peralta

From Barquisimeto, Venezuela

e-mail: tirso_peralta@yahoo.com, tirso.peralta@gmail.com

msn: tirsope@hotmail.com


Let me know what you think.

"Feel free to share"

Personal tools