roles) && !current_user_can('export'); } if ($noCapabilitiesNotice) { $notices[] = array(__CLASS__, 'showNoExportCapabilityNotice'); } if (is_multisite()) { $displayNotices = is_super_admin() && current_user_can('export'); } else { $displayNotices = current_user_can('export'); } if ($displayNotices) { $notices[] = array(__CLASS__, 'clearInstallerFilesAction'); // BEFORE MIGRATION SUCCESS NOTICE $notices[] = array(__CLASS__, 'migrationSuccessNotice'); $notices[] = array(__CLASS__, 'installAutoDeactivatePlugins'); } $action = is_multisite() ? 'network_admin_notices' : 'admin_notices'; foreach ($notices as $notice) { add_action($action, $notice); } } /** * Remove all notices coming from other plugins * * @param string $hook Hook string * * @return void */ public static function unhookThirdPartyNotices($hook) { if (!ControllersManager::isDuplicatorPage()) { return; } global $wp_filter; $filterHooks = array('user_admin_notices', 'admin_notices', 'all_admin_notices', 'network_admin_notices'); foreach ($filterHooks as $filterHook) { if (empty($wp_filter[$filterHook]->callbacks) || !is_array($wp_filter[$filterHook]->callbacks)) { continue; } foreach ($wp_filter[$filterHook]->callbacks as $priority => $hooks) { foreach ($hooks as $name => $arr) { if (is_object($arr['function']) && $arr['function'] instanceof Closure) { unset($wp_filter[$filterHook]->callbacks[$priority][$name]); continue; } if ( !empty($arr['function'][0]) && is_object($arr['function'][0]) && strpos(get_class($arr['function'][0]), Autoloader::ROOT_NAMESPACE) === 0 ) { continue; } if (!empty($name) && strpos($name, Autoloader::ROOT_NAMESPACE) !== 0) { unset($wp_filter[$filterHook]->callbacks[$priority][$name]); } } } } } /** * Clear installer file action * * @return void */ public static function clearInstallerFilesAction() { if (!\DUP_CTRL_Tools::isDiagnosticPage() || get_option(self::OPTION_KEY_MIGRATION_SUCCESS_NOTICE) == true) { return; } if (SnapUtil::filterInputRequest('action', FILTER_DEFAULT) === 'installer') { if (! wp_verify_nonce($_REQUEST['_wpnonce'], 'duplicator_cleanup_page')) { echo '

' . __('Security issue', 'duplicator') . '

'; exit; // Get out of here bad nounce! } ?>
id == 'duplicator_page_duplicator-tools' && isset($_GET['action']) && $_GET['action'] == 'installer'); if (DUP_Server::hasInstallerFiles() && !$is_installer_cleanup_req) { MigrationMng::renameInstallersPhpFiles(); $on_active_tab = isset($_GET['section']) ? $_GET['section'] : ''; echo '

'; //Safe Mode Notice $safe_html = ''; if (get_option("duplicator_exe_safe_mode", 0) > 0) { $safe_msg1 = __('Safe Mode:', 'duplicator'); $safe_msg2 = __('During the install safe mode was enabled deactivating all plugins.
Please be sure to ', 'duplicator'); $safe_msg3 = __('re-activate the plugins', 'duplicator'); $safe_html = "

{$safe_msg1}
{$safe_msg2} {$safe_msg3}!

"; } //On Tools > Cleanup Page if ($screen->id == 'duplicator_page_duplicator-tools' && ($on_active_tab == "info" || $on_active_tab == '')) { $title = __('This site has been successfully migrated!', 'duplicator'); $msg1 = __('Final step(s):', 'duplicator'); $msg2 = __('This message will be removed after all installer files are removed. Installer files must be removed to maintain a secure site. ' . 'Click the link above or button below to remove all installer files and complete the migration.', 'duplicator'); echo " " . esc_html($title) . "
{$safe_html} " . esc_html($msg1) . "
"; printf( "1. %s
", esc_html__('Remove Installation Files Now!', 'duplicator') ); printf( "2. %s
", esc_html__('Optionally, Review Duplicator at WordPress.org...', 'duplicator') ); echo "
" . esc_html($msg2) . "
"; //All other Pages } else { $title = __('Migration Almost Complete!', 'duplicator'); $msg = __( 'Reserved Duplicator installation files have been detected in the root directory. Please delete these installation files to ' . 'avoid security issues.
Go to: Duplicator > Tools > General > Information > Utils and click the "Remove Installation Files" button', 'duplicator' ); $nonce = wp_create_nonce('duplicator_cleanup_page'); $url = self_admin_url('admin.php?page=duplicator-tools&tab=diagnostics§ion=info&_wpnonce=' . $nonce); echo "{$title}
{$safe_html} {$msg}"; @printf("
%s", __('Take me there now!', 'duplicator')); } echo "

"; } } /** * Shows a message for redirecting a page * * @param string $location The location to redirect to * * @return never */ public static function redirect($location) { echo '
'; esc_html__('Redirecting Please Wait...', 'duplicator'); echo '
'; echo ""; die(esc_html__('Invalid token permissions to perform this request.', 'duplicator')); } /** * Shows install deactivated function * * @return void */ public static function installAutoDeactivatePlugins() { $reactivatePluginsAfterInstallation = get_option(self::OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL, false); $pluginsToActive = get_option(self::OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL, false); if (!is_array($pluginsToActive) || empty($pluginsToActive)) { return false; } $shouldBeActivated = array(); $allPlugins = get_plugins(); foreach ($pluginsToActive as $index => $pluginSlug) { if (!isset($allPlugins[$pluginSlug])) { unset($pluginsToActive[$index]); continue; } $isActive = is_plugin_active($pluginSlug); if (!$isActive && isset($allPlugins[$pluginSlug])) { $shouldBeActivated[$pluginSlug] = $allPlugins[$pluginSlug]['Name']; } else { unset($pluginsToActive[$index]); } } if (empty($shouldBeActivated)) { delete_option(self::OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL); return; } else { update_option(self::OPTION_KEY_ACTIVATE_PLUGINS_AFTER_INSTALL, $pluginsToActive); } $activatePluginsAnchors = array(); foreach ($shouldBeActivated as $slug => $title) { $activateURL = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $slug), 'activate-plugin_' . $slug); $anchorTitle = sprintf(esc_html__('Activate %s', 'duplicator'), $title); $activatePluginsAnchors[] = '' . $title . ''; } ?>

" . esc_html__("Warning!", "duplicator") . " " . esc_html__("Migration Almost Complete!", "duplicator") . "
"; echo esc_html__( "Plugin(s) listed here have been deactivated during installation to help prevent issues. Please activate them to finish this migration: ", "duplicator" ) . "
"; echo implode(' ,', $activatePluginsAnchors); ?>

id, $duplicator_pages) || (isset($notices[$notice_id]) && 'true' === $notices[$notice_id])) { return; } // not using DUP_Util::getTablePrefix() in place of $tablePrefix because AdminNotices included initially (Duplicator\Lite\Requirement // is depended on the AdminNotices) $tablePrefix = (is_multisite() && is_plugin_active_for_network('duplicator/duplicator.php')) ? $GLOBALS['wpdb']->base_prefix : $GLOBALS['wpdb']->prefix; $packagesCount = $GLOBALS['wpdb']->get_var('SELECT count(id) FROM ' . $tablePrefix . 'duplicator_packages WHERE status=100'); if ($packagesCount < DUPLICATOR_FEEDBACK_NOTICE_SHOW_AFTER_NO_PACKAGE) { return; } $notices[$notice_id] = 'false'; update_user_meta(get_current_user_id(), DUPLICATOR_ADMIN_NOTICES_USER_META_KEY, $notices); $dismiss_url = wp_nonce_url( add_query_arg(array( 'action' => 'duplicator_set_admin_notice_viewed', 'notice_id' => esc_attr($notice_id), ), admin_url('admin-post.php')), 'duplicator_set_admin_notice_viewed', 'nonce' ); ?>
" style="text-align:top; margin:0; height:60px; width:60px;" alt="Duplicator">
roles) && !current_user_can('export')) { $faqUrl = esc_url(LinkManager::getDocUrl( 'how-to-resolve-duplicator-plugin-user-interface-ui-issues', 'admin_notice', 'duplicator menu missing' )); $errorMessage = __( 'Duplicator
Your logged-in user role does not have export capability so you don\'t have access to Duplicator functionality.', 'duplicator' ) . "
" . sprintf( _x( 'RECOMMENDATION: Add export capability to your role. See FAQ: ' . '%1$sWhy is the Duplicator/Packages menu missing from my admin menu?%2$s', '%1$s and %2$s are tags', 'duplicator' ), '', '' ); self::displayGeneralAdminNotice($errorMessage, self::GEN_ERROR_NOTICE, true); } } /** * display genral admin notice by printing it * * @param string $htmlMsg html code to be printed * @param integer $noticeType constant value of SELF::GEN_ * @param boolean $isDismissible whether the notice is dismissable or not. Default is true * @param array|string $extraClasses add more classes to the notice div * * @return void */ public static function displayGeneralAdminNotice($htmlMsg, $noticeType, $isDismissible = true, $extraClasses = array()) { if (empty($extraClasses)) { $classes = array(); } elseif (is_array($extraClasses)) { $classes = $extraClasses; } else { $classes = array($extraClasses); } $classes[] = 'notice'; switch ($noticeType) { case self::GEN_INFO_NOTICE: $classes[] = 'notice-info'; break; case self::GEN_SUCCESS_NOTICE: $classes[] = 'notice-success'; break; case self::GEN_WARNING_NOTICE: $classes[] = 'notice-warning'; break; case self::GEN_ERROR_NOTICE: $classes[] = 'notice-error'; break; default: throw new Exception('Invalid Admin notice type!'); } if ($isDismissible) { $classes[] = 'is-dismissible'; } $classesStr = implode(' ', $classes); ?>