tag. */ do_action('wp_body_open'); } } add_action('after_setup_theme', 'busiprof_agency_setup'); function busiprof_agency_setup() { load_theme_textdomain('busiprof-agency', BUSIPROF_AGENCY_TEMPLATE_DIR . '/languages'); //About Theme $theme = wp_get_theme(); // gets the current theme if ('Busiprof Agency' == $theme->name) { if (is_admin()) { require BUSIPROF_AGENCY_TEMPLATE_DIR . '/admin/admin-init.php'; } } add_theme_support('automatic-feed-links'); add_theme_support('title-tag'); } add_action('after_switch_theme', 'busiprof_agency_import_data_in_busiprof_child_theme'); /** * Import theme mods when switching from Busiprof child theme to Busiprof */ function busiprof_agency_import_data_in_busiprof_child_theme() { // Get the name of the previously active theme. $previous_theme = strtolower(get_option('theme_switched')); if (!in_array( $previous_theme, array('Busiprof Agency','vdequator','vdperanto','arzine','lazyprof'))) { return; } // Get the theme mods from the previous theme. $previous_theme_content = get_option('theme_mods_' . $previous_theme); if (!empty($previous_theme_content)) { foreach ($previous_theme_content as $previous_theme_mod_k => $previous_theme_mod_v) { set_theme_mod($previous_theme_mod_k, $previous_theme_mod_v); } } } // For body class function busiprof_agency_body_class(){ $body = ''; if (function_exists('webriti_companion_activate')) { global $template; $busiprof_agency_is_front_page = wp_parse_args( get_option( 'busiprof_theme_options', array() ), busiprof_theme_setup_data()); if (( $busiprof_agency_is_front_page['front_page'] == 'yes' && basename($template)=='template-home-two.php')||($busiprof_agency_is_front_page['front_page'] == 'yes' && basename($template)=='front-page.php')) { $body='home-business'; } } return $body; } $busiprof_agency_theme = wp_get_theme(); if( $busiprof_agency_theme->name == 'Busiprof Agency' || $busiprof_agency_theme->name == 'Busiprof Agency child' || $busiprof_agency_theme->name == 'Busiprof Agency Child') { // Notice to add required plugin function busiprof_agency_admin_plugin_notice_warn() { global $hook_suffix; $theme_name = wp_get_theme(); if($hook_suffix === 'themes.php'){ if ( get_option( 'dismissed-busiprof_agency_comanion_plugin', false ) ) { return; } if ( function_exists('webriti_companion_activate')) { return; }?>

Artboard 1WC

plugin.

'activated')); } else { wp_send_json_success(array('status' => 'installed')); } } else { wp_send_json_success(array('status' => 'not_installed')); } } // Existing AJAX installation function for installing and activating add_action('wp_ajax_busiprof_agency_install_activate_plugin', 'busiprof_agency_install_and_activate_plugin'); function busiprof_agency_install_and_activate_plugin() { if (!current_user_can('install_plugins')) { wp_send_json_error('You do not have permission to install plugins.'); return; } if (!isset($_POST['plugin_url'])) { wp_send_json_error('No plugin URL provided.'); return; } // Include necessary WordPress files for plugin installation include_once(ABSPATH . 'wp-admin/includes/file.php'); include_once(ABSPATH . 'wp-admin/includes/misc.php'); include_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'); include_once(ABSPATH . 'wp-admin/includes/plugin.php'); $plugin_url = esc_url($_POST['plugin_url']); $plugin_slug = sanitize_text_field($_POST['plugin_slug']); $plugin_main_file = $plugin_slug . '/' . $plugin_slug . '.php'; // Ensure this matches your plugin structure // Download the plugin file WP_Filesystem(); $temp_file = download_url($plugin_url); if (is_wp_error($temp_file)) { wp_send_json_error($temp_file->get_error_message()); return; } // Unzip the plugin to the plugins folder $plugin_folder = WP_PLUGIN_DIR; $result = unzip_file($temp_file, $plugin_folder); // Clean up temporary file unlink($temp_file); if (is_wp_error($result)) { wp_send_json_error($result->get_error_message()); return; } // Activate the plugin if it was installed $activate_result = activate_plugin($plugin_main_file); // Return success with redirect URL wp_send_json_success(array('redirect_url' => admin_url('admin.php?page=busiprof_agency-welcome'))); } // Enqueue JavaScript for the button functionality add_action('admin_enqueue_scripts', 'busiprof_agency_enqueue_plugin_installer_script'); function busiprof_agency_enqueue_plugin_installer_script() { global $hook_suffix; wp_dequeue_script('busiprof-plugin-installer-js'); wp_enqueue_script('busiprof-agency-plugin-installer-js', BUSIPROF_AGENCY_TEMPLATE_DIR_URI . '/admin/assets/js/plugin-installer.js', array('jquery'), null, true); wp_localize_script('busiprof-agency-plugin-installer-js', 'pluginInstallerAjax', array( 'ajax_url' => admin_url('admin-ajax.php'), 'hook_suffix' => $hook_suffix, 'nonce' => wp_create_nonce('plugin_installer_nonce'), )); }