ID ); ?>

ID ); $adventurebook_combat_system = adventurebook_get_combat_system_for_adventurebook( $adventurebook_id ); if ( $adventurebook_combat_system === null ) { echo '

' . esc_html( __( 'Error: No combat system defined for this adventurebook.', 'adventurebook' ) ) . '

'; return; } /** @var Item_Spawn $item_spawn */ foreach ( $item_spawns as $item_spawn ) { $item_definition = $item_spawn->get_item_definition(); echo wp_kses( $item_definition->get_item_html( $adventurebook_combat_system ), array( 'a' => array( 'href' => array(), 'title' => array(), 'style' => array(), 'target' => array(), ), 'div' => array( 'class' => array(), 'id' => array(), 'style' => array(), 'onclick' => array(), ), 'span' => array( 'class' => array(), 'style' => array(), ), 'img' => array( 'src' => array(), 'width' => array(), 'height' => array(), 'style' => array(), 'alt' => array(), ), 'strong' => array(), 'button' => array( 'class' => array(), 'data-item-id' => array(), ), ) ); // delete button echo ''; } ?>

' . esc_html( __( 'No item definitions available', 'adventurebook' ) ) . '

'; ?> prefix . 'adventurebook_item_spawns'; $result = $wpdb->delete( $table_name, array( 'id' => $item_id ) );// phpcs:ignore WordPress.DB.DirectDatabaseQuery if ( $result ) { wp_send_json_success( esc_html( __( 'Item spawn deleted.', 'adventurebook' ) ) ); } else { wp_send_json_error( esc_html( __( 'Item spawn not found.', 'adventurebook' ) ) ); } } else { wp_send_json_error( esc_html( __( 'Invalid request.', 'adventurebook' ) ) ); } } // AJAX-Aktion registrieren add_action( 'wp_ajax_adventurebook_delete_item_spawn', 'adventurebook_delete_item_spawn_ajax' ); function adventurebook_add_item_spawn_ajax(): void { check_ajax_referer( 'adventurebook_ajax_nonce' ); // Nonce validieren // check for admin rights if ( ! current_user_can( 'manage_options' ) ) { return; } // Überprüfen, ob die erforderlichen Parameter vorhanden sind if ( isset( $_POST['post_id'] ) && isset( $_POST['item_code'] ) ) { $post_id = intval( $_POST['post_id'] ); $item_code = sanitize_text_field( wp_unslash( $_POST['item_code'] ) ); // Überprüfen, ob der Benutzer berechtigt ist // muss die Rolle 'editor' oder 'administrator' haben if ( ! current_user_can( 'edit_others_pages' ) ) { wp_send_json_error( esc_html( __( 'Not authorized.', 'adventurebook' ) ) ); } $result = Item_Spawn::create_item_spawn( $item_code, $post_id ); if ( $result ) { wp_send_json_success( esc_html( __( 'Item spawn added.', 'adventurebook' ) ) ); } else { wp_send_json_error( esc_html( __( 'Error adding item spawn.', 'adventurebook' ) ) ); } } else { wp_send_json_error( esc_html( __( 'Invalid request.', 'adventurebook' ) ) ); } } // AJAX-Handler für das Hinzufügen registrieren add_action( 'wp_ajax_adventurebook_add_item_spawn', 'adventurebook_add_item_spawn_ajax' );