本文整理汇总了PHP中WPFB_Core::CurUserCanUpload方法的典型用法代码示例。如果您正苦于以下问题:PHP WPFB_Core::CurUserCanUpload方法的具体用法?PHP WPFB_Core::CurUserCanUpload怎么用?PHP WPFB_Core::CurUserCanUpload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPFB_Core
的用法示例。
在下文中一共展示了WPFB_Core::CurUserCanUpload方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Setup
static function Setup($custom = false)
{
global $user_ID;
$screen = get_current_screen();
//$screen->get_option('layout_colums', 2);
//add_filter('screen_layout_columns', array(__CLASS__, 'screenLayoutColumns'), 10, 2);
if ($custom && !wp_is_mobile()) {
add_screen_option('layout_columns', array('max' => 2, 'default' => 2));
}
if (WPFB_Core::CurUserCanUpload()) {
add_meta_box('wpfb-add-file-widget', ($custom ? '' : WPFB_PLUGIN_NAME . ': ') . __('Add File', 'wp-filebase'), array(__CLASS__, 'WidgetAddFile'), $screen, 'normal', 'default', array(!$custom));
}
if ($custom) {
if (!empty($_GET['wpfb-hide-how-start'])) {
update_user_option($user_ID, WPFB_OPT_NAME . '_hide_how_start', 1);
}
$show_how_start = !(bool) get_user_option(WPFB_OPT_NAME . '_hide_how_start');
add_meta_box('wpfb-tools', __('Tools'), array(__CLASS__, 'WidgetTools'), $screen, 'side', 'default');
add_meta_box('wpfb-stats', __('Statistics', 'wp-filebase'), array(__CLASS__, 'WidgetStats'), $screen, 'side', 'default');
add_meta_box('wpfb-getstarted', sprintf(__('How to get started with %s?', 'wp-filebase'), WPFB_PLUGIN_NAME), array(__CLASS__, 'WidgetGetStarted'), $screen, 'side', $show_how_start ? 'high' : 'low');
add_meta_box('wpfb-about', __('About', 'wp-filebase'), array(__CLASS__, 'WidgetAbout'), $screen, 'side', 'default');
add_meta_box('wpfb-logs', __('Log Files', 'wp-filebase'), array(__CLASS__, 'WidgetLogFiles'), $screen, 'side', 'low');
//add_meta_box('wpfb-', __('','wp-filebase'), array(__CLASS__, ''), $screen, 'normal', 'default' );
//$screen->render_screen_meta();
}
}
示例2: Display
static function Display()
{
global $wpdb, $user_ID;
wpfb_loadclass('File', 'Category', 'Admin', 'Output');
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
$clean_uri = remove_query_arg(array('message', 'action', 'file_id', 'cat_id', 'deltpl', 'hash_sync'));
// keep search keyword
// nonce/referer check (security)
if ($action == 'updatefile' || $action == 'addfile') {
$nonce_action = WPFB . "-" . $action;
if ($action == 'updatefile') {
$nonce_action .= $_POST['file_id'];
}
if (!check_admin_referer($nonce_action, 'wpfb-file-nonce')) {
wp_die(__('Cheatin’ uh?'));
}
}
// 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 'editfile':
if (!current_user_can('upload_files')) {
wp_die(__('Cheatin’ uh?'));
}
if (!empty($_POST['files'])) {
if (!is_array($_POST['files'])) {
$_POST['files'] = explode(',', $_POST['files']);
}
$files = array();
foreach ($_POST['files'] as $file_id) {
$file = WPFB_File::GetFile($file_id);
if (!is_null($file) && $file->CurUserCanEdit()) {
$files[] = $file;
}
}
if (count($files) > 0) {
WPFB_Admin::PrintForm('file', $files, array('multi_edit' => true));
} else {
wp_die('No files to edit.');
}
} else {
$file = WPFB_File::GetFile($_GET['file_id']);
if (is_null($file) || !$file->CurUserCanEdit()) {
wp_die(__('You do not have the permission to edit this file!', 'wp-filebase'));
}
WPFB_Admin::PrintForm('file', $file);
}
break;
case 'updatefile':
$file_id = (int) $_POST['file_id'];
$update = true;
$file = WPFB_File::GetFile($file_id);
if (is_null($file) || !$file->CurUserCanEdit()) {
wp_die(__('Cheatin’ uh?'));
}
case 'addfile':
$update = !empty($update);
if (!WPFB_Core::CurUserCanUpload()) {
wp_die(__('Cheatin’ uh?'));
}
extract($_POST);
if (isset($jj) && isset($ss)) {
$jj = $jj > 31 ? 31 : $jj;
$hh = $hh > 23 ? $hh - 24 : $hh;
$mn = $mn > 59 ? $mn - 60 : $mn;
$ss = $ss > 59 ? $ss - 60 : $ss;
$_POST['file_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);
}
$result = WPFB_Admin::InsertFile(stripslashes_deep(array_merge($_POST, $_FILES)), true);
if (isset($result['error']) && $result['error']) {
$message = $result['error'] . '<br /><a href="javascript:history.back()">' . __("Go back") . '</a>';
} else {
$message = $update ? __('File updated.', 'wp-filebase') : __('File added.', 'wp-filebase');
}
default:
if (!current_user_can('upload_files')) {
wp_die(__('Cheatin’ uh?'));
}
if (!empty($_REQUEST['redirect']) && !empty($_REQUEST['redirect_to'])) {
WPFB_AdminLite::JsRedirect($_REQUEST['redirect_to']);
exit;
}
if (!empty($_POST['deleteit'])) {
foreach ((array) $_POST['delete'] as $file_id) {
if (is_object($file = WPFB_File::GetFile($file_id)) && $file->CurUserCanDelete()) {
$file->Remove(true);
}
}
WPFB_File::UpdateTags();
}
//.........这里部分代码省略.........
示例3: get_the_title
$post_title = $post_id ? get_the_title($post_id) : null;
switch ($action) {
case 'detachfile':
if ($file && $file->CurUserCanEdit() && $file->file_post_id == $post_id) {
$file->SetPostId(0);
$file = null;
}
break;
case 'delfile':
if ($file && $file->CurUserCanEdit()) {
$file->Remove();
}
$file = null;
break;
case 'addfile':
if (!WPFB_Core::CurUserCanUpload()) {
wp_die(__('Cheatin’ uh?'));
}
break;
case 'updatefile':
if (!$file || !$file->CurUserCanEdit()) {
wp_die(__('Cheatin’ uh?'));
}
break;
case 'change-order':
foreach ($_POST as $n => $v) {
if (strpos($n, 'file_attach_order-') === 0) {
$file_id = intval(substr($n, strlen('file_attach_order-')));
if (!is_null($f = WPFB_File::GetFile($file_id))) {
$f->file_attach_order = intval($v);
$f->DBSave();
示例4: AdminDashboardSetup
static function AdminDashboardSetup()
{
if (WPFB_Core::CurUserCanUpload()) {
wp_add_dashboard_widget('wpfb-add-file-widget', WPFB_PLUGIN_NAME . ': ' . __('Add File', WPFB), wpfb_callback('Admin', 'AddFileWidget'));
}
}
示例5: 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');
}
}
示例6: FileBrowser
static function FileBrowser(&$content, $root_cat_id = 0, $cur_cat_id = 0)
{
static $fb_id = 0;
$fb_id++;
wpfb_loadclass('Category', 'File');
if (WPFB_Core::$file_browser_search) {
// see Core::ContentFilter
} else {
$root_cat = $root_cat_id == 0 ? null : WPFB_Category::GetCat($root_cat_id);
$cur_item = WPFB_Core::$file_browser_item;
if ($cur_cat_id > 0) {
$cur_item = WPFB_Category::GetCat($cur_cat_id);
}
// make sure cur cat is a child cat of parent
if (!is_null($cur_item) && !is_null($root_cat) && !$root_cat->IsAncestorOf($cur_item)) {
$cur_item = null;
}
self::initFileTreeView($el_id = "wpfb-filebrowser-{$fb_id}", $root_cat);
// thats all, JS is loaded in Core::Header
$content .= '<ul id="' . $el_id . '" class="treeview">';
$parents = array();
if (!is_null($cur_item)) {
$p = $cur_item;
do {
array_push($parents, $p);
} while (!is_null($p = $p->GetParent()) && !$p->Equals($root_cat));
}
$args = array();
if (is_admin()) {
$args['is_admin'] = true;
}
self::FileBrowserList($content, $root_cat, array_merge($args, array('open_cats' => $parents)));
$content .= '</ul><div style="clear:both;"></div>';
if (WPFB_Core::CurUserCanCreateCat() || WPFB_Core::CurUserCanUpload()) {
wpfb_loadclass('TreeviewAdmin');
$content .= WPFB_TreeviewAdmin::ReturnHTML($el_id, is_admin() || get_user_option('wpfb_set_fbdd'), is_admin() ? 'filebrowser_admin' : 'filebrowser');
}
}
}
示例7: Display
//.........这里部分代码省略.........
</script>
<?php
if (!empty(WPFB_Core::$settings->tag_conv_req)) {
?>
<p><a href="<?php
echo add_query_arg('action', 'convert-tags');
?>
" class="button"><?php
_e('Convert old Tags', WPFB);
?>
</a> <?php
printf(__('Convert tags from versions earlier than %s.', WPFB), '0.2.0');
?>
</p> <?php
}
?>
<!-- <p><a href="<?php
echo add_query_arg('action', 'add-urls');
?>
" class="button"><?php
_e('Add multiple URLs', WPFB);
?>
</a> <?php
_e('Add multiple remote files at once.', WPFB);
?>
</p>
-->
</div>
<div style="clear: both;"></div>
<?php
if (WPFB_Core::CurUserCanUpload()) {
WPFB_Admin::PrintForm('file', null, array('exform' => $exform));
}
?>
<?php
if (!$show_how_start) {
// display how start here if its hidden
wpfb_call('AdminHowToStart', 'Display');
}
?>
<h2><?php
_e('About');
?>
</h2>
<p>
<?php
echo WPFB_PLUGIN_NAME . ' ' . WPFB_VERSION;
?>
by Fabian Schlieper <a href="http://fabi.me/">
<?php
if (strpos($_SERVER['SERVER_PROTOCOL'], 'HTTPS') === false) {
?>
<img src="http://fabi.me/misc/wpfb_icon.gif?lang=<?php
if (defined('WPLANG')) {
echo WPLANG;
}
?>
" alt="" /><?php
}
?>
fabi.me</a><br/>
示例8: Display
//.........这里部分代码省略.........
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>';
}
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'])) {
示例9: upload
private static function upload($args)
{
define('TMP_FILE_MAX_AGE', 3600 * 3);
$frontend_upload = !empty($args['frontend_upload']) && $args['frontend_upload'] !== "false";
$file_add_now = !empty($args['file_add_now']) && $args['file_add_now'] !== "false";
// TODO: need to check if frontend_upload and user logged in state
// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
if (!is_user_logged_in()) {
if (is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
} elseif (empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
}
if (empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie'])) {
$_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
}
if (!empty($_REQUEST['auth_cookie']) || !empty($_REQUEST['logged_in_cookie'])) {
wp_set_current_user(wp_validate_auth_cookie());
}
}
wpfb_loadclass('Category', 'File');
$parent_cat = empty($args['cat_id']) ? null : WPFB_Category::GetCat($args['cat_id']);
if ($frontend_upload) {
if ($file_add_now) {
wpfb_ajax_die('Unsupported upload!');
} else {
if (!WPFB_Core::$settings->frontend_upload && !current_user_can('upload_files')) {
wpfb_ajax_die(__('You do not have permission to upload files.'));
}
}
} else {
if (!WPFB_Core::CurUserCanUpload() && !$parent_cat && !$parent_cat->CurUserCanAddFiles()) {
wpfb_ajax_die(__('You do not have permission to upload files.'));
}
check_admin_referer(WPFB . '-async-upload');
}
wpfb_loadclass('Admin');
if (!empty($args['delupload'])) {
$del_upload = @json_decode($args['delupload']);
if ($del_upload && is_file($tmp = WPFB_Core::UploadDir() . '/.tmp/' . str_replace(array('../', '.tmp/'), '', $del_upload->tmp_name))) {
echo (int) @unlink($tmp);
}
// delete other old temp files
require_once ABSPATH . 'wp-admin/includes/file.php';
$tmp_files = list_files(WPFB_Core::UploadDir() . '/.tmp');
foreach ($tmp_files as $tmp) {
if (time() - filemtime($tmp) >= TMP_FILE_MAX_AGE) {
@unlink($tmp);
}
}
exit;
}
if (empty($_FILES['async-upload'])) {
wpfb_ajax_die(__('No file was uploaded.', 'wp-filebase') . ' (ASYNC)');
}
if (!is_uploaded_file($_FILES['async-upload']['tmp_name']) || !($tmp = WPFB_Admin::GetTmpFile($_FILES['async-upload']['name'])) || !move_uploaded_file($_FILES['async-upload']['tmp_name'], $tmp)) {
wpfb_ajax_die(sprintf(__('“%s” has failed to upload due to an error'), esc_html($_FILES['async-upload']['name'])));
}
$_FILES['async-upload']['tmp_name'] = trim(substr($tmp, strlen(WPFB_Core::UploadDir())), '/');
$json = json_encode($_FILES['async-upload']);
if ($file_add_now) {
$file_data = array('file_flash_upload' => $json, 'file_category' => 0);
if (!empty($args['presets'])) {
$presets = array();
parse_str($args['presets'], $presets);
WPFB_Admin::AdaptPresets($presets);
$file_data = array_merge($file_data, $presets);
}
$result = WPFB_Admin::InsertFile($file_data, false);
if (empty($result['error'])) {
$resp = array_merge((array) $result['file'], array('file_thumbnail_url' => $result['file']->GetIconUrl(), 'file_edit_url' => $result['file']->GetEditUrl(), 'file_cur_user_can_edit' => $result['file']->CurUserCanEdit(), 'file_download_url' => $result['file']->GetUrl(), 'nonce' => wp_create_nonce(WPFB . '-updatefile' . $result['file_id'])));
if (isset($args['tpl_tag'])) {
$tpl_tag = $args['tpl_tag'];
if ($tpl_tag === 'false') {
$tpl_tag = null;
}
$resp['tpl'] = $result['file']->GenTpl2($tpl_tag);
}
} else {
wpfb_ajax_die($result['error']);
}
$json = json_encode($resp);
}
header('Content-Type: application/json; charset=' . get_option('blog_charset'));
//header('Content-Length: ' . strlen($json));
echo $json;
}
示例10: 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');
}
}