本文整理汇总了PHP中WPFB_Core::GetOpt方法的典型用法代码示例。如果您正苦于以下问题:PHP WPFB_Core::GetOpt方法的具体用法?PHP WPFB_Core::GetOpt怎么用?PHP WPFB_Core::GetOpt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPFB_Core
的用法示例。
在下文中一共展示了WPFB_Core::GetOpt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MakeFormOptsList
static function MakeFormOptsList($opt_name, $selected = null, $add_empty_opt = false)
{
$options = WPFB_Core::GetOpt($opt_name);
$options = explode("\n", $options);
$def_sel = is_null($selected) && !is_string($selected);
$list = $add_empty_opt ? '<option value=""' . (is_string($selected) && $selected == '' ? ' selected="selected"' : '') . '>-</option>' : '';
$selected = explode('|', $selected);
foreach ($options as $opt) {
$opt = trim($opt);
$tmp = explode('|', $opt);
$list .= '<option value="' . esc_attr(trim($tmp[1])) . '"' . ($def_sel && $opt[0] == '*' || !$def_sel && in_array($tmp[1], $selected) ? ' selected="selected"' : '') . '>' . esc_html(trim($tmp[0], '*')) . '</option>';
}
return $list;
}
示例2: GenTpl
function GenTpl($parsed_tpl = null, $context = '')
{
if ($context != 'ajax') {
WPFB_Core::$load_js = true;
}
if (empty($parsed_tpl)) {
$tpo = $this->is_file ? 'template_file_parsed' : 'template_cat_parsed';
$parsed_tpl = WPFB_Core::GetOpt($tpo);
if (empty($parsed_tpl)) {
$parsed_tpl = wpfb_call('TplLib', 'Parse', WPFB_Core::GetOpt($this->is_file ? 'template_file' : 'template_cat'));
WPFB_Core::UpdateOption($tpo, $parsed_tpl);
}
}
/*
if($this->is_file) {
global $wpfb_file_paths;
if(empty($wpfb_file_paths)) $wpfb_file_paths = array();
$wpfb_file_paths[(int)$this->file_id] = $this->GetLocalPathRel();
}
*/
self::$tpl_uid++;
$f =& $this;
return eval("return ({$parsed_tpl});");
}
示例3: Download
function Download()
{
global $wpdb, $current_user, $user_ID;
@error_reporting(0);
wpfb_loadclass('Category', 'Download');
$downloader_ip = preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']);
get_currentuserinfo();
$logged_in = !empty($user_ID);
$user_role = $logged_in ? reset($current_user->roles) : null;
// get user's highest role (like in user-eidt.php)
$is_admin = current_user_can('manage_options');
// check user level
if (!$this->CurUserCanAccess()) {
$this->DownloadDenied('inaccessible_msg');
}
// check offline
if ($this->file_offline && !$is_admin) {
wp_die(WPFB_Core::$settings->file_offline_msg);
}
// check referrer
if ($this->file_direct_linking != 1) {
// if referer check failed, redirect to the file post
if (!WPFB_Download::RefererCheck()) {
$url = WPFB_Core::GetPostUrl($this->file_post_id);
if (empty($url)) {
$url = home_url();
}
wp_redirect($url);
exit;
}
}
// check traffic
if ($this->IsLocal() && !WPFB_Download::CheckTraffic($this->file_size)) {
header('HTTP/1.x 503 Service Unavailable');
wp_die(WPFB_Core::$settings->traffic_exceeded_msg);
}
// check daily user limit
if (!$is_admin && WPFB_Core::$settings->daily_user_limits) {
if (!$logged_in) {
$this->DownloadDenied('inaccessible_msg');
}
$today = intval(date('z'));
$usr_dls_today = intval(get_user_option(WPFB_OPT_NAME . '_dls_today'));
$usr_last_dl_day = intval(date('z', intval(get_user_option(WPFB_OPT_NAME . '_last_dl'))));
if ($today != $usr_last_dl_day) {
$usr_dls_today = 0;
}
// check for limit
$dl_limit = intval(WPFB_Core::GetOpt('daily_limit_' . $user_role));
if ($dl_limit > 0 && $usr_dls_today >= $dl_limit) {
$this->DownloadDenied(sprintf(WPFB_Core::$settings->daily_limit_exceeded_msg, $dl_limit));
}
$usr_dls_today++;
update_user_option($user_ID, WPFB_OPT_NAME . '_dls_today', $usr_dls_today);
update_user_option($user_ID, WPFB_OPT_NAME . '_last_dl', time());
}
// count download
if (!$is_admin || !WPFB_Core::$settings->ignore_admin_dls) {
$last_dl_time = mysql2date('U', $this->file_last_dl_time, false);
if (empty($this->file_last_dl_ip) || $this->file_last_dl_ip != $downloader_ip || time() - $last_dl_time > 86400) {
$wpdb->query("UPDATE " . $wpdb->wpfilebase_files . " SET file_hits = file_hits + 1, file_last_dl_ip = '" . $downloader_ip . "', file_last_dl_time = '" . current_time('mysql') . "' WHERE file_id = " . (int) $this->file_id);
}
}
// external hooks
do_action('wpfilebase_file_downloaded', $this->file_id);
$url = $this->GetRemoteUri();
$is_local_remote = !empty($url) && parse_url($url, PHP_URL_SCHEME) === 'file' && is_readable($url);
// download or redirect
if ($this->IsLocal() || $is_local_remote) {
$bw = 'bitrate_' . ($logged_in ? 'registered' : 'unregistered');
WPFB_Download::SendFile($is_local_remote ? $url : $this->GetLocalPath(), array('bandwidth' => WPFB_Core::$settings->{$bw}, 'etag' => $this->file_hash, 'md5_hash' => WPFB_Core::$settings->fake_md5 ? null : $this->file_hash, 'force_download' => WPFB_Core::$settings->force_download || $this->file_force_download, 'cache_max_age' => 10, 'filename' => empty($this->file_name_original) ? $this->file_name : $this->file_name_original));
} else {
//header('HTTP/1.1 301 Moved Permanently');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Expires: Thu, 01 Jan 1970 00:00:00 GMT');
header('Location: ' . $url);
}
exit;
}
示例4: TplsTable
static function TplsTable($type, $exclude = array(), $include = array())
{
global $user_identity;
$cat = $type == 'cat';
$list = $type == 'list';
$tpls = $list ? get_option(WPFB_OPT_NAME . '_list_tpls') : WPFB_Core::GetTpls($type);
if (!$list) {
$tpls['default'] = WPFB_Core::GetOpt("template_{$type}");
}
$item = $cat ? self::$sample_cat : self::$sample_file;
?>
<table class="widefat post fixed" cellspacing="0">
<thead>
<tr>
<th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
<th scope="col" class="manage-column" style="width:200px"><?php
_e('Name');
?>
</th>
<th scope="col" class="manage-column column-title" style=""><?php
_e('Preview');
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
<th scope="col" class="manage-column" style=""><?php
_e('Name');
?>
</th>
<th scope="col" class="manage-column column-title" style=""><?php
_e('Preview');
?>
</th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($tpls as $tpl_tag => $tpl_src) {
if (!empty($include) && !in_array($tpl_tag, $include) || !empty($exclude) && in_array($tpl_tag, $exclude)) {
continue;
}
$edit_link = add_query_arg(array('action' => 'edit', 'type' => $type, 'tpl' => $tpl_tag));
if ($list) {
$tpl = WPFB_ListTpl::Get($tpl_tag);
}
?>
<tr id="tpl-<?php
echo "{$type}-{$tpl_tag}";
?>
" class="iedit" valign="top">
<th scope="row" class="check-column"><input type="checkbox" name="tpl[]" value="<?php
echo esc_attr($tpl_tag);
?>
" /></th>
<td class="column-title">
<strong><a class="row-title" href="<?php
echo $edit_link;
?>
" title="<?php
printf(__('Edit “%s”'), $tpl_tag);
?>
"><?php
echo self::TplTitle($tpl_tag);
?>
</a></strong><br />
<code>tpl=<?php
echo $tpl_tag;
?>
</code>
<div class="row-actions"><span class='edit'><a href="<?php
echo $edit_link;
?>
" title="<?php
_e('Edit this item');
?>
"><?php
_e('Edit');
?>
</a></span>
<?php
if (!in_array($tpl_tag, self::$protected_tags)) {
?>
<span class='trash'>| <a class='submitdelete' title='<?php
_e('Delete this item permanently');
?>
' href='<?php
echo wp_nonce_url(add_query_arg(array('action' => 'del', 'type' => $type, 'tpl' => $tpl_tag)), 'del-' . $type, 'wpfb-tpl-nonce') . '#' . $type;
?>
'><?php
_e('Delete');
?>
</a></span><?php
}
?>
</div>
//.........这里部分代码省略.........
示例5: ParseSelOpts
static function ParseSelOpts($opt_name, $sel_tags, $uris = false)
{
$outarr = array();
$opts = explode("\n", WPFB_Core::GetOpt($opt_name));
if (!is_array($sel_tags)) {
$sel_tags = explode('|', $sel_tags);
}
for ($i = 0; $i < count($opts); $i++) {
$opt = explode('|', trim($opts[$i]));
if (in_array(isset($opt[1]) ? $opt[1] : $opt[0], $sel_tags)) {
$o = esc_html(ltrim($opt[0], '*'));
if ($uris && isset($opt[2])) {
$o = '<a href="' . esc_attr($opt[2]) . '" target="_blank">' . $o . '</a>';
}
$outarr[] = $o;
}
}
return implode(', ', $outarr);
}
示例6: Display
//.........这里部分代码省略.........
<p><?php
printf(__('%d Tags in %d Posts has been converted.'), $result['n_tags'], count($result['tags']));
?>
</p>
<ul>
<?php
if (!empty($result['tags'])) {
foreach ($result['tags'] as $post_title => $tags) {
echo "<li><strong>" . esc_html($post_title) . "</strong><ul>";
foreach ($tags as $old => $new) {
echo "<li>{$old} => {$new}</li>";
}
echo "</ul></li>";
}
}
?>
</ul>
<?php
if (!empty($result['errors'])) {
?>
<h2><?php
_e('Errors');
?>
</h2>
<ul><?php
foreach ($result['errors'] as $post_title => $err) {
echo "<li><strong>" . esc_html($post_title) . ": </strong> " . esc_html($err) . "<ul>";
}
?>
</ul>
<?php
}
$opts = WPFB_Core::GetOpt();
unset($opts['tag_conv_req']);
update_option(WPFB_OPT_NAME, $opts);
WPFB_Core::$settings = (object) $opts;
break;
// convert-tags
// convert-tags
case 'del':
if (!empty($_REQUEST['files']) && WPFB_Core::CurUserCanUpload()) {
$ids = explode(',', $_REQUEST['files']);
$nd = 0;
foreach ($ids as $id) {
$id = intval($id);
if (($file = WPFB_File::GetFile($id)) != null && $file->CurUserCanEdit()) {
$file->Remove(true);
$nd++;
}
}
WPFB_File::UpdateTags();
echo '<div id="message" class="updated fade"><p>' . sprintf(__('%d Files removed'), $nd) . '</p></div>';
}
if (!empty($_REQUEST['cats']) && WPFB_Core::CurUserCanCreateCat()) {
$ids = explode(',', $_REQUEST['cats']);
$nd = 0;
foreach ($ids as $id) {
$id = intval($id);
if (($cat = WPFB_Category::GetCat($id)) != null) {
$cat->Delete();
$nd++;
}
}
echo '<div id="message" class="updated fade"><p>' . sprintf(__('%d Categories removed'), $nd) . '</p></div>';
}
示例7: Display
//.........这里部分代码省略.........
<p><?php
printf(__('%d Tags in %d Posts has been converted.'), $result['n_tags'], count($result['tags']));
?>
</p>
<ul>
<?php
if (!empty($result['tags'])) {
foreach ($result['tags'] as $post_title => $tags) {
echo "<li><strong>" . esc_html($post_title) . "</strong><ul>";
foreach ($tags as $old => $new) {
echo "<li>{$old} => {$new}</li>";
}
echo "</ul></li>";
}
}
?>
</ul>
<?php
if (!empty($result['errors'])) {
?>
<h2><?php
_e('Errors');
?>
</h2>
<ul><?php
foreach ($result['errors'] as $post_title => $err) {
echo "<li><strong>" . esc_html($post_title) . ": </strong> " . esc_html($err) . "<ul>";
}
?>
</ul>
<?php
}
$opts = WPFB_Core::GetOpt();
unset($opts['tag_conv_req']);
update_option(WPFB_OPT_NAME, $opts);
WPFB_Core::$settings = (object) $opts;
break;
// convert-tags
// convert-tags
case 'del':
if (!empty($_REQUEST['files']) && WPFB_Core::CurUserCanUpload()) {
$ids = explode(',', $_REQUEST['files']);
$nd = 0;
foreach ($ids as $id) {
$id = intval($id);
if (($file = WPFB_File::GetFile($id)) != null && $file->CurUserCanDelete()) {
$file->Remove(true);
$nd++;
}
}
WPFB_File::UpdateTags();
echo '<div id="message" class="updated fade"><p>' . sprintf(__('%d Files removed'), $nd) . '</p></div>';
}
if (!empty($_REQUEST['cats']) && WPFB_Core::CurUserCanCreateCat()) {
$ids = explode(',', $_REQUEST['cats']);
$nd = 0;
foreach ($ids as $id) {
$id = intval($id);
if (($cat = WPFB_Category::GetCat($id)) != null) {
$cat->Delete();
$nd++;
}
}
echo '<div id="message" class="updated fade"><p>' . sprintf(__('%d Categories removed'), $nd) . '</p></div>';
}