/** * Register Nav Menus. * * @see http://codex.wordpress.org/Navigation_Menus */ public static function registerNavMenus() { add_action('init', function () { foreach (Menu::getMenusActive() as $menu) { $menus[$menu] = I18n::transu($menu); } register_nav_menus($menus); }); }
/** * (non-PHPdoc) * * @see \Widgets\WidgetBase::widget() */ public function widget($args, $instance) { /* * Put all languages available to show into the instance var. */ $instance['languages'] = I18n::getAllLangAvailableKeyValue(); /* * And call the widget func from the parent class WidgetBase. */ parent::widget($args, $instance); }
/** * * @param string $user_ID */ public function getRenderLanguage($user_ID = false) { if (!$user_ID) { global $user_ID; } $user = User::find($user_ID); // Format the list $userLang = $user->getLang(); foreach (I18n::getAllLangAvailable() as $t) { $languages[] = ['value' => $t, 'text' => I18n::transu('lang_' . $t), 'selected' => $userLang == $t]; } $args = ['user' => $user, 'KEY_LANGUAGE' => User::KEY_LANGUAGE, 'languages' => $languages]; return $this->render('backend/user/_lang', $args); }
/** * tag.php */ public function getTag() { $tag = get_queried_object(); $args = ['postsWhereKey' => Ajax::TAG, 'postsWhereValue' => $tag->term_id, 'thingType' => I18n::transu('tag'), 'thingToSearch' => $tag->name, 'posts' => Post::getByTag($tag->term_id)]; return $this->renderPage('base/search', $args); }
<?php /* * This file is part of the Knob-mvc package. * * (c) José María Valera Reales <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Knob\I18n\I18n; /** * ============================ * Your Mustache params * ============================ * * @see knob-base/src/config/mustache_params.php -> Parent file * */ return ['ajaxUrl' => '/ajax', 'blogAuthor' => 'José María Valera Reales', 'blogDescription' => ($d = I18n::trans('internal.blog_description')) ? $d : get_bloginfo('description'), 'blogKeywords' => 'knob, wordpress, framework, mvc, template, mustache, php'];
/** * Return the form for comments * * @return string */ public function getFormComments() { ob_start(); $placeTextarea = I18n::transu('post.share_comment'); $params = ['comment_notes_after' => '', 'author' => '<p class="comment-form-author">' . '<label for="author">' . __('Your Name') . '</label> <input id="author" name="author" type="text" value="Your First and Last Name" size="30" /></p>', 'comment_field' => ' <div class="form-group comment-form-comment"> <label for="comment">' . _x('Comment', 'noun') . '</label> <textarea class="form-control" id="comment" name="comment" cols="45" rows="2" maxlength="1000" aria-required="true" placeholder="' . $placeTextarea . '"></textarea> </div>']; $placeAuthor = I18n::transu('name'); $placeEmail = I18n::transu('email'); $placeUrl = I18n::transu('website'); comment_form($params, $this->ID); $comment_form = ob_get_clean(); $comment_form = str_replace('id="author"', 'class="author form-control" placeholder="' . $placeAuthor . '"', $comment_form); $comment_form = str_replace('id="email"', 'class="email form-control" placeholder="' . $placeEmail . '"', $comment_form); $comment_form = str_replace('id="url"', 'class="url form-control" placeholder="' . $placeUrl . '"', $comment_form); $comment_form = str_replace('id="submit"', 'class="btn btn-default"', $comment_form); return $comment_form; }
/** * * @return array */ public static function getAllLangAvailableKeyValue() { $languages = []; foreach (I18n::getAllLangAvailable() as $l) { $languages[] = ['key' => $l, 'value' => I18n::getLangFullnameBrowser($l)]; } /* * Sort by key */ usort($languages, function ($a, $b) { return strcasecmp($a['key'], $b['key']); }); return $languages; }
/** * Response the menu * * @param array $_datas * @return array JSON */ private function jsonMenu($_datas) { $type = $_datas['type']; $args = ['archives' => Archive::getMonthly(), 'categories' => Term::getCategories(), 'languages' => I18n::getAllLangAvailableKeyValue(), 'pages' => Post::getPages(), 'tags' => Term::getTags()]; $type = str_replace('-', '_', $type); $content = $this->render('menu/' . $type . '_default', $args); $json['content'] = $content; $json['code'] = KeysRequest::OK; return $json; }
<?php /* * This file is part of the Knob-mvc package. * * (c) José María Valera Reales <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Knob\I18n\I18n; /** * ============================ * Your Mustache params * ============================ * * @see knob-base/src/config/mustache_params.php -> Parent file * */ return ['ajaxUrl' => '/ajax', 'blogAuthor' => 'José María Valera Reales', 'blogDescription' => ($d = I18n::trans('internal.blog_description')) ? $d : get_bloginfo('description'), 'blogKeywords' => 'just blog chema'];
* file that was distributed with this source code. */ namespace Config; use Knob\I18n\I18n; /** * ============================ * Your Mustache helpers * ============================ * * @see knob-base/src/config/mustache_helpers.php -> Parent file * * ---------------------------- * For example: * ---------------------------- * $lower_text = 'lower text to upper'; // var from PHP code * * {{#case.upper}} lower_text {{/case.upper}} -> LOWER TEXT TO UPPER * Or * {{ lower_text | case.upper}} -> LOWER TEXT TO UPPER * * * @link https://github.com/bobthecow/mustache.php#usage * @link https://github.com/bobthecow/mustache.php/wiki/FILTERS-pragma * */ return ['trans' => function ($value) { return I18n::trans($value); }, 'transu' => function ($value) { return I18n::transu($value); }];
* * (c) José María Valera Reales <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use Knob\I18n\I18n; /** * NOTE: * For to use this page remember that you have to create your own * page through the backend from Wordpress. * * @example yoursite.com/lang?lang=en */ $lang = $_GET['lang']; $redirect = $_GET['redirect']; /* * Check if the lang is available */ if (in_array($lang, I18n::getAllLangAvailable())) { session_start(); $_SESSION[I18n::CURRENT_LANG] = $lang; } /* * We only redirect the url if not is absolute */ if (!$redirect || strpos($redirect, 'http') !== false || strpos($redirect, 'https') !== false) { header("Location: /"); } else { header("Location: {$redirect}"); }