/**
 *
 * @return unknown_type
 */
function wphp_remove_wp_low_profiler()
{
    wphp_log("called: wphp_remove_wp_low_profiler");
    $plugin_list = get_plugins('/wp-low-profiler');
    if (isset($plugin_list['wp-low-profiler.php'])) {
        wphp_log("The 'WP low Profiler' plugin is present. Cleaning it up...");
        $plugins = array('wp-low-profiler/wp-low-profiler.php');
        if (is_plugin_active('wp-low-profiler/wp-low-profiler.php')) {
            wphp_log("The 'WP low Profiler' plugin is active. Deactivating...");
            deactivate_plugins($plugins, true);
            // silent deactivate
        }
        wphp_log("Deleting plugin 'WP low Profiler'...");
        delete_plugins($plugins, '');
    } else {
        wphp_log("The 'WP low Profiler' plugin does not exist.");
    }
}
 protected function delete()
 {
     foreach ($this->plugins as $plugin) {
         if (Jetpack::is_plugin_active($plugin)) {
             $error = $this->log[$plugin][] = 'You cannot delete a plugin while it is active on the main site.';
             continue;
         }
         $result = delete_plugins(array($plugin));
         if (is_wp_error($result)) {
             $error = $this->log[$plugin][] = $result->get_error_message();
         } else {
             $this->log[$plugin][] = 'Plugin deleted';
         }
     }
     if (!$this->bulk && isset($error)) {
         return new WP_Error('delete_plugin_error', $error, 400);
     }
     return true;
 }
Beispiel #3
0
 /**
  * Activate handle
  */
 function do_activate()
 {
     // get current version of plugin
     $latest_version = IG_Pb_Helper_Functions::get_plugin_info(IG_PB_FILE, 'Version');
     // get previous version of plugin
     $old_version = get_transient('ig_pb_version');
     // compare version
     if (!$old_version || version_compare($old_version, $latest_version, '<')) {
         // update plugin version
         set_transient('ig_pb_version', $latest_version);
         // remove cache folder if plugin is installed before
         if ($old_version) {
             IG_Pb_Utils_Common::remove_cache_folder();
         }
     }
     // remove free shortcode directory
     if (is_dir(WP_PLUGIN_DIR . '/ig-shortcodes-free')) {
         delete_plugins(array('ig-shortcodes-free/main.php'));
     }
 }
 /**
  * @usage Single click add-on update
  */
 function updateAddon()
 {
     if (isset($_POST['updateurl']) && current_user_can(WPDM_ADMIN_CAP)) {
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         $upgrader = new \Plugin_Upgrader(new \Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
         $downloadlink = $_POST['updateurl'] . '&preact=login&user='******'__wpdm_suname') . '&pass='******'__wpdm_supass') . '&__wpdmnocache=' . uniqid();
         $update = new \stdClass();
         $plugininfo = wpdm_plugin_data($_POST['plugin']);
         deactivate_plugins($plugininfo['plugin_index_file'], true);
         delete_plugins(array($plugininfo['plugin_index_file']));
         $upgrader->install($downloadlink);
         if (file_exists(dirname(WPDM_BASE_DIR) . '/' . $plugininfo['plugin_index_file'])) {
             activate_plugin($plugininfo['plugin_index_file']);
         }
         die("Updated Successfully");
     } else {
         die("Only site admin is authorized to install add-on");
     }
 }
/**
 * Ajax handler for deleting a plugin.
 *
 * @since 4.6.0
 *
 * @see delete_plugins()
 */
function wp_ajax_delete_plugin()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug']) || empty($_POST['plugin'])) {
        wp_send_json_error(array('slug' => '', 'errorCode' => 'no_plugin_specified', 'errorMessage' => __('No plugin specified.')));
    }
    $plugin = plugin_basename(sanitize_text_field(wp_unslash($_POST['plugin'])));
    $status = array('delete' => 'plugin', 'slug' => sanitize_key(wp_unslash($_POST['slug'])));
    if (!current_user_can('delete_plugins') || 0 !== validate_file($plugin)) {
        $status['errorMessage'] = __('Sorry, you are not allowed to delete plugins for this site.');
        wp_send_json_error($status);
    }
    $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
    $status['plugin'] = $plugin;
    $status['pluginName'] = $plugin_data['Name'];
    if (is_plugin_active($plugin)) {
        $status['errorMessage'] = __('You cannot delete a plugin while it is active on the main site.');
        wp_send_json_error($status);
    }
    // Check filesystem credentials. `delete_plugins()` will bail otherwise.
    $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins');
    ob_start();
    $credentials = request_filesystem_credentials($url);
    ob_end_clean();
    if (false === $credentials || !WP_Filesystem($credentials)) {
        global $wp_filesystem;
        $status['errorCode'] = 'unable_to_connect_to_filesystem';
        $status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
        // Pass through the error from WP_Filesystem if one was raised.
        if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
            $status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
        }
        wp_send_json_error($status);
    }
    $result = delete_plugins(array($plugin));
    if (is_wp_error($result)) {
        $status['errorMessage'] = $result->get_error_message();
        wp_send_json_error($status);
    } elseif (false === $result) {
        $status['errorMessage'] = __('Plugin could not be deleted.');
        wp_send_json_error($status);
    }
    wp_send_json_success($status);
}
 function delete_default_content()
 {
     delete_theme('twentysixteen');
     delete_theme('twentyfifteen');
     delete_theme('twentyfourteen');
     delete_theme('twentythirteen');
     delete_theme('twentytwelve');
     delete_theme('twentyeleven');
     delete_theme('twentyten');
     delete_plugins(array('hello.php', 'akismet/akismet.php'));
 }
 /**
  *
  * @TODO document
  *
  */
 function plugin_delete($type, $file, $path, $uploader, $checked)
 {
     $this->wp_libs();
     if (!$checked) {
         $this->check_creds('extend', WP_PLUGIN_DIR);
     }
     global $wp_filesystem;
     delete_plugins(array(ltrim($file, '/')));
     $message = __('Plugin Deleted.', 'pagelines');
     $text = '&extend_text=plugin_delete#your_plugins';
     $this->page_reload(PL_ADMIN_STORE_SLUG . $text, null, $message);
 }
 /**
  * Delete plugin action.
  *
  * @return  void
  */
 protected function delete_plugin_action()
 {
     // Get plugin index
     $index = isset($_GET['plugin']) ? $_GET['plugin'] : null;
     if (is_null($index)) {
         throw new Exception(__('Missing plugin to delete.', 'ferado'));
     }
     // Get details about upload directory
     $path = wp_upload_dir();
     $path = $path['basedir'] . '/' . $this->id . '/installed_plugins.json';
     if (!$this->wp_filesystem->exists($path)) {
         return;
     }
     // Load the list of demo assets to be downloaded
     $installed_plugins = array_values(json_decode($this->wp_filesystem->get_contents($path), true));
     if (isset($installed_plugins[$index])) {
         // Find plugin
         if ($plugin = $this->_get_plugin_path($installed_plugins[$index]['name'])) {
             $result = delete_plugins(array($plugin));
             if (is_wp_error($result)) {
                 throw new Exception($result->get_error_message());
             }
         }
     }
     if ($index + 1 == count($installed_plugins)) {
         // Delete sample data installation results
         $this->wp_filesystem->delete($path);
     }
 }
Beispiel #9
0
/**
 * AJAX handler for deleting a plugin.
 *
 * @since 4.X.0
 */
