本文整理汇总了PHP中WPFB_Core::settings方法的典型用法代码示例。如果您正苦于以下问题:PHP WPFB_Core::settings方法的具体用法?PHP WPFB_Core::settings怎么用?PHP WPFB_Core::settings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPFB_Core
的用法示例。
在下文中一共展示了WPFB_Core::settings方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _manually_load_plugin
function _manually_load_plugin()
{
require dirname(dirname(__FILE__)) . '/wp-filebase.php';
add_action('init', function () {
require_once dirname(dirname(__FILE__)) . '/classes/Core.php';
wpfb_loadclass('Setup');
WPFB_Setup::OnActivateOrVerChange(null);
WPFB_Core::$settings = (object) get_option(WPFB_OPT_NAME);
WPFB_Core::InitClass();
}, 1);
}
示例2: RemoveOptions
static function RemoveOptions()
{
delete_option(WPFB_OPT_NAME);
delete_option('wpfb_css');
delete_metadata('user', 0, 'wpfb_ext_tagtime', '', true);
// delete old options too
$options = WPFB_Admin::SettingsSchema();
foreach ($options as $opt_name => $opt_data) {
delete_option(WPFB_OPT_NAME . '_' . $opt_name);
}
WPFB_Core::$settings = new stdClass();
}
示例3: InitClass
static function InitClass()
{
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'));
// 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)
$wpfb_css = get_option('wpfb_css');
if ($wpfb_css) {
// static file?
wp_enqueue_style(WPFB, $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_PLUGIN_URI . "wp-filebase_css.php?rp={$upload_path}", array(), WPFB_VERSION, 'all');
}
if (is_admin() && !empty($_GET['page']) && strpos($_GET['page'], 'wpfilebase_') !== false || defined('WPFB_EDITOR_PLUGIN')) {
wpfb_loadclass('Admin');
}
// live admin
if (current_user_can('upload_files') && !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);
}
}
// 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
static function Display()
{
global $wpdb;
wpfb_loadclass('Admin', 'Output');
WPFB_Core::PrintJS();
// prints wpfbConf.ajurl
wp_register_script('jquery-imagepicker', WPFB_PLUGIN_URI . 'extras/jquery/image-picker/image-picker.min.js', array('jquery'), WPFB_VERSION);
wp_register_style('jquery-imagepicker', WPFB_PLUGIN_URI . 'extras/jquery/image-picker/image-picker.css', array(), WPFB_VERSION);
if (!current_user_can('manage_options')) {
wp_die(__('Cheatin’ uh?') . '<!-- manage_options -->');
}
// nonce and referer check (security)
if ((!empty($_POST['reset']) || !empty($_POST['submit'])) && !check_admin_referer('wpfb-update-settings', 'wpfb-nonce')) {
wp_die(__('Cheatin’ uh?'));
}
$post = stripslashes_deep($_POST);
$action = !empty($post['action']) ? $post['action'] : (!empty($_GET['action']) ? $_GET['action'] : '');
$messages = array();
$errors = array();
$options = get_option(WPFB_OPT_NAME);
$option_fields = WPFB_Admin::SettingsSchema();
if (isset($post['reset'])) {
// keep templates
$file_tpl = WPFB_Core::$settings->template_file;
$cat_tpl = WPFB_Core::$settings->template_cat;
wpfb_loadclass('Setup');
WPFB_Setup::ResetOptions();
WPFB_Core::UpdateOption('template_file', $file_tpl);
WPFB_Core::UpdateOption('template_cat', $cat_tpl);
$new_options = get_option(WPFB_OPT_NAME);
$messages = array_merge($messages, WPFB_Admin::SettingsUpdated($options, $new_options));
unset($new_options);
$messages[] = __('Settings reseted.', WPFB);
$options = get_option(WPFB_OPT_NAME);
} elseif (isset($post['submit'])) {
// cleanup
foreach ($option_fields as $opt_tag => $opt_data) {
if (isset($post[$opt_tag])) {
if (!is_array($post[$opt_tag])) {
$post[$opt_tag] = trim($post[$opt_tag]);
}
switch ($opt_data['type']) {
case 'number':
$post[$opt_tag] = intval($post[$opt_tag]);
break;
case 'select':
// check if value is in options array, if not set to default
if (!in_array($post[$opt_tag], array_keys($opt_data['options']))) {
$post[$opt_tag] = $opt_data['default'];
}
break;
case 'roles':
$post[$opt_tag] = array_values(array_filter($post[$opt_tag]));
// the following must not be removed! if the roles array is empty, permissions are assumed to be set for everyone!
// so make sure that the admin is explicitly set!
if (!empty($opt_data['not_everyone']) && !in_array('administrator', $post[$opt_tag])) {
if (!is_array($post[$opt_tag])) {
$post[$opt_tag] = array();
}
array_unshift($post[$opt_tag], 'administrator');
}
break;
case 'cat':
$post[$opt_tag] = empty($post[$opt_tag]) || is_null($cat = WPFB_Category::GetCat($post[$opt_tag])) ? 0 : intval($post[$opt_tag]);
break;
}
}
}
$post['upload_path'] = str_replace(ABSPATH, '', $post['upload_path']);
$options['upload_path'] = str_replace(ABSPATH, '', $options['upload_path']);
$post['download_base'] = trim($post['download_base'], '/');
if (WPFB_Admin::WPCacheRejectUri($post['download_base'] . '/', $options['download_base'] . '/')) {
$messages[] = sprintf(__('/%s/ added to rejected URIs list of WP Super Cache.', WPFB), $post['download_base']);
}
$tpl_file = $post['template_file'];
$tpl_cat = $post['template_cat'];
if (!empty($tpl_file) && (empty($options['template_file_parsed']) || $tpl_file != $options['template_file'])) {
wpfb_loadclass('TplLib');
$tpl_file = WPFB_TplLib::Parse($tpl_file);
$result = WPFB_TplLib::Check($tpl_file);
if (!$result['error']) {
$options['template_file_parsed'] = $tpl_file;
$messages[] = __('File template successfully parsed.', WPFB);
} else {
$errors[] = sprintf(__('Could not parse template: error (%s) in line %s.', WPFB), $result['msg'], $result['line']);
}
}
if (!empty($tpl_cat) && (empty($options['template_cat_parsed']) || $tpl_cat != $options['template_cat'])) {
wpfb_loadclass('TplLib');
$tpl_cat = WPFB_TplLib::Parse($tpl_cat);
$result = WPFB_TplLib::Check($tpl_cat);
if (!$result['error']) {
$options['template_cat_parsed'] = $tpl_cat;
$messages[] = __('Category template successfully parsed.', WPFB);
} else {
$errors[] = sprintf(__('Could not parse template: error (%s) in line %s.', WPFB), $result['msg'], $result['line']);
}
}
$fb_sub_pages = get_pages(array('child_of' => $options['file_browser_post_id']));
if ($options['file_browser_post_id'] > 0 && count($fb_sub_pages)) {
//.........这里部分代码省略.........
示例5: SettingsUpdated
public static function SettingsUpdated($old, &$new)
{
$messages = array();
wpfb_call('Setup', 'ProtectUploadPath');
// custom fields:
$messages = array_merge($messages, WPFB_Admin::SyncCustomFields());
if ($old['thumbnail_path'] != $new['thumbnail_path']) {
update_option(WPFB_OPT_NAME, $old);
// temporaly restore old settings
WPFB_Core::$settings = (object) $old;
$items = array_merge(WPFB_File::GetFiles2(), WPFB_Category::GetCats());
$old_thumbs = array();
foreach ($items as $i => $item) {
$old_thumbs[$i] = $item->GetThumbPath(true);
}
update_option(WPFB_OPT_NAME, $new);
// restore new settings
WPFB_Core::$settings = (object) $new;
$n = 0;
foreach ($items as $i => $item) {
if (!empty($old_thumbs[$i]) && is_file($old_thumbs[$i])) {
$new_path = $item->GetThumbPath(true);
$dir = dirname($new_path);
if (!is_dir($dir)) {
self::Mkdir($dir);
}
if (rename($old_thumbs[$i], $new_path)) {
$n++;
} else {
$messages[] = sprintf(__('Could not move thumnail %s to %s.', WPFB), $old_thumbs[$i], $new_path);
}
}
}
if (count($n > 0)) {
$messages[] = sprintf(__('%d Thumbnails moved.', WPFB), $n);
}
}
flush_rewrite_rules();
return $messages;
}
示例6: Display
static function Display()
{
global $wpdb, $user_ID;
//register_shutdown_function( create_function('','$error = error_get_last(); if( $error && $error[\'type\'] != E_STRICT ){print_r( $error );}else{return true;}') );
wpfb_loadclass('File', 'Category', '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', 'doit', 'ids', 'files', 'cats', 'batch_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');
}
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');
WPFB_Admin::PrintFlattrHead();
?>
<script type="text/javascript">
/* Liking/Donate Bar */
if(typeof(jQuery) != 'undefined') {
jQuery(document).ready(function(){
if(getUserSetting("wpfilebase_hidesuprow",false) == 1) {
jQuery('#wpfb-liking').hide();
jQuery('#wpfb-liking-toggle').addClass('closed');
}
jQuery('#wpfb-liking-toggle').click(function(){
jQuery('#wpfb-liking').slideToggle();
jQuery(this).toggleClass('closed');
setUserSetting("wpfilebase_hidesuprow", 1-getUserSetting("wpfilebase_hidesuprow",false), 0);
});
});
}
</script>
<div class="wrap">
<div id="icon-wpfilebase" class="icon32"><br /></div>
<h2><?php
echo WPFB_PLUGIN_NAME;
?>
</h2>
<?php
if ($show_how_start) {
wpfb_call('AdminHowToStart', 'Display');
}
if (!empty($_GET['action'])) {
echo '<p><a href="' . $clean_uri . '" class="button">' . __('Go back') . '</a></p>';
}
switch ($action) {
default:
$clean_uri = remove_query_arg('pagenum', $clean_uri);
$upload_dir = WPFB_Core::UploadDir();
$upload_dir_rel = str_replace(ABSPATH, '', $upload_dir);
$chmod_cmd = "CHMOD " . WPFB_PERM_DIR . " " . $upload_dir_rel;
if (!is_dir($upload_dir)) {
$result = WPFB_Admin::Mkdir($upload_dir);
if ($result['error']) {
$error_msg = sprintf(__('The upload directory <code>%s</code> does not exists. It could not be created automatically because the directory <code>%s</code> is not writable. Please create <code>%s</code> and make it writable for the webserver by executing the following FTP command: <code>%s</code>', WPFB), $upload_dir_rel, str_replace(ABSPATH, '', $result['parent']), $upload_dir_rel, $chmod_cmd);
} else {
wpfb_call('Setup', 'ProtectUploadPath');
}
} elseif (!is_writable($upload_dir)) {
$error_msg = sprintf(__('The upload directory <code>%s</code> is not writable. Please make it writable for PHP by executing the follwing FTP command: <code>%s</code>', WPFB), $upload_dir_rel, $chmod_cmd);
}
if (!empty($error_msg)) {
echo '<div class="error default-password-nag"><p>' . $error_msg . '</p></div>';
}
if (!empty(WPFB_Core::$settings->tag_conv_req)) {
echo '<div class="updated"><p><a href="' . add_query_arg('action', 'convert-tags') . '">';
_e('WP-Filebase content tags must be converted', WPFB);
echo '</a></p></div><div style="clear:both;"></div>';
}
if (!get_post(WPFB_Core::$settings->file_browser_post_id)) {
echo '<div class="updated"><p>';
printf(__('File Browser post or page not set! Some features like search will not work. <a href="%s">Click here to set the File Browser Post ID.</a>', WPFB), esc_attr(admin_url('admin.php?page=wpfilebase_sets#' . sanitize_title(__('File Browser', WPFB)))));
echo '</p></div><div style="clear:both;"></div>';
}
/*
wpfb_loadclass('Config');
if(!WPFB_Config::IsWritable()) {
echo '<div class="updated"><p>';
printf(__('The config file %s is not writable or could not be created. Please create the file and make it writable for the webserver.',WPFB), WPFB_Config::$file);
echo '</p></div><div style="clear:both;"></div>';
}
*/
?>
<?php
if (self::PluginHasBeenUsedAWhile(true)) {
self::ProUpgradeNag();
}
if (self::PluginHasBeenUsedAWhile()) {
?>
//.........这里部分代码省略.........
示例7: Display
static function Display()
{
global $wpdb, $user_ID;
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
wpfb_loadclass('AdminDashboard');
add_thickbox();
wp_enqueue_script('dashboard');
if (wp_is_mobile()) {
wp_enqueue_script('jquery-touch-punch');
}
//register_shutdown_function( create_function('','$error = error_get_last(); if( $error && $error[\'type\'] != E_STRICT ){print_r( $error );}else{return true;}') );
wpfb_loadclass('File', 'Category', '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', 'doit', 'ids', 'files', 'cats', 'batch_sync'));
// keep search keyword
WPFB_Admin::PrintFlattrHead();
?>
<script type="text/javascript">
/* Liking/Donate Bar */
if(typeof(jQuery) != 'undefined') {
jQuery(document).ready(function(){
if(getUserSetting("wpfilebase_hidesuprow",false) == 1) {
jQuery('#wpfb-liking').hide();
jQuery('#wpfb-liking-toggle').addClass('closed');
}
jQuery('#wpfb-liking-toggle').click(function(){
jQuery('#wpfb-liking').slideToggle();
jQuery(this).toggleClass('closed');
setUserSetting("wpfilebase_hidesuprow", 1-getUserSetting("wpfilebase_hidesuprow",false), 0);
});
});
}
</script>
<div class="wrap">
<div id="icon-wpfilebase" class="icon32"><br /></div>
<h2><?php
echo WPFB_PLUGIN_NAME;
?>
</h2>
<?php
switch ($action) {
default:
$clean_uri = remove_query_arg('pagenum', $clean_uri);
$upload_dir = WPFB_Core::UploadDir();
$upload_dir_rel = str_replace(ABSPATH, '', $upload_dir);
$chmod_cmd = "CHMOD " . WPFB_PERM_DIR . " " . $upload_dir_rel;
if (!is_dir($upload_dir)) {
$result = WPFB_Admin::Mkdir($upload_dir);
if ($result['error']) {
$error_msg = sprintf(__('The upload directory <code>%s</code> does not exists. It could not be created automatically because the directory <code>%s</code> is not writable. Please create <code>%s</code> and make it writable for the webserver by executing the following FTP command: <code>%s</code>', 'wp-filebase'), $upload_dir_rel, str_replace(ABSPATH, '', $result['parent']), $upload_dir_rel, $chmod_cmd);
} else {
wpfb_call('Setup', 'ProtectUploadPath');
}
} elseif (!is_writable($upload_dir)) {
$error_msg = sprintf(__('The upload directory <code>%s</code> is not writable. Please make it writable for PHP by executing the follwing FTP command: <code>%s</code>', 'wp-filebase'), $upload_dir_rel, $chmod_cmd);
}
if (!empty($error_msg)) {
echo '<div class="error default-password-nag"><p>' . $error_msg . '</p></div>';
}
if (!empty(WPFB_Core::$settings->tag_conv_req)) {
echo '<div class="updated"><p><a href="' . add_query_arg('action', 'convert-tags') . '">';
_e('WP-Filebase content tags must be converted', 'wp-filebase');
echo '</a></p></div><div style="clear:both;"></div>';
}
?>
<?php
if (self::PluginHasBeenUsedAWhile(true)) {
self::ProUpgradeNag();
}
if (self::PluginHasBeenUsedAWhile()) {
?>
<div id="wpfb-support-col">
<div id="wpfb-liking-toggle"></div>
<h3><?php
_e('Like WP-Filebase?', 'wp-filebase');
?>
</h3>
<div id="wpfb-liking">
<!-- <div style="text-align: center;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fwp-filebase%2F&send=false&layout=button_count&width=150&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:140px; height:21px; display:inline-block; text-align:center;" <?php
echo ' allowTransparency="true"';
?>
></iframe></div> -->
<div style="text-align: center;" ><a href="https://twitter.com/wpfilebase" class="twitter-follow-button" data-show-count="false">Follow @wpfilebase</a>
<script type="text/javascript">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
<p>Please <a href="http://wordpress.org/support/view/plugin-reviews/wp-filebase">give it a good rating</a>.</p>
<p>For Cloud support and lots of other advanced features consider an</p>
<p style="text-align: center;"><a href="https://wpfilebase.com/?ref=dblike" class="button-primary">Upgrade to Pro</a></p>
<p style="text-align: center;"><a href="http://demo.wpfilebase.com/?ref=dblike" class="button">Live Pro Demo</a></p>
<p style="text-align:right;float:right;font-style:italic;">Thanks, Fabian</p>
<!-- <div style="text-align: center;">
<?php
//WPFB_Admin::PrintPayPalButton()
//.........这里部分代码省略.........
示例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');
}
}
示例9: InitClass
static function InitClass()
{
self::$ajax_url = admin_url('admin-ajax.php?action=wpfilebase');
self::$ajax_url_public = home_url('/?wpfilebase_ajax=1');
if (defined('WPFB_NO_CORE_INIT')) {
return;
}
// on activation
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('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(WPFB . '_cron', array(__CLASS__, 'Cron'));
add_action('wpfilebase_sync', array(__CLASS__, 'Sync'));
// for Developers: New wp-filebase actions
add_action('wp_ajax_nopriv_wpfilebase', array(__CLASS__, 'AjaxPublic'));
add_action('wp_ajax_wpfilebase', array(__CLASS__, 'AjaxAdmin'));
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-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');
}
if (isset($_GET['wpfilebase_ajax'])) {
define('DOING_AJAX', true);
wpfb_loadclass('Ajax');
WPFB_Ajax::PublicRequest();
}
}