/** * Apply the data to configure the theme */ public function run() { $data = $this->getData(); $defaultProperties = $data['defaults']; $areas = $data['areas']; foreach ($areas as $slug => $desc) { // Handle quick declaration style if (!is_array($desc)) { // $desc is actually the title, build an array $desc = array('name' => $desc); } // Set name and description if not specified if (!isset($desc['name'])) { $desc['name'] = Strings::labelizeSlug($slug); } if (!isset($desc['description'])) { $desc['description'] = ''; } // Set the slug $desc['id'] = $slug; // Merge with our default and register $areaProperties = array_merge($defaultProperties, $desc); // Internationalize what has to be internationalized $areaProperties['name'] = Strings::translate($areaProperties['name']); $areaProperties['description'] = Strings::translate($areaProperties['description']); register_sidebar($areaProperties); } }
/** * Apply the data to configure the theme */ public function run() { $locations = array(); $data = $this->getData(); foreach ($data as $slug => $desc) { $locations[$slug] = Strings::translate($desc); } register_nav_menus($locations); }
/** * Add image sizes to the media size dropdown list. * * @param array $sizes The existing sizes. * * @return array */ public function addSizesToDropDownList($sizes) { $new = array(); $data = $this->getData(); foreach ($data as $slug => $props) { // If no 4th option, stop the loop. if (!isset($props['media']) || false == $props['media']) { continue; } $new[$slug] = isset($props['mediaLabel']) ? $props['mediaLabel'] : Strings::labelizeSlug($slug); // Internationalize what has to be $new[$slug] = Strings::translate($new[$slug]); } return array_merge($sizes, $new); }
/** * Helper function to translate an array value if it is effectively defined * @param array $array the container * @param mixed $key the array key * @return null|string the translated value */ private function translateValueIfKeyExists(&$array, $key) { if (isset($array[$key])) { return Strings::translate($array[$key]); } return null; }