本文整理汇总了PHP中WPFB_Core::CurUserCanCreateCat方法的典型用法代码示例。如果您正苦于以下问题:PHP WPFB_Core::CurUserCanCreateCat方法的具体用法?PHP WPFB_Core::CurUserCanCreateCat怎么用?PHP WPFB_Core::CurUserCanCreateCat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPFB_Core
的用法示例。
在下文中一共展示了WPFB_Core::CurUserCanCreateCat方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array_keys
if (($n = count($tags)) > 0) {
$ks = array_keys($tags);
for ($i = 0; $i < $n; $i++) {
if (stripos($ks[$i], $tag) === 0) {
while ($i < $n && stripos($ks[$i], $tag) === 0) {
$props[] = array('t' => $ks[$i], 'n' => $tags[$ks[$i]]);
$i++;
}
//break;
}
}
}
wpfb_print_json($props);
exit;
case 'new-cat':
if (!WPFB_Core::CurUserCanCreateCat()) {
die('-1');
}
wpfb_loadclass('Admin');
$result = WPFB_Admin::InsertCategory($_POST);
if (isset($result['error']) && $result['error']) {
wpfb_print_json(array('error' => $result['error']));
exit;
}
$cat = $result['cat'];
$args = WPFB_Output::fileBrowserArgs($_POST['args']);
$filesel = $args['type'] === 'fileselect';
$catsel = $args['type'] === 'catselect';
wpfb_print_json(array('error' => 0, 'id' => $cat->GetId(), 'name' => $cat->GetTitle(), 'id_str' => $args['idp'] . 'cat-' . $cat->cat_id, 'url' => $cat->GetUrl(), 'text' => WPFB_Output::fileBrowserCatItemText($catsel, $filesel, $cat, $args['onselect'], empty($_REQUEST['is_admin']) ? 'filebrowser' : 'filebrowser_admin'), 'classes' => $filesel || $catsel ? 'folder' : null));
exit;
case 'change-category':
示例2: GetTreeItems
static function GetTreeItems($parent_id, $args = array())
{
/* $args = array(
* sort_cats
* sort_files
* cats_only
* exclude_attached
* priv
* idp =>
* onselect
* );
*/
$parent_id = is_object($parent_id) ? $parent_id->cat_id : intval($parent_id);
$args = self::fileBrowserArgs($args);
$type = $args['type'];
$browser = $type === 'browser';
$filesel = $type === 'fileselect';
$catsel = $type === 'catselect';
$args['idp'] = wp_strip_all_tags($args['idp']);
$idp_cat = $args['idp'] . 'cat-';
$idp_file = $args['idp'] . 'file-';
$file_tpl = $cat_tpl = !empty($args['tpl']) ? $args['tpl'] : (($is_admin = !empty($args['is_admin'])) ? 'filebrowser_admin' : 'filebrowser');
if ($parent_id > 0 && (is_null($cat = WPFB_Category::GetCat($parent_id)) || !$cat->CurUserCanAccess())) {
return array((object) array('id' => 0, 'text' => WPFB_Core::$settings->cat_inaccessible_msg));
}
$sql_sort_files = $browser ? WPFB_Core::GetSortSql((WPFB_Core::$settings->file_browser_file_sort_dir ? '>' : '<') . WPFB_Core::$settings->file_browser_file_sort_by) : 'file_display_name';
$sql_sort_cats = $browser ? WPFB_Core::GetSortSql((WPFB_Core::$settings->file_browser_cat_sort_dir ? '>' : '<') . WPFB_Core::$settings->file_browser_cat_sort_by, false, true) : 'cat_name';
$files_before_cats = $browser && WPFB_Core::$settings->file_browser_fbc;
$inline_add_cat = WPFB_Core::CurUserCanCreateCat();
$where = " cat_parent = {$parent_id} ";
if ($browser) {
$where .= " AND cat_exclude_browser <> '1' ";
}
$cats = WPFB_Category::GetCats("WHERE {$where} ORDER BY {$sql_sort_cats}");
$cat_items = array();
$i = 0;
$folder_class = $filesel || $catsel ? 'folder' : '';
foreach ($cats as $c) {
if ($c->CurUserCanAccess(true)) {
$cat_items[$i++] = (object) array('id' => $idp_cat . $c->cat_id, 'cat_id' => $c->cat_id, 'text' => self::fileBrowserCatItemText($catsel, $filesel, $c, $args['onselect'], $cat_tpl), 'hasChildren' => $inline_add_cat || $c->HasChildren($catsel), 'classes' => $folder_class);
}
}
if ($inline_add_cat) {
$is = WPFB_Core::$settings->small_icon_size > 0 ? WPFB_Core::$settings->small_icon_size : 32;
$cat_items[$i++] = (object) array('id' => $idp_cat . '0', 'cat_id' => 0, 'text' => '<form action="" style="display:none;"><input type="text" placeholder="' . __('Category Name', WPFB) . '" name="cat_name" /></form> ' . '<a href="#" style="text-decoration:none;" onclick=\'return wpfb_newCatInput(this,' . $parent_id . ');\'><span style="' . ($browser ? 'font-size:' . $is . 'px;width:' . $is . 'px' : 'font-size:200%') . ';line-height:0;vertical-align:sub;display:inline-block;text-align:center;">+</span>' . __('Add Category', WPFB) . '</a>' . '<span style="font-size: 200%;vertical-align: sub;line-height: 0;font-weight: lighter;"> / </span>' . '<a href="#" style="text-decoration:none;" class="add-file"><span style="' . ($browser ? 'font-size:' . $is . 'px;width:' . $is . 'px' : 'font-size:200%') . ';line-height:0;vertical-align:sub;display:inline-block;text-align:center;">+</span>' . __('Add File', WPFB) . '</a>', 'hasChildren' => false, 'classes' => 'add-item');
} elseif ($parent_id == 0 && $catsel && $i == 0) {
return array((object) array('id' => $idp_cat . '0', 'text' => sprintf(__('You did not create a category. <a href="%s" target="_parent">Click here to create one.</a>', WPFB), admin_url('admin.php?page=wpfilebase_cats#addcat')), 'hasChildren' => false));
}
$file_items = array();
$i = 0;
if (empty($args['cats_only']) && !$catsel) {
$where = WPFB_File::GetSqlCatWhereStr($parent_id);
if (!empty($args['exclude_attached'])) {
$where .= " AND `file_post_id` = 0";
}
// $files = WPFB_File::GetFiles2(WPFB_File::GetSqlCatWhereStr($root_id), WPFB_Core::$settings->hide_inaccessible, $sql_file_order);
//$files = WPFB_File::GetFiles2(WPFB_File::GetSqlCatWhereStr($root_id), WPFB_Core::$settings->hide_inaccessible, $sql_file_order);
$files = WPFB_File::GetFiles2($where, WPFB_Core::$settings->hide_inaccessible && !($filesel && wpfb_call('Core', 'CurUserCanUpload')), $sql_sort_files);
foreach ($files as $f) {
$file_items[$i++] = (object) array('id' => $idp_file . $f->file_id, 'text' => $filesel ? '<a href="javascript:;" onclick="' . sprintf($args['onselect'], $f->file_id) . '">' . esc_html($f->GetTitle(24)) . '</a> <span style="font-size:75%;vertical-align:top;">' . esc_html($f->file_name) . '</span>' : $f->GenTpl2($file_tpl, false), 'classes' => $filesel ? 'file' : null, 'hasChildren' => false);
}
}
return $files_before_cats ? array_merge($file_items, $cat_items) : array_merge($cat_items, $file_items);
}
示例3: InitClass
static function InitClass()
{
self::$ajax_url = WPFB_Core::PluginUrl('wpfb-ajax.php');
if (defined('WPFB_NO_CORE_INIT')) {
return;
}
// used with CSS proxy
//Load settings
self::$settings = (object) get_option(WPFB_OPT_NAME);
// load lang
$lang_dir = defined('WPFB_LANG_DIR') ? '../../' . WPFB_LANG_DIR : basename(WPFB_PLUGIN_ROOT) . '/languages';
load_plugin_textdomain(WPFB, 'wp-content/plugins/' . $lang_dir, $lang_dir);
add_action('parse_query', array(__CLASS__, 'ParseQuery'));
// search
add_action('wp_enqueue_scripts', array(__CLASS__, 'EnqueueScripts'));
add_action('wp_footer', array(__CLASS__, 'Footer'));
add_action('generate_rewrite_rules', array(__CLASS__, 'GenRewriteRules'));
add_action(WPFB . '_cron', array(__CLASS__, 'Cron'));
add_action('wpfilebase_sync', array(__CLASS__, 'Sync'));
// for Developers: New wp-filebase actions
add_shortcode('wpfilebase', array(__CLASS__, 'ShortCode'));
// for attachments and file browser
add_filter('the_content', array(__CLASS__, 'ContentFilter'), 10);
// must be lower than 11 (before do_shortcode) and after wpautop (>9)
add_filter('ext2type', array(__CLASS__, 'Ext2TypeFilter'));
add_filter('pre_set_site_transient_update_plugins', array(__CLASS__, 'PreSetPluginsTransientFilter'));
add_filter('plugins_api', array(__CLASS__, 'PluginsApiFilter'), 10, 3);
// register treeview stuff
//wp_register_script('jquery-cookie', WPFB_PLUGIN_URI.'extras/jquery/jquery.cookie.js', array('jquery'));
wp_register_script('jquery-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.js', array('jquery'), WPFB_VERSION);
wp_register_script('jquery-treeview-edit', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.edit.js', array('jquery-treeview'), WPFB_VERSION);
wp_register_script('jquery-treeview-async', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.async.js', array('jquery-treeview-edit'), WPFB_VERSION);
wp_register_style('jquery-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.css', array(), WPFB_VERSION);
// DataTables
wp_register_script('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/js/jquery.dataTables.min.js', array('jquery'), WPFB_VERSION);
wp_register_style('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/css/jquery.dataTables.css', array(), WPFB_VERSION);
wp_register_script('jquery-dataTables-columnFilter', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/js/jquery.dataTables.columnFilter.js', array('jquery-dataTables'), WPFB_VERSION);
wp_register_script(WPFB, WPFB_PLUGIN_URI . 'js/common.js', array('jquery'), WPFB_VERSION);
// cond loading (see Footer)
if (empty(WPFB_Core::$settings->disable_css)) {
$wpfb_css = get_option('wpfb_css');
if ($wpfb_css) {
// static file?
wp_enqueue_style(WPFB, strstr($wpfb_css, '//'), array(), WPFB_VERSION, 'all');
} else {
$upload_path = path_is_absolute(WPFB_Core::$settings->upload_path) ? '' : WPFB_Core::$settings->upload_path;
wp_enqueue_style(WPFB, WPFB_Core::PluginUrl("wp-filebase_css.php?rp={$upload_path}"), array(), WPFB_VERSION, 'all');
}
}
$wpfb_admin_page = is_admin() && !empty($_GET['page']) && strpos($_GET['page'], 'wpfilebase_') !== false || defined('WPFB_EDITOR_PLUGIN');
if ($wpfb_admin_page) {
wpfb_loadclass('Admin');
}
// live admin
if ($wpfb_admin_page && @$_GET['page'] == 'wpfilebase_filebrowser' || (WPFB_Core::CurUserCanCreateCat() || WPFB_Core::CurUserCanUpload()) && !is_admin()) {
wp_enqueue_script(WPFB . '-live-admin', WPFB_PLUGIN_URI . 'js/live-admin.js', array('jquery'), WPFB_VERSION);
if (self::GetOpt('admin_bar')) {
add_action('admin_bar_menu', array(__CLASS__, 'AdminBar'), 80);
}
if (self::GetOpt('file_context_menu')) {
wp_enqueue_script('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.js', array('jquery'));
wp_enqueue_style('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.css', array(), WPFB_VERSION);
}
wp_enqueue_style('wpfb-live-admin', WPFB_PLUGIN_URI . 'css/live-admin.css', array(), WPFB_VERSION);
}
// for admin
if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
self::MceAddBtns();
}
self::DownloadRedirect();
if ((WPFB_Core::$settings->frontend_upload || current_user_can('upload_files')) && (!empty($_GET['wpfb_upload_file']) || !empty($_GET['wpfb_add_cat']))) {
wpfb_call('Admin', empty($_GET['wpfb_upload_file']) ? 'ProcessWidgetAddCat' : 'ProcessWidgetUpload');
}
}
示例4: Display
//.........这里部分代码省略.........
</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>';
}
case 'sync':
echo '<h2>' . __('Synchronisation') . '</h2>';
wpfb_loadclass('Sync');
$result = WPFB_Sync::Sync(!empty($_GET['hash_sync']), true);
if (!is_null($result)) {
WPFB_Sync::PrintResult($result);
}
if (empty($_GET['hash_sync'])) {
echo '<p><a href="' . add_query_arg('hash_sync', 1) . '" class="button">' . __('Complete file sync', WPFB) . '</a> ' . __('Checks files for changes, so more reliable but might take much longer. Do this if you uploaded/changed files with FTP.', WPFB) . '</p>';
}
break;
// sync
// sync
case 'batch-upload':
wpfb_loadclass('BatchUploader');
$batch_uploader = new WPFB_BatchUploader();
$batch_uploader->Display();
break;
case 'reset-hits':
global $wpdb;
$n = 0;
if (current_user_can('manage_options')) {
$n = $wpdb->query("UPDATE `{$wpdb->wpfilebase_files}` SET file_hits = 0 WHERE 1=1");
}
echo "<p>";
printf(__('Done. %d Files affected.'), $n);
echo "</p>";
break;
case 'install-extensions':
wpfb_call('AdmInstallExt', 'Display');
break;
}
// switch
?>
</div> <!-- wrap -->
<?php
}
示例5: Display
static function Display()
{
global $wpdb, $user_ID;
if (!WPFB_Core::CurUserCanCreateCat()) {
wp_die(__('Cheatin’ uh?'));
}
wpfb_loadclass('Category', 'File', 'Admin', 'Output');
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$action = !empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : '');
$clean_uri = remove_query_arg(array('message', 'action', 'file_id', 'cat_id', 'deltpl', 'hash_sync'));
// keep search keyword
// switch simple/extended form
if (isset($_GET['exform'])) {
$exform = !empty($_GET['exform']) && $_GET['exform'] == 1;
update_user_option($user_ID, WPFB_OPT_NAME . '_exform', $exform, true);
} else {
$exform = (bool) get_user_option(WPFB_OPT_NAME . '_exform');
}
?>
<div class="wrap">
<?php
switch ($action) {
case 'editcat':
$cat_id = (int) $_GET['cat_id'];
$file_category = WPFB_Category::GetCat($cat_id);
if (is_null($file_category) || !$file_category->CurUserCanEdit()) {
wp_die(__('Cheatin’ uh?'));
}
WPFB_Admin::PrintForm('cat', $file_category);
break;
case 'updatecat':
$cat_id = (int) $_POST['cat_id'];
$update = true;
$file_category = WPFB_Category::GetCat($cat_id);
if (is_null($file_category) || !$file_category->CurUserCanEdit()) {
wp_die(__('Cheatin’ uh?'));
}
case 'addcat':
$update = !empty($update);
if (!$update && !WPFB_Core::CurUserCanCreateCat()) {
wp_die(__('Cheatin’ uh?'));
}
$result = WPFB_Admin::InsertCategory(array_merge(stripslashes_deep($_POST), $_FILES));
if (isset($result['error']) && $result['error']) {
$message = $result['error'];
} else {
$message = $update ? __('Category updated.') : __('Category added.');
/* def */
}
//wp_redirect($clean_uri . '&action=manage_cats&message=' . urlencode($message));
//wp_redirect($clean_uri . '&action=manage_cats&message=' . urlencode($message));
default:
if (!empty($_POST['deleteit'])) {
foreach ((array) $_POST['delete'] as $cat_id) {
if (is_object($cat = WPFB_Category::GetCat($cat_id)) && $cat->CurUserCanEdit()) {
$cat->Delete();
}
}
}
if (!empty($_REQUEST['redirect']) && !empty($_REQUEST['redirect_to'])) {
WPFB_AdminLite::JsRedirect($_REQUEST['redirect_to']);
exit;
}
?>
<h2><?php
echo str_replace(array('(<', '>)'), array('<', '>'), sprintf(__('Manage Categories (<a href="%s">add new</a>)', 'wp-filebase'), '#addcat" class="add-new-h2'));
if (isset($_GET['s']) && $_GET['s']) {
printf('<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html(stripslashes($_GET['s'])));
}
?>
</h2>
<?php
if (!empty($message)) {
?>
<div id="message" class="updated fade"><p><?php
echo $message;
?>
</p></div><?php
}
?>
<form class="search-form topmargin" action="" method="get"><p class="search-box">
<input type="hidden" value="<?php
echo esc_attr($_GET['page']);
?>
" name="page" />
<label class="hidden" for="category-search-input"><?php
_e('Search Categories');
?>
:</label>
<input type="text" class="search-input" id="category-search-input" name="s" value="<?php
echo isset($_GET['s']) ? esc_attr($_GET['s']) : '';
?>
" />
<input type="submit" value="<?php
_e('Search Categories');
?>
//.........这里部分代码省略.........
示例6: Display
//.........这里部分代码省略.........
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>';
}
case 'sync':
echo '<h2>' . __('Synchronisation') . '</h2>';
wpfb_loadclass('Sync');
$result = WPFB_Sync::Sync(!empty($_GET['hash_sync']), true);
if (!is_null($result)) {
WPFB_Sync::PrintResult($result);
}
if (empty($_GET['hash_sync'])) {
echo '<p><a href="' . add_query_arg('hash_sync', 1) . '" class="button">' . __('Complete file sync', 'wp-filebase') . '</a> ' . __('Checks files for changes, so more reliable but might take much longer. Do this if you uploaded/changed files with FTP.', 'wp-filebase') . '</p>';
}
if (empty($_GET['debug'])) {
echo '<p><a href="' . add_query_arg('debug', 1) . '" class="button">' . __('Debug Sync', 'wp-filebase') . '</a> ' . __('Run to get more Debug Info in case Sync crashes', 'wp-filebase') . '</p>';
}
break;
// sync
// sync
case 'batch-upload':
wpfb_loadclass('BatchUploader');
$batch_uploader = new WPFB_BatchUploader();
$batch_uploader->Display();
break;
case 'reset-hits':
global $wpdb;
$n = 0;
if (current_user_can('manage_options')) {
$n = $wpdb->query("UPDATE `{$wpdb->wpfilebase_files}` SET file_hits = 0 WHERE 1=1");
}
echo "<p>";
printf(__('Done. %d Files affected.'), $n);
echo "</p>";
break;
case 'install-extensions':
wpfb_call('AdmInstallExt', 'Display');
break;
}
// switch
if (!empty($_GET['action'])) {
echo '<p><a href="' . $clean_uri . '" class="button">' . __('Go back') . '</a></p>';
}
?>
</div> <!-- wrap -->
<?php
}
示例7: actionNewCat
private static function actionNewCat($args)
{
wpfb_loadclass('Category');
$parent_cat = empty($args['cat_parent']) ? null : WPFB_Category::GetCat($args['cat_parent']);
if (!WPFB_Core::CurUserCanCreateCat() && !$parent_cat && !$parent_cat->CurUserCanAddFiles()) {
die('-1');
}
wpfb_loadclass('Admin');
$result = WPFB_Admin::InsertCategory($args);
if (isset($result['error']) && $result['error']) {
wp_send_json(array('error' => $result['error']));
exit;
}
$cat = $result['cat'];
$fb_args = WPFB_Output::fileBrowserArgs(empty($args['args']) ? array() : $args['args']);
$filesel = $fb_args['type'] === 'fileselect';
$catsel = $fb_args['type'] === 'catselect';
$tpl = empty($args['tpl']) ? empty($args['is_admin']) ? 'filebrowser' : 'filebrowser_admin' : $args['tpl'];
wp_send_json(array('error' => 0, 'id' => $cat->GetId(), 'name' => $cat->GetTitle(), 'id_str' => $fb_args['idp'] . 'cat-' . $cat->cat_id, 'url' => $cat->GetUrl(), 'text' => WPFB_Output::fileBrowserCatItemText($catsel, $filesel, $cat, $fb_args['onselect'], $tpl), 'classes' => $filesel || $catsel ? 'folder' : null));
}
示例8: InitClass
static function InitClass()
{
self::$ajax_url = admin_url('admin-ajax.php?action=wpfilebase');
self::$ajax_url_public = strstr(home_url('/?wpfilebase_ajax=1'), '//');
// remove protocol qualifier
self::$settings = (object) get_option(WPFB_OPT_NAME, array());
if (defined('WPFB_NO_CORE_INIT')) {
return;
}
// on activation
$lang_dir = defined('WPFB_LANG_DIR') ? '../../' . WPFB_LANG_DIR : basename(WPFB_PLUGIN_ROOT) . '/languages';
load_plugin_textdomain('wp-filebase', false, $lang_dir);
add_action('parse_query', array(__CLASS__, 'ParseQuery'));
// search
add_action('wp_enqueue_scripts', array(__CLASS__, 'EnqueueScripts'));
add_action('wp_footer', array(__CLASS__, 'Footer'));
add_action('generate_rewrite_rules', array(__CLASS__, 'GenRewriteRules'));
add_action('wp_ajax_nopriv_wpfilebase', wpfb_callback('Ajax', 'PublicRequest'));
add_action('wp_ajax_wpfilebase', wpfb_callback('Ajax', 'AdminRequest'));
add_action('wpfb_cron', array(__CLASS__, 'Cron'));
add_action('wpfilebase_sync', array(__CLASS__, 'Sync'));
// for Developers: New wp-filebase actions
add_action('wpfilebase_bgscan', array(__CLASS__, 'BgScanWork'));
// for Developers: New wp-filebase actions
// for attachments and file browser
add_filter('the_content', array(__CLASS__, 'ContentFilter'), 10);
// must be lower than 11 (before do_shortcode) and after wpautop (>9)
add_filter('pre_set_site_transient_update_plugins', array(__CLASS__, 'PreSetPluginsTransientFilter'));
add_filter('plugins_api', array(__CLASS__, 'PluginsApiFilter'), 10, 3);
add_filter('ext2type', array(__CLASS__, 'Ext2TypeFilter'));
add_shortcode('wpfilebase', array(__CLASS__, 'ShortCode'));
self::DownloadRedirect();
if (isset($_GET['wpfilebase_ajax'])) {
define('DOING_AJAX', true);
wpfb_loadclass('Ajax');
WPFB_Ajax::PublicRequest();
}
// register treeview stuff
wp_register_script('wpfb-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview-async-edit.min.js', array('jquery'), WPFB_VERSION);
wp_register_style('wpfb-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.css', array(), WPFB_VERSION);
// DataTables
wp_register_script('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/datatables.min.js', array('jquery'), WPFB_VERSION);
wp_register_style('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/datatables.min.css', array(), WPFB_VERSION);
wp_register_script(WPFB, WPFB_PLUGIN_URI . 'js/common.js', array('jquery'), WPFB_VERSION);
// cond loading (see Footer)
wp_register_script('wpfb-live-admin', WPFB_PLUGIN_URI . 'js/live-admin.js', array('jquery'), WPFB_VERSION);
if (empty(WPFB_Core::$settings->disable_css)) {
$wpfb_css = get_option('wpfb_css');
wp_enqueue_style(WPFB, strstr($wpfb_css ? $wpfb_css : WPFB_PLUGIN_URI . 'wp-filebase.css', '//'), array(), WPFB_VERSION, 'all');
}
// live admin normaly for front-end, but also on filebrowser backend
if (is_admin() ? isset($_GET['page']) && $_GET['page'] == 'wpfilebase_filebrowser' : WPFB_Core::CurUserCanCreateCat() || WPFB_Core::CurUserCanUpload()) {
wp_enqueue_script('wpfb-live-admin');
wp_enqueue_style('wpfb-live-admin', WPFB_PLUGIN_URI . 'css/live-admin.css', array(), WPFB_VERSION);
self::$settings->admin_bar && add_action('admin_bar_menu', array(__CLASS__, 'AdminBar'), 80);
if (!empty(self::$settings->file_context_menu)) {
wp_enqueue_script('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.js', array('jquery'));
wp_enqueue_style('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.css', array(), WPFB_VERSION);
}
}
if (WPFB_Core::$settings->frontend_upload && (!empty($_GET['wpfb_upload_file']) || !empty($_GET['wpfb_add_cat'])) && (WPFB_Core::CurUserCanUpload() || WPFB_Core::CurUserCanCreateCat())) {
wpfb_call('Admin', empty($_GET['wpfb_upload_file']) ? 'ProcessWidgetAddCat' : 'ProcessWidgetUpload');
}
}