Skip to content

Instantly share code, notes, and snippets.

@scribu
Last active January 7, 2024 11:59

Revisions

  1. scribu revised this gist Aug 17, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion wrapping.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    <?php
    # License: Public Domain.

    # License: Public Domain

    # I recommend replacing 'my_' with your own prefix.

  2. scribu revised this gist Aug 17, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion wrapping.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    <?php
    # This code is in the Public Domain.
    # License: Public Domain.

    # I recommend replacing 'my_' with your own prefix.

    function my_template_path() {
  3. Cristi Burcă revised this gist Sep 4, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions wrapping.php
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,11 @@
    # I recommend replacing 'my_' with your own prefix.

    function my_template_path() {
    return APP_Wrapping::$main_template;
    return My_Wrapping::$main_template;
    }

    function my_template_base() {
    return APP_Wrapping::$base;
    return My_Wrapping::$base;
    }


  4. Cristi Burcă revised this gist Sep 4, 2012. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions wrapping.php
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,17 @@
    <?php
    # This code is in the Public Domain.
    # I recommend replacing 'my_' with your own prefix.

    function app_template_path() {
    function my_template_path() {
    return APP_Wrapping::$main_template;
    }

    function app_template_base() {
    function my_template_base() {
    return APP_Wrapping::$base;
    }


    class APP_Wrapping {
    class My_Wrapping {

    /**
    * Stores the full path to the main template file
    @@ -38,4 +40,4 @@ static function wrap( $template ) {
    }
    }

    add_filter( 'template_include', array( 'APP_Wrapping', 'wrap' ), 99 );
    add_filter( 'template_include', array( 'My_Wrapping', 'wrap' ), 99 );
  5. Cristi Burcă revised this gist Nov 5, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wrapping.php
    Original file line number Diff line number Diff line change
    @@ -38,4 +38,4 @@ static function wrap( $template ) {
    }
    }

    add_filter( 'template_include', array( 'APP_Wrapping', 'wrap' ) );
    add_filter( 'template_include', array( 'APP_Wrapping', 'wrap' ), 99 );
  6. scribu renamed this gist Sep 11, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. scribu revised this gist Sep 11, 2011. 1 changed file with 4 additions and 12 deletions.
    16 changes: 4 additions & 12 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    <?php

    function app_template_path() {
    return APP_Wrapping::get_main_template();
    return APP_Wrapping::$main_template;
    }

    function app_template_base() {
    return APP_Wrapping::get_base();
    return APP_Wrapping::$base;
    }


    @@ -14,12 +14,12 @@ class APP_Wrapping {
    /**
    * Stores the full path to the main template file
    */
    private static $main_template;
    static $main_template;

    /**
    * Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
    */
    private static $base;
    static $base;

    static function wrap( $template ) {
    self::$main_template = $template;
    @@ -36,14 +36,6 @@ class APP_Wrapping {

    return locate_template( $templates );
    }

    static function get_main_template() {
    return self::$main_template;
    }

    static function get_base() {
    return self::$base;
    }
    }

    add_filter( 'template_include', array( 'APP_Wrapping', 'wrap' ) );
  8. scribu revised this gist Sep 11, 2011. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,14 @@ function app_template_base() {

    class APP_Wrapping {

    /**
    * Stores the full path to the main template file
    */
    private static $main_template;

    /**
    * Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
    */
    private static $base;

    static function wrap( $template ) {
  9. scribu renamed this gist Sep 11, 2011. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  10. scribu created this gist Sep 11, 2011.
    42 changes: 42 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    <?php

    function app_template_path() {
    return APP_Wrapping::get_main_template();
    }

    function app_template_base() {
    return APP_Wrapping::get_base();
    }


    class APP_Wrapping {

    private static $main_template;
    private static $base;

    static function wrap( $template ) {
    self::$main_template = $template;

    self::$base = substr( basename( self::$main_template ), 0, -4 );

    if ( 'index' == self::$base )
    self::$base = false;

    $templates = array( 'wrapper.php' );

    if ( self::$base )
    array_unshift( $templates, sprintf( 'wrapper-%s.php', self::$base ) );

    return locate_template( $templates );
    }

    static function get_main_template() {
    return self::$main_template;
    }

    static function get_base() {
    return self::$base;
    }
    }

    add_filter( 'template_include', array( 'APP_Wrapping', 'wrap' ) );