function wp_ajax_delete_plugin()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug']) || empty($_POST['plugin'])) {
        wp_send_json_error(array('errorCode' => 'no_plugin_specified'));
    }
    $plugin = filter_var(wp_unslash($_POST['plugin']), FILTER_SANITIZE_STRING);
    $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
    $status = array('delete' => 'plugin', 'slug' => sanitize_key($_POST['slug']), 'plugin' => $plugin, 'pluginName' => $plugin_data['Name']);
    if (!current_user_can('delete_plugins')) {
        $status['error'] = __('You do not have sufficient permissions to delete plugins for this site.');
        wp_send_json_error($status);
    }
    if (!is_plugin_inactive($plugin)) {
        $status['error'] = __('You cannot delete a plugin while it is active on the main site.');
        wp_send_json_error($status);
    }
    // Check filesystem credentials. `delete_plugins()` will bail otherwise.
    ob_start();
    $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins');
    if (false === ($credentials = request_filesystem_credentials($url)) || !WP_Filesystem($credentials)) {
        global $wp_filesystem;
        ob_end_clean();
        $status['errorCode'] = 'unable_to_connect_to_filesystem';
        $status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
        // Pass through the error from WP_Filesystem if one was raised.
        if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
            $status['error'] = $wp_filesystem->errors->get_error_message();
        }
        wp_send_json_error($status);
    }
    $result = delete_plugins(array($plugin));
    if (is_wp_error($result)) {
        $status['error'] = $result->get_error_message();
        wp_send_json_error($status);
    } elseif (false === $result) {
        $status['error'] = __('Plugin could not be deleted.');
        wp_send_json_error($status);
    }
    wp_send_json_success($status);
}
Beispiel #10
0
 public function download_plugin_ajax_handler()
 {
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once $this->plugin_path() . '/includes/installer-upgrader-skins.php';
     if (isset($_POST['data'])) {
         $data = json_decode(base64_decode($_POST['data']), true);
     }
     $ret = false;
     $plugin_id = false;
     $message = '';
     //validate subscription
     $site_key = $this->get_repository_site_key($data['repository_id']);
     $subscription_data = $this->fetch_subscription_data($data['repository_id'], $site_key, self::SITE_KEY_VALIDATION_SOURCE_DOWNLOAD_REPORT);
     if ($subscription_data && !is_wp_error($subscription_data) && $this->repository_has_valid_subscription($data['repository_id'])) {
         if ($data['nonce'] == wp_create_nonce('install_plugin_' . $data['url'])) {
             $upgrader_skins = new Installer_Upgrader_Skins();
             //use our custom (mute) Skin
             $upgrader = new Plugin_Upgrader($upgrader_skins);
             remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
             $plugins = get_plugins();
             //upgrade or install?
             foreach ($plugins as $id => $plugin) {
                 $wp_plugin_slug = dirname($id);
                 $is_embedded = $this->plugin_is_embedded_version(preg_replace('/ Embedded$/', '', $plugin['Name']), preg_replace('/-embedded$/', '', $wp_plugin_slug));
                 if ($wp_plugin_slug == $data['slug'] || $is_embedded && preg_replace('/-embedded$/', '', $wp_plugin_slug) == $data['slug']) {
                     $plugin_id = $id;
                     break;
                 }
             }
             if ($plugin_id && empty($is_embedded)) {
                 //upgrade
                 $response['upgrade'] = 1;
                 $plugin_is_active = is_plugin_active($plugin_id);
                 $ret = $upgrader->upgrade($plugin_id);
                 if (!$ret && !empty($upgrader->skin->installer_error)) {
                     if (is_wp_error($upgrader->skin->installer_error)) {
                         $message = $upgrader->skin->installer_error->get_error_message() . ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
                     }
                 }
                 if ($plugin_is_active) {
                     //prevent redirects
                     add_filter('wp_redirect', '__return_false');
                     activate_plugin($plugin_id);
                 }
             } else {
                 //install
                 if ($is_embedded) {
                     delete_plugins(array($plugin_id));
                 }
                 $response['install'] = 1;
                 $ret = $upgrader->install($data['url']);
                 if (!$ret && !empty($upgrader->skin->installer_error)) {
                     if (is_wp_error($upgrader->skin->installer_error)) {
                         $message = $upgrader->skin->installer_error->get_error_message() . ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
                     }
                 }
             }
             $plugins = get_plugins();
             //read again
             if ($ret && !empty($_POST['activate'])) {
                 foreach ($plugins as $id => $plugin) {
                     $wp_plugin_slug = dirname($id);
                     if ($wp_plugin_slug == $data['slug']) {
                         $plugin_version = $plugin['Version'];
                         $plugin_id = $id;
                         break;
                     }
                 }
             }
         }
     } else {
         //subscription not valid
         $ret = false;
         $message = __('Your subscription appears to no longer be valid. Please try to register again using a valid site key.', 'installer');
     }
     $response['version'] = isset($plugin_version) ? $plugin_version : 0;
     $response['plugin_id'] = $plugin_id;
     $response['nonce'] = wp_create_nonce('activate_' . $plugin_id);
     $response['success'] = $ret;
     $response['message'] = $message;
     echo json_encode($response);
     exit;
 }
Beispiel #11
0
function nebula_initialization_delete_plugins()
{
    //Remove Hello Dolly plugin if it exists
    if (file_exists(WP_PLUGIN_DIR . '/hello.php')) {
        delete_plugins(array('hello.php'));
    }
}
Beispiel #12
0
 function do_uninstall()
 {
     if (!$this->current_user_can_uninstall()) {
         wp_die(__('You do not have sufficient permissions to delete plugins on this site.', 'seo-ultimate'));
     }
     echo "<script type='text/javascript'>jQuery('#adminmenu .current').hide(); jQuery('#toplevel_page_seo').hide();</script>";
     echo "<div class=\"wrap\">\n";
     echo "\n<h2>" . __('Uninstall SEO Ultimate', 'seo-ultimate') . "</h2>\n";
     //Delete settings and do miscellaneous clean up
     $this->plugin->uninstall();
     $this->print_mini_message('success', __('Deleted settings.', 'seo-ultimate'));
     //Deactivate the plugin
     deactivate_plugins(array($this->plugin->plugin_basename), true);
     //Attempt to delete the plugin's files and output result
     if (is_wp_error($error = delete_plugins(array($this->plugin->plugin_basename)))) {
         $this->print_mini_message('error', __('An error occurred while deleting files.', 'seo-ultimate') . '<br />' . $error->get_error_message());
     } else {
         $this->print_mini_message('success', __('Deleted files.', 'seo-ultimate'));
         $this->print_mini_message('success', __('Uninstallation complete. Thanks for trying SEO Ultimate.', 'seo-ultimate'));
     }
     echo "\n</div>\n";
     return true;
 }
