コード例 #1
0
ファイル: Comm.php プロジェクト: kmvan/poil10n
 public static function getOpts($key = null, $force = false)
 {
     if (!$force) {
         static $cache = [];
         $cacheID = static::getOptID();
         if (!isset($cache[$cacheID])) {
             $cache[$cacheID] = array_merge(static::getDefaultOpts(), (array) Options::getOpts(static::getOptID()));
         }
         if ($key) {
             return isset($cache[$cacheID][$key]) ? $cache[$cacheID][$key] : false;
         }
         return $cache[$cacheID];
     }
     $opts = array_merge(static::getDefaultOpts(), (array) Options::getOpts(static::getOptID()));
     if (!$opts) {
         return false;
     }
     if ($key) {
         return isset($opts[$key]) ? $opts[$key] : false;
     }
     return $opts;
 }
コード例 #2
0
ファイル: Api.php プロジェクト: kmvan/poil10n
 public static function catOptsList($addonID, $catID, $child = false)
 {
     $opts = (array) Options::getOpts($addonID);
     if ($child !== false) {
         $selectedCatID = isset($opts[$catID][$child]) && $opts[$catID][$child] != 0 ? $opts[$catID][$child] : null;
     } else {
         $selectedCatID = isset($opts[$catID]) && $opts[$catID] != 0 ? $opts[$catID] : null;
     }
     $args = ['name' => $child !== false ? $addonID . '[' . $catID . '][' . $child . ']' : $addonID . '[' . $catID . ']', 'name' => $child !== false ? "{$addonID}[{$catID}][{$child}]" : $addonID . '[' . $catID . ']', 'id' => $child !== false ? $addonID . '-' . $catID . '-' . $child : $addonID . '-' . $catID, 'show_option_none' => L10n::__('Select category'), 'hierarchical' => 1, 'hide_empty' => false, 'selected' => $selectedCatID, 'echo' => 1];
     \wp_dropdown_categories($args);
 }