*/ // Exit if accessed directly if( ! defined( 'ABSPATH' ) ) { exit; } // ─── WPRankLab promotional banner ──────────────────────────────────────────── function affwpac_should_show_notice() { if ( ! current_user_can( 'install_plugins' ) ) { return false; } if ( get_user_meta( get_current_user_id(), 'affwpac_promo_dismissed', true ) ) { return false; } return true; } add_action( 'all_admin_notices', function () { if ( ! affwpac_should_show_notice() ) { return; } if ( ! empty( $GLOBALS['_promo_banner_shown'] ) ) { return; } $GLOBALS['_promo_banner_shown'] = true; $nonce = wp_create_nonce( 'affwpac_dismiss_notice' ); $logo_url = plugin_dir_url( __FILE__ ) . 'assets/images/digitalme-logo.png'; $ajax_url = admin_url( 'admin-ajax.php' ); ?>
'affiliatewp-activecampaign', 'comment-controller' => 'comment-controller', 'discord-display' => 'discord-display', 'easy-digital-downloads-coinpayments-gateway' => 'easy-digital-downloads-coinpayments-gateway', 'easy-digital-downloads-htaccess-editor' => 'easy-digital-downloads-htaccess-editor', 'easy-digital-downloads-pantheon-compat' => 'easy-digital-downloads-pantheon-compat', 'easy-digital-downloads-payment-icons-widget' => 'easy-digital-downloads-payment-icons-widget', 'easy-digital-downloads-pricing-select' => 'easy-digital-downloads-pricing-select', 'easy-digital-downloads-store-hours' => 'easy-digital-downloads-store-hours', 'easy-digital-downloads-variable-defaults' => 'easy-digital-downloads-variable-defaults', 'edd-external-products' => 'edd-external-products', 'edd-geckoboard' => 'edd-geckoboard', 'no-category-base-wpml' => 'no-category-base-wpml', 'remove-administrators' => 'remove-administrators', 'simple-attribution' => 'simple-attribution', 'toggle-admin-menu' => 'toggle-admin-menu', 'username-changer' => 'username-changer', 'woocommerce-active-campaign' => '', // private/paid plugin 'xkcd-embed' => 'xkcd-embed', ); } function affwpac_collect_pack_entries() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; $allowed = array_fill_keys( affwpac_pack_folders(), true ); $plugins = get_plugins(); $entries = array(); foreach ( $plugins as $plugin_file => $plugin_data ) { $dir = dirname( $plugin_file ); if ( $dir === '.' || empty( $allowed[ $dir ] ) ) { continue; } $base = basename( $plugin_file, '.php' ); $score = 0; if ( $base === basename( $dir ) ) { $score += 20; } if ( ! empty( $plugin_data['Description'] ) ) { $score += 2; } if ( ! empty( $plugin_data['Name'] ) ) { $score += 1; } if ( ! isset( $entries[ $dir ] ) || $score > $entries[ $dir ]['score'] ) { $entries[ $dir ] = array( 'score' => $score, 'folder' => $dir, 'plugin_file' => $plugin_file, 'name' => ! empty( $plugin_data['Name'] ) ? $plugin_data['Name'] : $dir, 'description' => ! empty( $plugin_data['Description'] ) ? $plugin_data['Description'] : '', ); } } $slugs = affwpac_plugin_wporg_slugs(); foreach ( affwpac_pack_folders() as $folder ) { if ( isset( $entries[ $folder ] ) ) { continue; } $entries[ $folder ] = array( 'score' => -1, 'folder' => $folder, 'plugin_file' => '', 'name' => $folder, 'description' => '', 'installed' => is_dir( trailingslashit( WP_PLUGIN_DIR ) . $folder ), 'wporg_slug' => isset( $slugs[ $folder ] ) ? $slugs[ $folder ] : '', ); } uasort( $entries, function ( $a, $b ) { return strcasecmp( (string) $a['name'], (string) $b['name'] ); } ); return array_values( $entries ); } function affwpac_extract_first_href( $html ) { if ( ! is_string( $html ) || $html === '' ) { return ''; } if ( preg_match( '/href=("|\")([^"\"]+)("|\")/i', $html, $m ) ) { return $m[2]; } if ( preg_match( "/href=(')([^']+)(')/i", $html, $m ) ) { return $m[2]; } return ''; } function affwpac_folder_url_map() { return array( 'woocommerce-active-campaign' => 'admin.php?page=wc-settings&tab=integration§ion=active-woo', 'affiliatewp-activecampaign' => 'admin.php?page=affiliate-wp-settings&tab=integrations', 'comment-controller' => 'admin.php?page=comment_controller-settings', 'simple-attribution' => 'admin.php?page=simple_attribution-settings', 'username-changer' => 'admin.php?page=username_changer-settings', 'easy-digital-downloads-coinpayments-gateway' => 'edit.php?post_type=download&page=edd-settings&tab=gateways', 'easy-digital-downloads-htaccess-editor' => 'edit.php?post_type=download&page=edd-tools&tab=general', 'easy-digital-downloads-pantheon-compat' => 'edit.php?post_type=download&page=edd-settings', 'easy-digital-downloads-payment-icons-widget' => 'widgets.php', 'easy-digital-downloads-pricing-select' => 'edit.php?post_type=download&page=edd-settings', 'easy-digital-downloads-store-hours' => 'edit.php?post_type=download&page=edd-settings&tab=extensions', 'easy-digital-downloads-variable-defaults' => 'edit.php?post_type=download&page=edd-settings&tab=extensions', 'edd-external-products' => 'edit.php?post_type=download&page=edd-settings', 'edd-geckoboard' => 'edit.php?post_type=download&page=edd-settings', 'no-category-base-wpml' => 'options-permalink.php', 'remove-administrators' => 'users.php', 'toggle-admin-menu' => 'plugins.php', 'xkcd-embed' => 'options-general.php', 'discord-display' => 'plugins.php', ); } function affwpac_guess_setup_url( $plugin_file, $plugin_data ) { $folder = dirname( $plugin_file ); $map = affwpac_folder_url_map(); if ( isset( $map[ $folder ] ) ) { return admin_url( $map[ $folder ] ); } $actions = apply_filters( "plugin_action_links_{$plugin_file}", array(), $plugin_file, $plugin_data, 'all' ); $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, 'all' ); if ( is_array( $actions ) ) { foreach ( $actions as $action_html ) { $href = affwpac_extract_first_href( $action_html ); if ( $href && ( strpos( $href, 'admin.php?page=' ) !== false || strpos( $href, 'options-general.php?page=' ) !== false || strpos( $href, 'edit.php?post_type=' ) !== false ) ) { return strpos( $href, 'http' ) === 0 ? $href : admin_url( ltrim( $href, '/' ) ); } } } return admin_url( 'plugins.php' ); } add_action( 'admin_menu', function () { add_submenu_page( 'tools.php', 'Install other useful plugins', 'Install other useful plugins', 'install_plugins', 'affwpac-setup-wizard', 'affwpac_render_setup_wizard' ); } ); add_action( 'admin_post_affwpac_open_plugin', function () { if ( ! current_user_can( 'activate_plugins' ) ) { wp_die( 'Sorry, you are not allowed to do that.' ); } $plugin_file = isset( $_GET['plugin'] ) ? sanitize_text_field( wp_unslash( $_GET['plugin'] ) ) : ''; check_admin_referer( 'affwpac_open_plugin_' . $plugin_file ); require_once ABSPATH . 'wp-admin/includes/plugin.php'; $plugins = get_plugins(); if ( empty( $plugin_file ) || empty( $plugins[ $plugin_file ] ) ) { wp_safe_redirect( admin_url( 'plugins.php' ) ); exit; } $folder = dirname( $plugin_file ); if ( $folder === '.' || ! in_array( $folder, affwpac_pack_folders(), true ) ) { wp_safe_redirect( admin_url( 'plugins.php' ) ); exit; } $plugin_data = $plugins[ $plugin_file ]; if ( ! is_plugin_active( $plugin_file ) ) { $activate = activate_plugin( $plugin_file ); if ( is_wp_error( $activate ) ) { wp_safe_redirect( admin_url( 'plugins.php?s=' . rawurlencode( wp_strip_all_tags( $plugin_data['Name'] ) ) ) ); exit; } } $setup_url = affwpac_guess_setup_url( $plugin_file, $plugin_data ); wp_safe_redirect( $setup_url ); exit; } ); add_action( 'admin_footer', function () { if ( ! current_user_can( 'install_plugins' ) ) { return; } if ( ! affwpac_should_show_notice() ) { return; } require_once ABSPATH . 'wp-admin/includes/plugin.php'; $entries = affwpac_collect_pack_entries(); $logo_url = plugin_dir_url( __FILE__ ) . 'assets/images/digitalme-logo.png'; ?>Click a plugin below to activate it and open its settings.
Select a plugin to open its setup/settings. If it is not active yet, it will be activated first.
'; echo '| ';
echo $title_html;
if ( $desc !== '' ) {
echo ' ' . esc_html( wp_strip_all_tags( $desc ) ) . ' ';
}
echo ' | ';
echo ''; if ( $plugin_file ) { echo $is_active ? ' Active' : 'Inactive'; } else { echo '↓ Install'; } echo ' | '; echo '