static function SetupMenu() { global $wp_version; $pm_tag = WPFB_OPT_NAME . '_manage'; $icon = floatval($wp_version) >= 3.8 ? 'images/admin_menu_icon2.png' : 'images/admin_menu_icon.png'; add_menu_page(WPFB_PLUGIN_NAME, WPFB_PLUGIN_NAME, 'manage_categories', $pm_tag, wpfb_callback('AdminGuiManage', 'Display'), WPFB_PLUGIN_URI . $icon); $menu_entries = array(array('tit' => __('Files', 'wp-filebase'), 'tag' => 'files', 'fnc' => wpfb_callback('AdminGuiFiles', 'Display'), 'desc' => 'View uploaded files and edit them', 'cap' => 'upload_files'), array('tit' => __('Categories'), 'tag' => 'cats', 'fnc' => 'DisplayCatsPage', 'desc' => 'Manage existing categories and add new ones.', 'cap' => 'manage_categories')); $menu_entries[] = array('tit' => __('File Browser', 'wp-filebase'), 'tag' => 'filebrowser', 'fnc' => wpfb_callback('AdminGuiFileBrowser', 'Display'), 'desc' => 'Brows files and categories', 'cap' => 'upload_files'); //array('tit'=>'Sync Filebase', 'hide'=>true, 'tag'=>'sync', 'fnc'=>'DisplaySyncPage', 'desc'=>'Synchronises the database with the file system. Use this to add FTP-uploaded files.', 'cap'=>'upload_files'), if (empty(WPFB_Core::$settings->disable_css)) { $menu_entries[] = array('tit' => __('Edit Stylesheet', 'wp-filebase'), 'tag' => 'css', 'fnc' => wpfb_callback('AdminGuiCss', 'Display'), 'desc' => 'Edit the CSS for the file template', 'cap' => 'edit_themes'); } $menu_entries = array_merge($menu_entries, array(array('tit' => __('Embed Templates', 'wp-filebase'), 'tag' => 'tpls', 'fnc' => 'DisplayTplsPage', 'desc' => 'Edit custom file list templates', 'cap' => 'edit_themes'), array('tit' => __('Settings'), 'tag' => 'sets', 'fnc' => 'DisplaySettingsPage', 'desc' => 'Change Settings', 'cap' => 'manage_options'))); foreach ($menu_entries as $me) { $callback = is_callable($me['fnc']) ? $me['fnc'] : array(__CLASS__, $me['fnc']); add_submenu_page($pm_tag, WPFB_PLUGIN_NAME . ' - ' . $me['tit'], empty($me['hide']) ? $me['tit'] : null, empty($me['cap']) ? 'read' : $me['cap'], WPFB_OPT_NAME . '_' . $me['tag'], $callback); } }
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')); } }
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'); } }