Skip to content

Commit

Permalink
faulty merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tobibode committed Feb 23, 2025
1 parent c7692ab commit 1ad68c5
Showing 1 changed file with 3 additions and 47 deletions.
50 changes: 3 additions & 47 deletions packages/wp-plugin/essentials/inc/dashboard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace ionos_wordpress\essentials\dashboard;

use function ionos_wordpress\essentials\dashboard\blocks\next_best_actions\getNBAData;
use function ionos_wordpress\essentials\dashboard\blocks\next_best_actions\model\getNBAElements;

use const ionos_wordpress\essentials\PLUGIN_DIR;

/*
Expand Down Expand Up @@ -34,18 +31,18 @@
require_once __DIR__ . '/editor.php';
}

require_once PLUGIN_DIR . '/blocks/nba/index.php';

\add_action('init', function () {
define('IONOS_ESSENTIALS_DASHBOARD_ADMIN_PAGE_TITLE', __('IONOS Dashboard', 'ionos-essentials'));

\wp_register_block_metadata_collection(
PLUGIN_DIR . '/build/dashboard/blocks',
PLUGIN_DIR . '/build/dashboard/blocks/blocks-manifest.php'
);
//\register_block_type(PLUGIN_DIR . '/build/dashboard/blocks/deep-links');
\register_block_type(PLUGIN_DIR . '/build/dashboard/blocks/deep-links');
\register_block_type(PLUGIN_DIR . '/build/dashboard/blocks/quick-links');
\register_block_type(PLUGIN_DIR . '/build/dashboard/blocks/vulnerability');
\register_block_type(PLUGIN_DIR . '/build/dashboard/blocks/next-best-actions');

});

// remove our blocks from all other post types
Expand Down Expand Up @@ -170,44 +167,3 @@
EOF
);
});

\add_action('load-' . ADMIN_PAGE_HOOK, function () {

});
add_action('wp_ajax_execute-nba-callback', function() {
$process = isset($_GET['process']) ? sanitize_text_field($_GET['process']) : '';
$id = isset($_GET['id']) ? sanitize_text_field($_GET['id']) : '';

if (empty($process) || empty($id)) {
\wp_send_json_error(new \WP_Error('missing_parameters', 'Missing parameters'));
}

require_once PLUGIN_DIR . '/build/dashboard/blocks/next-best-actions/data.php';
$elements = getNBAData();
if (! is_array($elements)) {
\wp_send_json_error(new \WP_Error('no_actions', 'No actions found'));
}

foreach ($elements as $element) {
if ($element->__get('id') === $id ) {

switch ($process) {
case 'click-nba-dismiss':
$element->__set('dismissed', true);
\wp_send_json_success(['addClass' => 'dismissed']);
break;
case 'click-nba-action':
$callback = $element->__get('completeOnClickCallback');
$result = \call_user_func($callback) === true;
if ($result === true) {
$element->__set('completed', true);
}
\wp_send_json_success( [ 'redirect' => $element->__get('link') ] );
break;
}
}
}

\wp_send_json_error(new \WP_Error('action_not_found', 'Action not found'));
});

0 comments on commit 1ad68c5

Please sign in to comment.