Beispiel #13
0
    $result = activate_plugins($plugin_ID);
    if (!is_wp_error($result)) {
        if ($update !== False) {
            $update .= __(' and Activated', 'amazon-link');
        } else {
            $update = __('Plugin ' . $installed_plugins[$plugin_ID]['Name'] . ' - has been Activated', 'amazon-link');
        }
        $installed_plugins[$plugin_ID]['Activated'] = True;
    } else {
        $error = $result->get_error_message();
    }
    // **********************************************************
    // Uninstall the selected plugin
} else {
    if ($action == __('Uninstall', 'amazon-link')) {
        $result = delete_plugins((array) $plugin_ID);
        if (!is_wp_error($result)) {
            $update = __('Plugin ' . $installed_plugins[$plugin_ID]['Name'] . ' - has been Uninstalled', 'amazon-link');
            unset($installed_plugins[$plugin_ID]);
            $action = __('Deactivate', 'amazon-link');
        } else {
            $error = $result->get_error_message();
        }
    }
}
// **********************************************************
// Deactivate the selected plugin
if ($action == __('Deactivate', 'amazon-link')) {
    $result = deactivate_plugins($plugin_ID);
    if (!is_wp_error($result)) {
        if ($update !== False) {
Beispiel #14
0
function wp_install_defaults($user_id)
{
    global $wpdb, $wp_rewrite, $current_site, $table_prefix;
    // Let's customize our default WordPress options
    // @link http://codex.wordpress.org/Option_Reference
    // My preferred permalink structure
    update_option('permalink_structure', '/%category%/%postname%');
    // Changed from 'posts' to 'page'
    update_option('show_on_front', 'page');
    // Make our home page be the front page
    update_option('page_on_front', 1);
    // Turned this on so you can create content from apps
    update_option('enable_app', 1);
    update_option('enable_xmlrpc', 1);
    // Disable comments by default
    update_option('default_comment_status', 'closed');
    // Hide the Toolbar on the front-end
    show_admin_bar(false);
    // Make our theme the default one
    switch_theme('orbit', 'orbit');
    // Remove Hello Dolly and Akismet plugins
    require_once ABSPATH . 'wp-admin/includes/plugin.php';
    require_once ABSPATH . 'wp-admin/includes/file.php';
    if (file_exists(WP_PLUGIN_DIR . '/hello.php') || file_exists(WP_PLUGIN_DIR . 'akismet/akismet.php')) {
        delete_plugins(array('hello.php', 'akismet/akismet.php'));
    }
    // Default category (we rename it from 'Uncategorized' to 'General')
    $cat_name = __('General');
    // translators: Default category slug
    $cat_slug = sanitize_title(_x('General', 'Default category slug'));
    if (global_terms_enabled()) {
        $cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
        if ($cat_id == null) {
            $wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
            $cat_id = $wpdb->insert_id;
        }
        update_option('default_category', $cat_id);
    } else {
        $cat_id = 1;
    }
    $wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
    $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
    $cat_tt_id = $wpdb->insert_id;
    // Default link category (commented out)
    /*
    $cat_name = __('Blogroll');
    // translators: Default link category slug
    $cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
    
    if ( global_terms_enabled() ) {
    	$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
    	if ( $blogroll_id == null ) {
    		$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
    		$blogroll_id = $wpdb->insert_id;
    	}
    	update_option('default_link_category', $blogroll_id);
    } else {
    	$blogroll_id = 2;
    }
    
    $wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
    $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
    $blogroll_tt_id = $wpdb->insert_id;
    
    // Now drop in some default links
    $default_links = array();
    $default_links[] = array(	'link_url' => 'http://codex.wordpress.org/',
    							'link_name' => 'Documentation',
    							'link_rss' => '',
    							'link_notes' => '');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/news/',
    							'link_name' => 'WordPress Blog',
    							'link_rss' => 'http://wordpress.org/news/feed/',
    							'link_notes' => '');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/extend/ideas/',
    							'link_name' => 'Suggest Ideas',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/support/',
    							'link_name' => 'Support Forum',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/extend/plugins/',
    							'link_name' => 'Plugins',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/extend/themes/',
    							'link_name' => 'Themes',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    $default_links[] = array(	'link_url' => 'http://planet.wordpress.org/',
    							'link_name' => 'WordPress Planet',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    foreach ( $default_links as $link ) {
    	$wpdb->insert( $wpdb->links, $link);
    	$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id) );
    }
    */
    // First post (commented out)
    /*
    $now = date('Y-m-d H:i:s');
    $now_gmt = gmdate('Y-m-d H:i:s');
    $first_post_guid = get_option('home') . '/?p=1';
    
    if ( is_multisite() ) {
    	$first_post = get_site_option( 'first_post' );
    
    	if ( empty($first_post) )
    		$first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
    
    	$first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post );
    	$first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
    } else {
    	$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
    }
    
    $wpdb->insert( $wpdb->posts, array(
    							'post_author' => $user_id,
    							'post_date' => $now,
    							'post_date_gmt' => $now_gmt,
    							'post_content' => $first_post,
    							'post_excerpt' => '',
    							'post_title' => __('Hello world!'),
    							// translators: Default post slug
    							'post_name' => sanitize_title( _x('hello-world', 'Default post slug') ),
    							'post_modified' => $now,
    							'post_modified_gmt' => $now_gmt,
    							'guid' => $first_post_guid,
    							'comment_count' => 1,
    							'to_ping' => '',
    							'pinged' => '',
    							'post_content_filtered' => ''
    							));
    $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
    */
    // Default comment (commented out)
    /*
    $first_comment_author = __('Mr WordPress');
    $first_comment_url = 'http://wordpress.org/';
    $first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.');
    if ( is_multisite() ) {
    	$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
    	$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
    	$first_comment = get_site_option( 'first_comment', $first_comment );
    }
    $wpdb->insert( $wpdb->comments, array(
    							'comment_post_ID' => 1,
    							'comment_author' => $first_comment_author,
    							'comment_author_email' => '',
    							'comment_author_url' => $first_comment_url,
    							'comment_date' => $now,
    							'comment_date_gmt' => $now_gmt,
    							'comment_content' => $first_comment
    							));
    */
    // First Page (edited the text and create our Home page)
    $first_page = sprintf(__("This is our home page. Congratulations!"), admin_url());
    if (is_multisite()) {
        $first_page = get_site_option('first_page', $first_page);
    }
    $first_post_guid = get_option('home') . '/?page_id=1';
    $wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'post_title' => __('Home'), 'post_name' => __('home'), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
    $wpdb->insert($wpdb->postmeta, array('post_id' => 1, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
    // Set up default widgets for default theme.
    update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
    update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
    update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
    update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
    update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
    update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
    update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2'), 'sidebar-2' => array(), 'sidebar-3' => array(), 'sidebar-4' => array(), 'sidebar-5' => array(), 'array_version' => 3));
    if (!is_multisite()) {
        update_user_meta($user_id, 'show_welcome_panel', 1);
    } elseif (!is_super_admin($user_id) && !metadata_exists('user', $user_id, 'show_welcome_panel')) {
        update_user_meta($user_id, 'show_welcome_panel', 2);
    }
    if (is_multisite()) {
        // Flush rules to pick up the new page.
        $wp_rewrite->init();
        $wp_rewrite->flush_rules();
        $user = new WP_User($user_id);
        $wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
        // Remove all perms except for the login user.
        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level'));
        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities'));
        // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
        if (!is_super_admin($user_id) && $user_id != 1) {
            $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix . '1_capabilities'));
        }
    }
}
Beispiel #15
0
 /**
  * Manipulate addon.
  *
  * @param   string  $addon   Addon to manipulate.
  * @param   string  $action  Action to execute.
  *
  * @return  array
  */
 protected static function execute($addon, $action)
 {
     // Check capabilities
     foreach (self::$actions as $do => $capability) {
         if ($action == $do && !empty($capability) && !current_user_can($capability)) {
             throw new Exception(__('You do not have sufficient permissions to either add or delete plugins for this site.'));
         }
     }
     // Check if addon should be updated or removed
     if ('update' == $action || 'uninstall' == $action) {
         // Get plugin slug
         $plugin = self::check($addon, false);
         if (empty($plugin)) {
             throw new Exception(__('update' == $action ? 'Cannot detect plugin to be updated.' : 'Cannot detect plugin to be removed.', IG_LIBRARY_TEXTDOMAIN));
         }
     }
     // Check if addon should be removed
     if ('uninstall' == $action) {
         $result = delete_plugins(array($plugin));
         // Verify uninstallation result
         if (is_wp_error($result)) {
             throw new Exception($result->get_error_message());
         }
     } else {
         // Verify authentication data
         $authentication = (bool) $_GET['authentication'];
         $username = isset($_POST['username']) ? $_POST['username'] : '';
         $password = isset($_POST['password']) ? $_POST['password'] : '';
         if ($authentication && (empty($username) || empty($password))) {
             // Check if user has customer account saved
             $customer_account = get_option('ig_customer_account', null);
             if (is_array($customer_account) && !@empty($customer_account['username']) && !@empty($customer_account['password'])) {
                 $username = $customer_account['username'];
                 $password = $customer_account['password'];
             } else {
                 throw new Exception(null);
             }
         }
         // Try to authenticate or download addon installation package
         try {
             $package = self::download($addon, $authentication, $username, $password, 'authenticate' == $action);
         } catch (Exception $e) {
             throw $e;
         }
         // Get WordPress's WordPress Filesystem Abstraction object
         $wp_filesystem = IG_Init_File_System::get_instance();
         // Check if addon should be installed or updated
         if ('authenticate' != $action) {
             // Verify core and add-on compatibility
             if (isset($_GET['core']) && ($core = self::get($_GET['core']))) {
                 // Extract downloaded add-on package
                 $tmp_dir = substr($package, 0, -4);
                 $result = unzip_file($package, $tmp_dir);
                 if (is_wp_error($result)) {
                     throw new Exception($result->get_error_message());
                 }
                 // Find constant definition file
                 if (@is_file("{$tmp_dir}/defines.php")) {
                     include "{$tmp_dir}/defines.php";
                 } elseif (count($defines = glob("{$tmp_dir}/*/defines.php"))) {
                     include current($defines);
                 }
                 // Get minimum core version required for this add-on
                 if (defined($core_version = strtoupper($addon) . '_CORE_VERSION')) {
                     eval('$core_version = ' . $core_version . ';');
                 }
                 if ($core_version && version_compare($core_version, $core['Version'], '>')) {
                     // Delete downloaded add-on package and clean-up temporary directory
                     $wp_filesystem->delete($package);
                     $wp_filesystem->delete($tmp_dir, true);
                     // Skip add-on installation
                     throw new Exception(sprintf(__("Cannot install %1\$s v%2\$s.\nThis version requires %3\$s v%4\$s while you are using %5\$s v%6\$s.", IG_LIBRARY_TEXTDOMAIN), $core['Addons'][$addon]->name, $core['Addons'][$addon]->version, $core['Name'], $core_version, $core['Name'], $core['Version']));
                 }
                 // Verification done, clean-up temporary directory
                 $wp_filesystem->delete($tmp_dir, true);
             }
             // Init WordPress Plugin Upgrader
             class_exists('Plugin_Upgrader') || (include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
             function_exists('screen_icon') || (include_once ABSPATH . 'wp-admin/includes/screen.php');
             function_exists('show_message') || (include_once ABSPATH . 'wp-admin/includes/misc.php');
             function_exists('get_plugin_data') || (include_once ABSPATH . 'wp-admin/includes/plugin.php');
             // Either install or update add-on
             $upgrader = new Plugin_Upgrader();
             if ('install' == $action) {
                 // Install plugin
                 $result = $upgrader->install($package);
                 // Verify installation result
                 if (is_wp_error($result)) {
                     throw new Exception($result->get_error_message());
                 }
             } else {
                 // Update plugin
                 add_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'), 10, 2);
                 add_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'), 10, 4);
                 $upgrader->run(array('package' => $package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin, 'type' => 'plugin', 'action' => 'update')));
                 remove_filter('upgrader_pre_install', array($upgrader, 'deactivate_plugin_before_upgrade'));
                 remove_filter('upgrader_clear_destination', array($upgrader, 'delete_old_plugin'));
                 if (is_wp_error($upgrader->result)) {
                     throw new Exception($upgrader->result->get_error_message());
                 }
                 // Force refresh of plugin update information
                 if (function_exists('wp_clean_plugins_cache')) {
                     wp_clean_plugins_cache(true);
                 }
             }
             // Try to activate plugin
             try {
                 $result = self::activate($addon, $action);
             } catch (Exception $e) {
                 throw $e;
             }
             // Remove downloaded add-on installation package
             $wp_filesystem->delete($package);
         } else {
             // Check if user want to save customer account
             if (isset($_POST['remember']) && (bool) $_POST['remember']) {
                 update_option('ig_customer_account', array('username' => $username, 'password' => $password));
             }
         }
     }
     // Return data
     return is_array($result) ? $result : array('success' => true, 'addon' => $addon, 'action' => $action, 'message' => 'authenticate' == $action ? json_decode($wp_filesystem->get_contents($package)) : null);
 }
/**
 * AJAX handler for deleting a plugin.
 *
 * @since 4.5.0
 */
function wp_ajax_delete_plugin()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug']) || empty($_POST['plugin'])) {
        wp_send_json_error(array('errorCode' => 'no_plugin_specified'));
    }
    $plugin = filter_var(wp_unslash($_POST['plugin']), FILTER_SANITIZE_STRING);
    $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
    $status = array('delete' => 'plugin', 'id' => sanitize_title($plugin_data['Name']), 'slug' => sanitize_key($_POST['slug']), 'plugin' => $plugin);
    if (!current_user_can('delete_plugins')) {
        $status['error'] = __('You do not have sufficient permissions to delete plugins for this site.');
        wp_send_json_error($status);
    }
    if (!is_plugin_inactive($plugin)) {
        $status['error'] = __('You cannot delete a plugin while it is active on the main site.');
        wp_send_json_error($status);
    }
    $delete_result = delete_plugins(array($plugin));
    if (is_wp_error($delete_result)) {
        $status['error'] = $delete_result->get_error_message();
        wp_send_json_error($status);
    } else {
        if (is_null($delete_result)) {
            global $wp_filesystem;
            $status['errorCode'] = 'unable_to_connect_to_filesystem';
            $status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
            // Pass through the error from WP_Filesystem if one was raised.
            if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
                $status['error'] = $wp_filesystem->errors->get_error_message();
            }
            wp_send_json_error($status);
        } elseif (false === $delete_result) {
            $status['error'] = __('Plugin could not be deleted.');
            wp_send_json_error($status);
        }
    }
    wp_send_json_success($status);
}
Beispiel #17
0
 /**
  * ciao_dolly
  * Deletes the Hello Dolly plugin.
  *
  * @since 1.0.0
  * @version 1.0.0
  **/
 public function ciao_dolly()
 {
     if (file_exists(plugin_dir_path('/hello.php'))) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
         require_once ABSPATH . 'wp-admin/includes/file.php';
         delete_plugins(array('hello.php'));
         // Set message.
         $this->messages[] = __('The hello dolly plugin has been removed', 'framework');
     }
 }
