Your WordPress media library is messy?
Start using FileBird to organize your files into folders by drag and drop.
_('You do not have permission to install plugins.')));
wp_die();
}
$installed = $this->pluginInstaller('filebird');
if ($installed === false) {
wp_send_json_error(array('message' => $installed));
}
try {
$result = activate_plugin('filebird/filebird.php');
if (is_wp_error($result)) {
throw new \Exception($result->get_error_message());
}
wp_send_json_success();
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
}
public function pluginInstaller ($slug) {
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
require_once( ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php' );
require_once( ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php' );
$api = plugins_api( 'plugin_information',
array(
'slug' => $slug,
'fields' => array(
'short_description' => false,
'sections' => false,
'requires' => false,
'rating' => false,
'ratings' => false,
'downloaded' => false,
'last_updated' => false,
'added' => false,
'tags' => false,
'compatibility' => false,
'homepage' => false,
'donate_link' => false,
),
)
);
if (is_wp_error($api)) {
throw new \Exception(_('Could not fetch plugin information.'));
}
$skin = new \WP_Ajax_Upgrader_Skin();
$upgrader = new \Plugin_Upgrader( $skin );
try {
$result = $upgrader->install( $api->download_link );
if (is_wp_error($result)) {
throw new \Exception($result->get_error_message());
}
return true;
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
return false;
}
public function ajax_set_notification(){
check_ajax_referer("njt_{$this->pluginPrefix}_cross_nonce", 'nonce', true);
//Save after 30 days
update_option("njt_notification_{$this->pluginPrefix}_cross", time() + (30 * 60 * 60 * 24));
wp_send_json_success();
}
public function ajax_hide_cross(){
check_ajax_referer("njt_{$this->pluginPrefix}_cross_nonce", 'nonce', true);
$type = sanitize_text_field($_POST['type']);
$time = time() + (30 * 60 * 60 * 24); // hide 30 days
update_option("njt_{$type}_{$this->pluginPrefix}_cross", $time);
wp_send_json_success();
}
}
}
if ( !class_exists('FileBirdCross') ) {
class FileBirdCross extends NjtCross {
public function is_plugin_exist()
{
return (
defined('NJT_FILEBIRD_VERSION') ||
defined('NJFB_VERSION') ||
parent::is_plugin_exist()
);
}
}
FileBirdCross::get_instance('filebird', 'filebird+ninjateam', NJT_FS_BN_PLUGIN_URL, array('filebird/filebird.php', 'filebird-pro/filebird.php'));
}