$theme->get('Name'), 'theme_author' => $theme->get('Author'), 'theme_demo_route_url' => 'https://demo.sharkthemes.com/barenote/', 'theme_version' => 'free', 'theme_quick_links' => array( array( 'label' => esc_html__('View Details', 'barenote'), 'url' => 'https://www.sharkthemes.com/downloads/barenote/', ), array( 'label' => esc_html__('Documentation', 'barenote'), 'url' => 'https://www.sharkthemes.com/docs/fse-documentation/', ), array( 'label' => esc_html__('Upgrade to Pro', 'barenote'), 'url' => 'https://www.sharkthemes.com/downloads/barenote-pro/', ), ), ); return $args; } endif; add_filter('wpopus_theme_constant_filter', 'barenote_theme_constant'); // show admin notice if (!function_exists('barenote_admin_notice')) { function barenote_admin_notice() { // Check if we're on the dashboard/index.php $screen = get_current_screen(); if ($screen->id !== 'dashboard') { return; } if (!current_user_can('manage_options')) { return; } // return if plugin exists if (function_exists('wpopus_pro') || function_exists('wpopus')) { return; } $theme = wp_get_theme(); ?>
admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('install_wpopus_nonce'), 'label' => esc_html__('Install and Activate', 'barenote'), 'success_label' => esc_html__('Installed and Activated', 'barenote'), ]); } add_action('admin_enqueue_scripts', 'barenote_admin_enqueue_scripts'); // install and activate wpopus function barenote_install_and_activate_plugin() { // Check if the current user has the capability to manage options if (!current_user_can('manage_options')) { wp_send_json_error(['message' => esc_html__('You are not authorized to perform this action.', 'barenote')]); } // Verify if the nonce is set and valid if (!isset($_POST['nonce'])) { wp_send_json_error(['message' => esc_html__('Nonce is missing.', 'barenote')]); } check_ajax_referer('install_wpopus_nonce', 'nonce'); include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . 'wp-admin/includes/plugin.php'; $plugin_slug = 'wpopus'; $plugin_file = $plugin_slug . '/' . $plugin_slug . '.php'; // Check if the plugin exists in the plugins directory if (file_exists(WP_PLUGIN_DIR . '/' . $plugin_file)) { // Plugin exists, activate it $activate = activate_plugin($plugin_file); if (is_wp_error($activate)) { wp_send_json_error(['message' => $activate->get_error_message()]); } wp_send_json_success(['message' => esc_html__('wpOpus activated successfully!', 'barenote')]); } // Plugin does not exist, proceed to install it $api = plugins_api('plugin_information', ['slug' => $plugin_slug]); if (is_wp_error($api)) { wp_send_json_error(['message' => $api->get_error_message()]); } $upgrader = new Plugin_Upgrader(); $result = $upgrader->install($api->download_link); if (is_wp_error($result)) { wp_send_json_error(['message' => $result->get_error_message()]); } // Activate the plugin after installation $activate = activate_plugin($plugin_file); if (is_wp_error($activate)) { wp_send_json_error(['message' => $activate->get_error_message()]); } wp_send_json_success(['message' => esc_html__('wpOpus installed and activated successfully!', 'barenote')]); } add_action('wp_ajax_install_wpopus_plugin', 'barenote_install_and_activate_plugin');