Beispiel #18
0
 /**
  * Delete a plugin
  *
  * @param array $args
  */
 function delete($args)
 {
     list($file, $name) = $this->parse_name($args, __FUNCTION__);
     if (!delete_plugins(array($file))) {
         WP_CLI::error('There was an error while deleting the plugin.');
     }
 }
Beispiel #19
0
<?php

/**
 *
 * Uninstalling IG PageBuilder: deletes post metas & options
 *
 * @author		InnoGears Team <*****@*****.**>
 * @package		IGPGBLDR
 * @version		$Id$
 */
//if uninstall not called from WordPress exit
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}
include_once 'core/utils/common.php';
// delete all other providers
$providers = get_transient('_ig_pb_providers');
if ($providers) {
    $providers = unserialize($providers);
    $list_plugins = array();
    foreach ($providers as $provider) {
        if (!empty($provider['file'])) {
            $list_plugins[] = $provider['file'];
        }
    }
    delete_plugins($list_plugins);
}
// delete cache folder
IG_Pb_Utils_Common::remove_cache_folder();
// delete meta key
IG_Pb_Utils_Common::delete_meta_key(array('_ig_page_builder_content', '_ig_html_content', '_ig_page_active_tab', '_ig_post_view_count', '_ig_deactivate_pb', '_ig_page_builder_css_files', '_ig_page_builder_css_custom'));
 function remove_plugin()
 {
     delete_plugins(array('wp-super-cache/wp-cache.php'));
     wp_cache_delete('plugins', 'plugins');
 }
Beispiel #21
0
 public function edit_plugins($args)
 {
     extract($args);
     $return = array();
     foreach ($items as $item) {
         switch ($items_edit_action) {
             case 'activate':
                 $result = activate_plugin($item['path']);
                 break;
             case 'deactivate':
                 $result = deactivate_plugins(array($item['path']));
                 break;
             case 'delete':
                 $result = delete_plugins(array($item['path']));
                 break;
             default:
                 break;
         }
         if (is_wp_error($result)) {
             $result = array('error' => $result->get_error_message());
         } elseif ($result === false) {
             $result = array('error' => "Failed to perform action.");
         } else {
             $result = "OK";
         }
         $return[$item['name']] = $result;
     }
     return $return;
 }
