Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/05/2016 04:26:30 AM (9 years ago)
Author:
boonebgorges
Message:

Move bp-core classes to their own files.

See #6870.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-theme-compatibility.php

    r10497 r10518  
    2525/** Base Class ****************************************************************/
    2626
    27 /**
    28  * Theme Compatibility base class.
    29  *
    30  * This is only intended to be extended, and is included here as a basic guide
    31  * for future Theme Packs to use. {@link BP_Legacy} is a good example of
    32  * extending this class.
    33  *
    34  * @since 1.7.0
    35  *
    36  * @todo We should probably do something similar to BP_Component::start().
    37  * @todo If this is only intended to be extended, it should be abstract.
    38  *
    39  * @param array $properties {
    40  *     An array of properties describing the theme compat package.
    41  *     @type string $id      ID of the package. Must be unique.
    42  *     @type string $name    Name of the theme. This should match the name given
    43  *                           in style.css.
    44  *     @type string $version Theme version. Used for busting script and style
    45  *                           browser caches.
    46  *     @type string $dir     Filesystem path of the theme.
    47  *     @type string $url     Base URL of the theme.
    48  * }
    49  */
    50 class BP_Theme_Compat {
    51 
    52     /**
    53      * Template package properties, as passed to the constructor.
    54      *
    55      * @since 1.7.0
    56      * @var array
    57      */
    58     protected $_data = array();
    59 
    60     /**
    61      * Pass the $properties to the object on creation.
    62      *
    63      * @since 1.7.0
    64      *
    65      * @param array $properties Array of properties for BP_Theme_Compat.
    66      */
    67         public function __construct( Array $properties = array() ) {
    68         $this->_data = $properties;
    69     }
    70 
    71     /**
    72      * Set up the BuddyPress-specific theme compat methods.
    73      *
    74      * Themes should use this method in their constructor.
    75      *
    76      * @since 1.7.0
    77      */
    78     protected function start() {
    79         // Sanity check.
    80         if ( ! bp_use_theme_compat_with_current_theme() ) {
    81             return;
    82         }
    83 
    84         // Setup methods.
    85         $this->setup_globals();
    86         $this->setup_actions();
    87     }
    88 
    89     /**
    90      * Set up global data for your template package.
    91      *
    92      * Meant to be overridden in your class. See
    93      * {@link BP_Legacy::setup_globals()} for an example.
    94      *
    95      * @since 1.7.0
    96      */
    97     protected function setup_globals() {}
    98 
    99     /**
    100      * Set up theme hooks for your template package.
    101      *
    102      * Meant to be overridden in your class. See
    103      * {@link BP_Legacy::setup_actions()} for an example.
    104      *
    105      * @since 1.7.0
    106      */
    107     protected function setup_actions() {}
    108 
    109     /**
    110      * Set a theme's property.
    111      *
    112      * @since 1.7.0
    113      *
    114      * @param string $property Property name.
    115      * @param mixed  $value    Property value.
    116      * @return bool True on success, false on failure.
    117      */
    118     public function __set( $property, $value ) {
    119         return $this->_data[$property] = $value;
    120     }
    121 
    122     /**
    123      * Get a theme's property.
    124      *
    125      * @since 1.7.0
    126      *
    127      * @param string $property Property name.
    128      * @return mixed The value of the property if it exists, otherwise an
    129      *               empty string.
    130      */
    131     public function __get( $property ) {
    132         return array_key_exists( $property, $this->_data ) ? $this->_data[$property] : '';
    133     }
    134 }
     27require dirname( __FILE__ ) . '/classes/class-bp-core-theme-compat.php';
    13528
    13629/** Functions *****************************************************************/
Note: See TracChangeset for help on using the changeset viewer.