示例#1
0
 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');
     }
 }
示例#2
0
 static function AjaxAdmin()
 {
     wpfb_loadclass('Ajax');
     WPFB_Ajax::AdminRequest();
 }