ThemeShaper Forums » Thematic

Announcing a new Alpha version

(10 posts)
  • Started 5 years ago by Chris
  • Latest reply from Chris
  • This topic is not a support question
  1. Hi,

    first the advice before the announcement ..

    The new alpha version that I'm going to commit to the SVN repository in a couple of minutes isn't fully tested! Even though it's running on my live blog I can't guarantee that this new version won't bite you, your Child Theme, and / or crash your blog ;)

    Try it on a local machine first!

    IMPORTANT: All of you running the last SVN copy please delete the directory 'settings' including the file 'definitions.php' before you install the new version! .. if not .. this will definitely bring your blog down! .. don't worry .. in this case just delete the above mentioned directory including the file.

    .. and before I get the first language related complaints :)

    .. No .. I haven't updated the .pot file. The whole code is still experimental and certain things might change 'til the final release.

    What's new?

    1. You'll find a new button on the Thematic Options Page called 'Create Definitions'. Hit the button and it'll create a definitions file that keeps everything you can access with bloginfo() or get_bloginfo(). In addition I integrated the new function thm_bloginfo(). When functions.php starts the first time it'll check for the definitions.php and set a flag. thm_bloginfo() will check for the existance of this flag and return a constant instead of calling blog_info / get_bloginfo otherwise get_bloginfo() will be called. This will save some time on the server while creating the html code.

    2. A new functionality to create a widget area is integrated into Thematic. After starting to work on this I realized that Nathan Rice already integrated this into his Prodigy framework. I adapted his naming scheme and extended the functionality to the max.

    Let's have a look into the main function:

    thematic_create_widget_area($sidebar_name, $before_widget, $after_widget, $before_title, $after_title, $action_hook, $function, $priority)

    $sidebar_name - name of the Widget Area - Default: no default

    $before_widget - opening CSS markup before widget - Default: thematic_before_widget()

    function thematic_before_widget() {
    	$content = '<li id="%1$s" class="widgetcontainer %2$s">';
    	return apply_filters('thematic_before_widget', $content);
    }

    $after_widget - closing CSS markup after widget - Default: thematic_after_widget()

    function thematic_after_widget() {
    	$content = '</li>';
    	return apply_filters('thematic_after_widget', $content);
    }

    $before_title - opening CSS markup before widget title - Default: thematic_before_title()

    function thematic_before_title() {
    	$content = "<h3 class=\"widgettitle\">";
    	return apply_filters('thematic_before_title', $content);
    }

    $after_title - closing CSS markup after widget title - Default: thematic_after_title()

    function thematic_after_title() {
    	$content = "</h3>\n";
    	return apply_filters('thematic_after_title', $content);
    }

    $action_hook - the action hook where the widget area should be placed - Default: no default, needs to be an existing action_hook

    $function - the function connected to the hook - Default: thematic_standard_widget_area(), this one can be used as long as you create only one widget area per action hook.

    $priority - the priority for the above mentioned function - Default: 10

    The standard widget areas are using the action hooks names 'widget_area_name' => 'widget_area_primary_aside'.

    To keep the thematic_standard_widget_area() as small as possible I'm working with current_filter() to get the name of the action hook. The trailing 'widget_area_' will be stripped and '_' replaced with '-'. This will result in the ID of the widget area for the standard widget areas ;)

    Because this won't work for all the other standard hooks we need to use a filter to do some magic.

    Imagine you want to create a widget area in the header called 'Header Aside' ..

    function my_widget_areas() {
    	thematic_create_widget_area('Header Aside', thematic_before_widget(), thematic_after_widget(), thematic_before_title(), thematic_after_title(), 'thematic_header','thematic_standard_widget_area', 8);
    }
    add_action('init', 'my_widget_areas');

    The ID of the widget area will be created with the name 'Header Aside' .. lower case .. replace blanks with '-' => 'header-aside'. Unfortunately the above mentioned translation for the name of the action hook won't work .. it will get 'thematic_header' and translate it into 'thematic-header' .. so here's the magic code to make this thing work:

    function my_hook($hook) {
    	if ($hook == 'thematic-header') {
    		return 'header-aside';
    	}
    	return $hook;
    }
    add_filter('thematic_process_hook', 'my_hook');

    Take a look at the complete example listed here: Back from vacation with a teaser

    That's it for today .. and please provide some feedback.

    TBD:
    - make the first thing work under WPMU
    - integrate the code to remove the standard widget areas

    Thanks!

    Chris

    Posted 5 years ago #
  2. SVN revision 551 is available.

    Chris

    Posted 5 years ago #
  3. amygail
    Member

    This is what you do on a 'vacation'? ;-)

    Can't wait to give it a spin.

    Welcome back!

    Posted 5 years ago #
  4. I've been doing some hacking around on this for the WPMU thing. I've discovered that, at least at home on a test server, if you use $blog_id in the file name then you can make this work by creating a different file for each blog.

    What I changed:

    functions.php
    Lines:31-37:
    Original:

    // Check if settings.php is available and load it
    if (file_exists(STYLESHEETPATH . '/settings/definitions.php')) {
    	define('THEMATIC_SETTINGS', TRUE);
    	require_once(STYLESHEETPATH . '/settings/definitions.php');
    } else {
    	define('THEMATIC_SETTINGS', FALSE);
    }

    Changed:

    // Check if settings.php is available and load it
    if (file_exists(STYLESHEETPATH . "/settings/blog-{$blog_id}-definitions.php")) {
    	define('THEMATIC_SETTINGS', TRUE);
    	require_once(STYLESHEETPATH . "/settings/blog-{$blog_id}-definitions.php");
    } else {
    	define('THEMATIC_SETTINGS', FALSE);
    }

    /library/extensions/theme-options.php
    Line 37
    Original:

    global $themename, $shortname, $options;

    Changed:

    global $themename, $shortname, $options, $blog_id;

    Line 73:
    Original:

    $filename = STYLESHEETPATH . '/settings/definitions.php';

    Changed:

    $filename = STYLESHEETPATH . "/settings/blog-{$blog_id}-definitions.php";

    What I end up with on WPMU are files named "blog-1-settings.php", blog-2-settings.php", etc... and on WordPress I get a file named "blog-1-settings.php" which might be a little weird but it works.

    Anyway, I hope this was helpful :^)

    Posted 5 years ago #
  5. Thanks a lot for your help! .. will look into this in the next days and commit an updated version to the repository.

    Chris

    Posted 5 years ago #
  6. Hi Amy,

    .. yep .. that's what I did during my vacation :) .. don't trust me, I spent about 90% of my time with my family. The little pirate a.k.a. the son kept his ol' dad busy the whole day :)

    .. and .. thanks a lot for all your help !!!

    Chris

    Posted 5 years ago #
  7. amygail
    Member

    We're glad you're back!

    Posted 5 years ago #
  8. Once again sitting in the middle of nowhere :)

    Thinking 'bout the widgetized areas .. and working on it. Don't know, if the latest changes will make it into a release. It's not flexible enough.

    Chris

    Posted 5 years ago #
  9. Widget area madness... I feel your pain. Look back at this tangent I went on a couple weeks back maybe it'll be a source of inspiration and/or laughter how-to-remove-or-filter-widget-areas-in-admin at the end of the thread I actually came up with a working solution that's maybe too flexible but working all the same.

    Posted 5 years ago #
  10. :)

    .. let's call it challenging. I had your idea always in my head.

    Think I found a method that looks pretty good. The standard sidebar names can be filtered, new sidebars can be added, and so on .. should be easier and more flexible than my last version.

    Chris

    Posted 5 years ago #

RSS feed for this topic

Reply

You must log in to post.