/**
 * Data validation for rtPanel General Options
 * 
 * @uses $rtp_general array
 * @return Array
 *
 * @since rtPanel 2.0
 * @param Array $input Non-validated data
 */
function rtp_general_validate($input)
{
    global $rtp_general;
    require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
    require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
    @($file_object = new WP_Filesystem_Direct());
    $default = rtp_theme_setup_values();
    if (isset($_POST['rtp_submit'])) {
        add_filter('intermediate_image_sizes_advanced', 'rtp_create_favicon');
        if ('image' == $input['logo_use'] && !empty($_FILES) && isset($_FILES['html-upload-logo']) && $_FILES['html-upload-logo']['size']) {
            if (substr($_FILES['html-upload-logo']['type'], 0, 5) == 'image') {
                $id = media_handle_upload('html-upload-logo', 0);
                if (is_wp_error($id)) {
                    if (!empty($id->errors['upload_error'])) {
                        $logo_errors = $id->errors['upload_error'];
                    }
                    if (!empty($logo_errors)) {
                        foreach ($logo_errors as $logo_error) {
                            add_settings_error('html-upload-logo', 'html-upload-logo', $logo_error, 'error');
                        }
                    }
                } else {
                    $img_src = wp_get_attachment_image_src($id, 'full', true);
                    $input['logo_upload'] = $img_src[0];
                    $input['logo_id'] = $id;
                    $input['logo_width'] = $img_src[1];
                    $input['logo_height'] = $img_src[2];
                    add_settings_error('html-upload-logo', 'html-upload-logo', __('Logo & Favicon Settings Updated', 'rtPanel'), 'updated');
                }
            } else {
                add_settings_error('html-upload-logo', 'html-upload-logo', __('Please upload a valid image file.', 'rtPanel'), 'error');
            }
        }
        if ('image' == $input['favicon_use'] && !empty($_FILES) && isset($_FILES['html-upload-fav']) && $_FILES['html-upload-fav']['size']) {
            // Upload File button was clicked
            if (substr($_FILES['html-upload-fav']['type'], 0, 5) == 'image') {
                $id = media_handle_upload('html-upload-fav', 0);
                if (is_wp_error($id)) {
                    if (!empty($id->errors['upload_error'])) {
                        $fav_errors = $id->errors['upload_error'];
                    }
                    if (!empty($fav_errors)) {
                        foreach ($fav_errors as $fav_error) {
                            add_settings_error('html-upload-fav', 'html-upload-fav', $fav_error, 'error');
                        }
                    }
                } else {
                    $img_src = wp_get_attachment_image_src($id, 'favicon', true);
                    $input['favicon_upload'] = $img_src[0];
                    $input['favicon_id'] = $id;
                    add_settings_error('html-upload-fav', 'html-upload-fav', __('Logo & Favicon Settings Updated', 'rtPanel'), 'updated');
                }
            } else {
                add_settings_error('html-upload-fav', 'html-upload-fav', __('Please upload a valid image file.', 'rtPanel'), 'error');
            }
        } elseif ('logo' == $input['favicon_use']) {
            if (RTP_IMG_FOLDER_URL . '/rtp-logo.png' == $input['logo_upload']) {
                $input['favicon_upload'] = RTP_IMG_FOLDER_URL . '/favicon.ico';
                $input['favicon_id'] = 0;
            } else {
                $img_src = wp_get_attachment_image_src($input['logo_id'], 'favicon', true);
                $input['favicon_upload'] = $img_src[0];
                $input['favicon_id'] = $input['logo_id'];
            }
        }
        remove_filter('intermediate_image_sizes_advanced', 'rtp_create_favicon');
        if ('image' != $input['logo_use']) {
            $input['login_head'] = $rtp_general['login_head'];
        }
        if (!empty($input['search_code'])) {
            if (!preg_match('/customSearchControl.draw\\(\'cse\'(.*)\\)\\;/i', $input['search_code']) && !preg_match('/\\<gcse:(searchresults-only|searchresults|search).*\\>\\<\\/gcse:(searchresults-only|searchresults|search)\\>/i', $input['search_code'])) {
                $input['search_code'] = $rtp_general['search_code'];
                add_settings_error('search_code', 'invalid_search_code', __('Google Search Code Error : While generating the code the layout option should either be "full-width" or "compact". The changes made have been reverted.', 'rtPanel'));
            } elseif ($input['search_code'] != $rtp_general['search_code']) {
                add_settings_error('search_code', 'valid_search_code', __('Google Custom Search Integration has been updated.', 'rtPanel'), 'updated');
            }
        }
        /**
         * rtSocial Plugin
         */
        if (isset($_POST['rtsocial-activate']) && $_POST['rtsocial-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtsocial_activate'];
            if (!wp_verify_nonce($nonce, RTP_SOCIAL . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_SOCIAL);
                add_settings_error('activate-plugin', 'plugin_activation', __('rtSocial has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtsocial-deactivate']) && $_POST['rtsocial-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtsocial_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_SOCIAL . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_SOCIAL));
                add_settings_error('deactivate-plugin', 'plugin_activation', __('rtSocial has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtsocial-delete']) && $_POST['rtsocial-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtsocial_delete'];
            if (!wp_verify_nonce($nonce, RTP_SOCIAL . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_SOCIAL));
                add_settings_error('delete-plugin', 'plugin_deletion', __('rtSocial has been Deleted.', 'rtPanel'), 'updated');
            }
        }
        /**
         * rtWidgets Plugin
         */
        if (isset($_POST['rtwidgets-activate']) && $_POST['rtwidgets-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtwidgets_activate'];
            if (!wp_verify_nonce($nonce, RTP_RTWIDGETS . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_RTWIDGETS);
                add_settings_error('activate-plugin', 'plugin_activation', __('rtWidgets has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtwidgets-deactivate']) && $_POST['rtwidgets-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtwidgets_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_RTWIDGETS . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_RTWIDGETS));
                add_settings_error('deactivate-plugin', 'plugin_activation', __('rtWidgets has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtwidgets-delete']) && $_POST['rtwidgets-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtwidgets_delete'];
            if (!wp_verify_nonce($nonce, RTP_RTWIDGETS . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_RTWIDGETS));
                add_settings_error('delete-plugin', 'plugin_deletion', __('rtWidgets has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtp-hooks-editor-activate']) && $_POST['rtp-hooks-editor-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtp_hooks_editor_activate'];
            if (!wp_verify_nonce($nonce, RTP_HOOKS_EDITOR . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_HOOKS_EDITOR);
                add_settings_error('activate-plugin', 'plugin_activation', __('rtPanel Hooks Editor Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtp-hooks-editor-deactivate']) && $_POST['rtp-hooks-editor-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtp_hooks_editor_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_HOOKS_EDITOR . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_HOOKS_EDITOR));
                add_settings_error('deactivate-plugin', 'plugin_activation', __('rtPanel Hooks Editor Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtp-hooks-editor-delete']) && $_POST['rtp-hooks-editor-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtp_hooks_editor_delete'];
            if (!wp_verify_nonce($nonce, RTP_HOOKS_EDITOR . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_HOOKS_EDITOR));
                add_settings_error('delete-plugin', 'plugin_deletion', __('rtPanel Hooks Editor Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['subscribe-activate']) && $_POST['subscribe-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_subscribe_activate'];
            if (!wp_verify_nonce($nonce, RTP_SUBSCRIBE_TO_COMMENTS . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_SUBSCRIBE_TO_COMMENTS);
                add_settings_error('activate-plugin', 'plugin_activation', __('Subscribe To Comments Reloaded Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['subscribe-deactivate']) && $_POST['subscribe-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_subscribe_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_SUBSCRIBE_TO_COMMENTS . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_SUBSCRIBE_TO_COMMENTS));
                add_settings_error('deactivate-plugin', 'plugin_activation', __('Subscribe To Comments Reloaded Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['subscribe-delete']) && $_POST['subscribe-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_subscribe_delete'];
            if (!wp_verify_nonce($nonce, RTP_SUBSCRIBE_TO_COMMENTS . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_SUBSCRIBE_TO_COMMENTS));
                add_settings_error('delete-plugin', 'plugin_deletion', __('Subscribe To Comments Reloaded Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['yoast_seo-activate']) && $_POST['yoast_seo-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_yoast_seo_activate'];
            if (!wp_verify_nonce($nonce, RTP_YOAST_SEO . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_YOAST_SEO);
                add_settings_error('activate-plugin', 'plugin_activation', __('Yoast WordPress SEO Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['yoast_seo-deactivate']) && $_POST['yoast_seo-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_yoast_seo_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_YOAST_SEO . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_YOAST_SEO));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('Yoast WordPress SEO Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['yoast_seo-delete']) && $_POST['yoast_seo-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_yoast_seo_delete'];
            if (!wp_verify_nonce($nonce, RTP_YOAST_SEO . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_YOAST_SEO));
                add_settings_error('delete-plugin', 'plugin_deletion', __('Yoast WordPress SEO Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtmedia-activate']) && $_POST['rtmedia-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtmedia_activate'];
            if (!wp_verify_nonce($nonce, RTP_MEDIA . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_MEDIA);
                add_settings_error('activate-plugin', 'plugin_activation', __('rtMedia for WordPress, BuddyPress and bbPress Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtmedia-deactivate']) && $_POST['rtmedia-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtmedia_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_MEDIA . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_MEDIA));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('rtMedia for WordPress, BuddyPress and bbPress Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['rtmedia-delete']) && $_POST['rtmedia-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_rtmedia_delete'];
            if (!wp_verify_nonce($nonce, RTP_MEDIA . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_MEDIA));
                add_settings_error('delete-plugin', 'plugin_deletion', __('rtMedia for WordPress, BuddyPress and bbPress Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['bbpress-activate']) && $_POST['bbpress-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_bbpress_activate'];
            if (!wp_verify_nonce($nonce, RTP_BBPRESS . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_BBPRESS);
                add_settings_error('activate-plugin', 'plugin_activation', __('bbPress Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['bbpress-deactivate']) && $_POST['bbpress-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_bbpress_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_BBPRESS . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_BBPRESS));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('bbPress Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['bbpress-delete']) && $_POST['bbpress-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_bbpress_delete'];
            if (!wp_verify_nonce($nonce, RTP_BBPRESS . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_BBPRESS));
                add_settings_error('delete-plugin', 'plugin_deletion', __('bbPress Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['buddypress-activate']) && $_POST['buddypress-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_buddypress_activate'];
            if (!wp_verify_nonce($nonce, RTP_BUDDYPRESS . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_BUDDYPRESS);
                add_settings_error('activate-plugin', 'plugin_activation', __('BuddyPress Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['buddypress-deactivate']) && $_POST['buddypress-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_buddypress_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_BUDDYPRESS . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_BUDDYPRESS));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('BuddyPress Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['buddypress-delete']) && $_POST['buddypress-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_buddypress_delete'];
            if (!wp_verify_nonce($nonce, RTP_BUDDYPRESS . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_BUDDYPRESS));
                add_settings_error('delete-plugin', 'plugin_deletion', __('BuddyPress Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['cf7-activate']) && $_POST['cf7-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_cf7_activate'];
            if (!wp_verify_nonce($nonce, RTP_CF7 . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_CF7);
                add_settings_error('activate-plugin', 'plugin_activation', __('Contact Form 7 Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['cf7-deactivate']) && $_POST['cf7-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_cf7_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_CF7 . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_CF7));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('Contact Form 7 Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['cf7-delete']) && $_POST['cf7-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_cf7_delete'];
            if (!wp_verify_nonce($nonce, RTP_CF7 . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_CF7));
                add_settings_error('delete-plugin', 'plugin_deletion', __('Contact Form 7 Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['jetpack-activate']) && $_POST['jetpack-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_jetpack_activate'];
            if (!wp_verify_nonce($nonce, RTP_JETPACK . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_JETPACK);
                add_settings_error('activate-plugin', 'plugin_activation', __('Jetpack by WordPress.com Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['jetpack-deactivate']) && $_POST['jetpack-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_jetpack_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_JETPACK . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_JETPACK));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('Jetpack by WordPress.com Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['jetpack-delete']) && $_POST['jetpack-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_jetpack_delete'];
            if (!wp_verify_nonce($nonce, RTP_JETPACK . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_JETPACK));
                add_settings_error('delete-plugin', 'plugin_deletion', __('Jetpack by WordPress.com Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['ninja_form-activate']) && $_POST['ninja_form-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_ninja_form_activate'];
            if (!wp_verify_nonce($nonce, RTP_NINJA_FORM . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_NINJA_FORM);
                add_settings_error('activate-plugin', 'plugin_activation', __('Ninja Forms Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['ninja_form-deactivate']) && $_POST['ninja_form-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_ninja_form_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_NINJA_FORM . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_NINJA_FORM));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('Ninja Forms Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['ninja_form-delete']) && $_POST['ninja_form-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_ninja_form_delete'];
            if (!wp_verify_nonce($nonce, RTP_NINJA_FORM . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_NINJA_FORM));
                add_settings_error('delete-plugin', 'plugin_deletion', __('Ninja Forms Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['woocommerce-activate']) && $_POST['woocommerce-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_woocommerce_activate'];
            if (!wp_verify_nonce($nonce, RTP_WOOCOMMERCE . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_WOOCOMMERCE);
                add_settings_error('activate-plugin', 'plugin_activation', __('WooCommerce - excelling eCommerce Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['woocommerce-deactivate']) && $_POST['woocommerce-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_woocommerce_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_WOOCOMMERCE . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_WOOCOMMERCE));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('WooCommerce - excelling eCommerce Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['woocommerce-delete']) && $_POST['woocommerce-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_woocommerce_delete'];
            if (!wp_verify_nonce($nonce, RTP_WOOCOMMERCE . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_WOOCOMMERCE));
                add_settings_error('delete-plugin', 'plugin_deletion', __('WooCommerce - excelling eCommerce Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['yarpp-activate']) && $_POST['yarpp-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_yarpp_activate'];
            if (!wp_verify_nonce($nonce, RTP_YARPP . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_YARPP);
                add_settings_error('activate-plugin', 'plugin_activation', __('Yet Another Related Posts Plugin (YARPP) has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['yarpp-deactivate']) && $_POST['yarpp-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_yarpp_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_YARPP . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_YARPP));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('Yet Another Related Posts Plugin (YARPP) has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['yarpp-delete']) && $_POST['yarpp-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_yarpp_delete'];
            if (!wp_verify_nonce($nonce, RTP_YARPP . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_YARPP));
                add_settings_error('delete-plugin', 'plugin_deletion', __('Yet Another Related Posts Plugin (YARPP) has been Deleted.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['regenerate-activate']) && $_POST['regenerate-activate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_regenerate_activate'];
            if (!wp_verify_nonce($nonce, RTP_REGENERATE_THUMBNAILS . '-activate')) {
                add_settings_error('activate-plugin', 'failure_plugin_activation', __('You do not have sufficient permissions to activate this plugin.', 'rtPanel'));
            } else {
                activate_plugin(RTP_REGENERATE_THUMBNAILS);
                add_settings_error('activate-plugin', 'plugin_activation', __('Regenerate Thumbnails Plugin has been Activated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['regenerate-deactivate']) && $_POST['regenerate-deactivate'] == 1) {
            $nonce = $_REQUEST['_wpnonce_regenerate_deactivate'];
            if (!wp_verify_nonce($nonce, RTP_REGENERATE_THUMBNAILS . '-deactivate')) {
                add_settings_error('deactivate-plugin', 'failure_plugin_deactivation', __('You do not have sufficient permissions to deactivate this plugin.', 'rtPanel'));
            } else {
                deactivate_plugins(array(RTP_REGENERATE_THUMBNAILS));
                add_settings_error('deactivate-plugin', 'plugin_deactivation', __('Regenerate Thumbnails Plugin has been Deactivated.', 'rtPanel'), 'updated');
            }
        } elseif (isset($_POST['regenerate-delete']) && $_POST['regenerate-delete'] == 1) {
            $nonce = $_REQUEST['_wpnonce_regenerate_delete'];
            if (!wp_verify_nonce($nonce, RTP_REGENERATE_THUMBNAILS . '-delete')) {
                add_settings_error('delete-plugin', 'failure_plugin_deletion', __('You do not have sufficient permissions to delete this plugin.', 'rtPanel'));
            } else {
                delete_plugins(array(RTP_REGENERATE_THUMBNAILS));
                add_settings_error('delete-plugin', 'plugin_deletion', __('Regenerate Thumbnails Plugin has been Deleted.', 'rtPanel'), 'updated');
            }
        }
    } elseif (isset($_POST['rtp_logo_favicon_reset'])) {
        $options = maybe_unserialize($rtp_general);
        unset($input);
        foreach ($options as $option => $value) {
            $input[$option] = $value;
        }
        $input['logo_use'] = $default[0]['logo_use'];
        $input['logo_upload'] = $default[0]['logo_upload'];
        $input['logo_id'] = $default[0]['logo_id'];
        $input['logo_width'] = $default[0]['logo_width'];
        $input['logo_height'] = $default[0]['logo_height'];
        $input['login_head'] = $default[0]['login_head'];
        $input['favicon_use'] = $default[0]['favicon_use'];
        $input['favicon_upload'] = $default[0]['favicon_upload'];
        $input['favicon_id'] = $default[0]['favicon_id'];
        add_settings_error('logo_favicon_settings', 'logo_favicon_reset', __('The Logo Settings have been restored to Default.', 'rtPanel'), 'updated');
    } elseif (isset($_POST['rtp_google_reset'])) {
        $options = maybe_unserialize($rtp_general);
        unset($input);
        foreach ($options as $option => $value) {
            $input[$option] = $value;
        }
        $input['search_code'] = $default[0]['search_code'];
        $input['search_layout'] = $default[0]['search_layout'];
        add_settings_error('search_code', 'reset_search_code', __('The Google Custom Search Integration has been restored to Default.', 'rtPanel'), 'updated');
    } elseif (isset($_POST['rtp_sidebar_reset'])) {
        $options = maybe_unserialize($rtp_general);
        unset($input);
        foreach ($options as $option => $value) {
            $input[$option] = $value;
        }
        $input['footer_sidebar'] = $default[0]['footer_sidebar'];
        $input['buddypress_sidebar'] = $default[0]['buddypress_sidebar'];
        $input['bbpress_sidebar'] = $default[0]['bbpress_sidebar'];
        add_settings_error('sidebar', 'reset_sidebar', __('The Sidebar Settings have been restored to Default.', 'rtPanel'), 'updated');
    } elseif (isset($_POST['rtp_custom_styles_reset'])) {
        $options = maybe_unserialize($rtp_general);
        unset($input);
        foreach ($options as $option => $value) {
            $input[$option] = $value;
        }
        $input['custom_styles'] = $default[0]['custom_styles'];
        add_settings_error('custom_styles', 'reset_custom_styles', __('Custom Styles has been restored to Default.', 'rtPanel'), 'updated');
    } elseif (isset($_POST['rtp_export'])) {
        rtp_export();
        die;
    } elseif (isset($_POST['rtp_import'])) {
        $general = rtp_import($_FILES['rtp_import']);
        if ($general && $general != 'ext') {
            unset($input);
            $input = maybe_unserialize($general);
            add_settings_error('rtp_import', 'import', __('rtPanel Options have been imported successfully', 'rtPanel'), 'updated');
        } elseif ($general == 'ext') {
            add_settings_error('rtp_import', 'no_import', __('Not a valid RTP file', 'rtPanel'));
        } else {
            add_settings_error('rtp_import', 'no_import', __('The file is corrupt. There was an error while importing. Please Try Again', 'rtPanel'));
        }
    } elseif (isset($_POST['rtp_reset'])) {
        $input = $default[0];
        add_settings_error('rtp_general', 'reset_general_options', __('All the rtPanel General Settings have been restored to default.', 'rtPanel'), 'updated');
    }
    return $input;
    // Return validated input.
}
Beispiel #23
0
 public static function ajax_manage_perk()
 {
     $request = parse_url(gwpost('request_url'));
     parse_str(gwar($request, 'query'), $request);
     if (empty($request)) {
         GWPerks::json_and_die(array('error' => __('There was an error managing this perk.', 'gravityperks')));
     }
     $action = gwar($request, 'action');
     $plugin = gwar($request, 'plugin');
     $_REQUEST['_wpnonce'] = gwar($request, '_wpnonce');
     // use some of WPs default plugin management functionality
     // @see wp-admin/plugins.php
     switch ($action) {
         case 'activate':
             if (!current_user_can('activate_plugins')) {
                 wp_die(__('You do not have sufficient permissions to activate plugins for this site.', 'gravityperks'));
             }
             check_admin_referer('activate-plugin_' . $plugin);
             $result = activate_plugin($plugin, null, is_network_admin());
             if (is_wp_error($result)) {
                 if ('unexpected_output' == $result->get_error_code()) {
                     $error_data = $result->get_error_data();
                 } else {
                     $error_data = $result;
                 }
                 GWPerks::json_and_die(array('error' => __('There was an error activating this perk.', 'gravityperks'), 'error_data' => $error_data));
             }
             if (!is_network_admin()) {
                 $recent = (array) get_option('recently_activated');
                 unset($recent[$plugin]);
                 update_option('recently_activated', $recent);
             }
             $perk_data = GWPerk::get_perk_data($plugin);
             GWPerks::json_and_die(array('success' => 1, 'listing_html' => self::get_perk_listing($plugin, $perk_data, true)));
             break;
         case 'deactivate':
             if (!current_user_can('activate_plugins')) {
                 wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.', 'gravityperks'));
             }
             check_admin_referer('deactivate-plugin_' . $plugin);
             if (!is_network_admin() && is_plugin_active_for_network($plugin)) {
                 GWPerks::json_and_die(array('error' => __('This perk can only be managed from the network admin\'s Plugins page.', 'gravityperks')));
             }
             deactivate_plugins($plugin, false, is_network_admin());
             if (!is_network_admin()) {
                 update_option('recently_activated', array($plugin => time()) + (array) get_option('recently_activated'));
             }
             $perk_data = GWPerk::get_perk_data($plugin);
             GWPerks::json_and_die(array('success' => 1, 'listing_html' => self::get_perk_listing($plugin, $perk_data, true)));
             break;
         case 'uninstall':
             if (!current_user_can('delete_plugins')) {
                 wp_die(__('You do not have sufficient permissions to delete plugins for this site.', 'gravityperks'));
             }
             check_admin_referer('uninstall-plugin_' . $plugin);
             deactivate_plugins($plugin, true);
             $perk = GWPerk::get_perk($plugin);
             $perk->uninstall();
             $result = delete_plugins(array($plugin));
             if ($result) {
                 $response = json_encode(array('success' => 1, 'listing_html' => ''));
             } else {
                 $response = __('ERROR');
             }
             die($response);
             break;
     }
     GWPerks::json_and_die(array('error' => __('There was an error managing this perk.', 'gravityperks')));
 }
 /**
  * Deletes almost all database data and asset cache for the builder.
  * We don't delete _fl_builder_enabled, _fl_builder_data and _fl_builder_draft
  * so layouts can be recovered should the plugin be installed again.
  *
  * @since 1.0
  * @return void
  */
 public static function uninstall_database()
 {
     if (current_user_can('delete_plugins')) {
         // Delete builder options.
         delete_option('_fl_builder_settings');
         delete_option('_fl_builder_enabled_modules');
         delete_option('_fl_builder_enabled_templates');
         delete_option('_fl_builder_user_templates_admin');
         delete_option('_fl_builder_templates_override');
         delete_option('_fl_builder_templates_override_rows');
         delete_option('_fl_builder_templates_override_modules');
         delete_option('_fl_builder_post_types');
         delete_option('_fl_builder_enabled_icons');
         delete_option('_fl_builder_branding');
         delete_option('_fl_builder_branding_icon');
         delete_option('_fl_builder_theme_branding');
         delete_option('_fl_builder_editing_capability');
         delete_option('_fl_builder_global_templates_editing_capability');
         delete_option('_fl_builder_help_button');
         delete_option('_fl_builder_color_presets');
         // Delete builder user meta.
         delete_metadata('user', 0, '_fl_builder_launched', 1, true);
         // Delete uploaded files and folders.
         $upload_dir = self::get_upload_dir();
         $filesystem = FLBuilderUtils::get_filesystem();
         $filesystem->rmdir($upload_dir['path'], true);
         // Deactivate and delete the plugin.
         deactivate_plugins(array(self::plugin_basename()), false, is_network_admin());
         delete_plugins(array(self::plugin_basename()));
         // Redirect to the plugins page.
         wp_redirect(admin_url('plugins.php?deleted=true&plugin_status=all&paged=1&s='));
         exit;
     }
 }
Beispiel #25
0
 function delete($args)
 {
     $this->_escape($args);
     $username = $args[0];
     $password = $args[1];
     $plugin_files = $args[2];
     if ($password != get_option('wpr_cron')) {
         if (!($user = $this->login($username, $password))) {
             return $this->error;
         }
         if (!current_user_can('delete_plugins')) {
             return new IXR_Error(401, 'Sorry, you cannot manage plugins on the remote blog.');
         }
     }
     $this->refresh_transient();
     ob_start();
     if (!is_array($plugin_files)) {
         $plugin_files = array($plugin_files);
     }
     $result = delete_plugins($plugin_files);
     ob_end_clean();
     if (is_wp_error($result)) {
         return new IXR_Error(401, 'Sorry, this plugin could not be deleted. ' . $result->get_error_message());
     }
     return TRUE;
 }
Beispiel #26
0
 private function uninstall_plugins($plugins)
 {
     require_once ABSPATH . '/wp-admin/includes/file.php';
     // First ensure that the plugins are deactivated.
     $this->deactivate_plugins($plugins);
     return delete_plugins((array) $plugins);
 }
Beispiel #27
0
				<div id="files-list" style="display:none;">
					<ul class="code">
					<?php 
                foreach ((array) $files_to_delete as $file) {
                    echo '<li>' . esc_html(str_replace(WP_PLUGIN_DIR, '', $file)) . '</li>';
                }
                ?>
					</ul>
				</div>
			</div>
				<?php 
                require_once ABSPATH . 'wp-admin/admin-footer.php';
                exit;
            }
            //Endif verify-delete
            $delete_result = delete_plugins($plugins);
            set_transient('plugins_delete_result_' . $user_ID, $delete_result);
            //Store the result in a cache rather than a URL param due to object type & length
            wp_redirect(self_admin_url("plugins.php?deleted=true&plugin_status={$status}&paged={$page}&s={$s}"));
            exit;
        case 'clear-recent-list':
            if (!is_network_admin()) {
                update_option('recently_activated', array());
            }
            break;
    }
}
$wp_list_table->prepare_items();
wp_enqueue_script('plugin-install');
add_thickbox();
add_screen_option('per_page', array('default' => 999));
Beispiel #28
0
 /**
  * We handle all the actions here
  * @return void
  */
 function handle_actions()
 {
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     // Need for upgrade classes.
     // we get current installed plugins
     $current = get_option('active_plugins');
     if ('install' === $this->current_action()) {
         require_once 'class-wpfavs-plugin-installer-skin.php';
         // Needed for installs.
         // Install a single plugin
         if (!isset($_POST['plugin']) && isset($_GET['plugin_id']) && 'install' == $_GET['action']) {
             // Create a new instance of Plugin_Upgrader.
             $upgrader = new Plugin_Upgrader($skin = new WpFavs_Plugin_Installer_Skin());
             // Perform the action and install the plugin from wordpress.org
             $upgrader->install($this->plugins[$_GET['plugin_id']]['dlink']);
             //We change status
             $this->plugins[$_GET['plugin_id']]['status'] = 'inactive';
         }
         //Install Bulk
         if (isset($_POST['plugin'])) {
             //We update status
             foreach ($this->plugins as $plugin_id => $plugin) {
                 //We check if the plugin is installed (if is not installed we cannot uninstall it)
                 if (in_array($plugin_id, $_POST['plugin']) && 'not-installed' == $plugin['status']) {
                     // Create a new instance of Plugin_Upgrader.
                     $upgrader = new Plugin_Upgrader($skin = new WpFavs_Plugin_Installer_Skin(array('multi' => 'true')));
                     // Perform the action and install the plugin from wordpress.org
                     $upgrader->install($this->plugins[$plugin_id]['dlink']);
                     $this->plugins[$plugin_id]['status'] = 'inactive';
                 }
             }
         }
         // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
         wp_cache_flush();
     }
     if ('activate' === $this->current_action()) {
         // Activate a single plugin
         if (!isset($_POST['plugin']) && isset($_GET['plugin_id']) && 'activate' == $_GET['action']) {
             activate_plugins($this->plugins[$_GET['plugin_id']]['file_path']);
             //We change status
             $this->plugins[$_GET['plugin_id']]['status'] = 'active';
         }
         //Activate Bulk
         if (isset($_POST['plugin'])) {
             activate_plugins($_POST['plugin']);
             //We update status
             foreach ($this->plugins as $plugin_id => $plugin) {
                 //We check if the plugin is inactive (if is not installed we cannot activate it)
                 if (in_array($plugin['file_path'], $_POST['plugin']) && 'inactive' == $plugin['status']) {
                     $this->plugins[$plugin_id]['status'] = 'active';
                 }
             }
         }
         // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
         wp_cache_flush();
     }
     if ('deactivate' === $this->current_action()) {
         // Deactivate a single plugin
         if (!isset($_POST['plugin']) && isset($_GET['plugin_id']) && 'deactivate' == $_GET['action']) {
             deactivate_plugins($this->plugins[$_GET['plugin_id']]['file_path']);
             //We change status
             $this->plugins[$_GET['plugin_id']]['status'] = 'inactive';
         }
         //Deactivate Bulk
         if (isset($_POST['plugin'])) {
             $this->deactive_bulk($_POST['plugin']);
         }
         // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
         wp_cache_flush();
     }
     if ('delete' === $this->current_action()) {
         // Delete a single plugin
         if (!isset($_POST['plugin']) && isset($_GET['plugin_id']) && 'delete' == $_GET['action']) {
             delete_plugins(array($this->plugins[$_GET['plugin_id']]['file_path']));
             //We change status
             $this->plugins[$_GET['plugin_id']]['status'] = 'not-installed';
         }
         // Delete Bulk
         if (isset($_POST['plugin'])) {
             $this->deactive_bulk($_POST['plugin']);
             @delete_plugins($_POST['plugin']);
             //We update status
             foreach ($this->plugins as $plugin_id => $plugin) {
                 //We check if the plugin is inactive (if is not inactive we cannot uninstall it)
                 if (in_array($plugin['file_path'], $_POST['plugin']) && 'inactive' == $plugin['status']) {
                     $this->plugins[$plugin_id]['status'] = 'not-installed';
                 }
             }
         }
         // Flush plugins cache so we can make sure that the installed plugins list is always up to date.
         wp_cache_flush();
     }
 }