PHP code example of theaminulai / feedback-sdk
1. Go to this page and download the library: Download theaminulai/feedback-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
theaminulai / feedback-sdk example snippets
add_action( 'plugins_loaded', function() {
\Feedback_SDK\Core\SDK::init([
'plugin_name' => 'ElementsKit',
'plugin_slug' => 'elementskit-lite',
'plugin_version' => ELEMENTSKIT_VERSION,
'api_endpoint' => 'https://api.theaminul.com/wp-json/feedback/v1/collect',
'api_key' => 'fk_your_api_key_here',
]);
}, 20 );
\Feedback_SDK\Core\SDK::init([
// ... lementsKit Feedback',
'brand_icon' => 'ti-layers',
'brand_icon_url' => 'https://cdn.example.com/elementskit-icon.png',
// Colors
'primary_color' => '#f59e0b',
'primary_gradient'=> 'linear-gradient(135deg, #f59e0b, #ef4444)',
'modal_bg' => '#fffbeb',
'option_bg' => '#fef9ee',
'option_active_bg'=> '#fef3c7',
'bg_overlay' => 'rgba(0, 0, 0, 0.5)',
// Layout
'modal_radius' => 16,
// Typography
'font_family' => 'Inter',
'font_url' => 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap',
'font_size_base' => 13,
// Text
'text_primary' => '#1c1917',
'text_muted' => '#78716c',
'border_color' => '#e5e7eb',
]);
\Feedback_SDK\Core\SDK::init([
// ...
'hide_reasons' => ['too-expensive', 'found-better'],
]);
\Feedback_SDK\Core\SDK::init([
// ...
'extra_reasons' => [
[
'key' => 'theme-conflict',
'icon' => 'ti-layout', // any Tabler icon
'label' => 'Theme conflict',
'ph' => 'Which theme are you using?', // textarea placeholder
],
],
]);
\Feedback_SDK\Core\SDK::init([
// ...
'reasons' => [
['key' => 'price', 'icon' => 'ti-coin', 'label' => 'Too expensive', 'ph' => 'What price works?'],
['key' => 'other', 'icon' => 'ti-dots', 'label' => 'Other', 'ph' => 'Tell us more'],
],
]);
$client = new \Feedback_SDK\API\Client(
'https://api.theaminul.com/wp-json/feedback/v1/collect',
'fk_your_api_key'
);
$client->flush_retry_queue();
// Register the event on activation
register_activation_hook( __FILE__, function() {
wp_schedule_event( time(), 'hourly', 'my_plugin_flush_feedback_queue' );
});
add_action( 'my_plugin_flush_feedback_queue', function() {
$client = new \Feedback_SDK\API\Client( FEEDBACK_ENDPOINT, FEEDBACK_KEY );
$client->flush_retry_queue();
});
// Fired after the API send attempt (success or fail).
// @param string $slug Plugin slug.
// @param bool $success Whether wp_remote_post returned without WP_Error.
// @param array $payload The data that was sent.
add_action( 'feedback_sdk/after_send', function( $slug, $success, $payload ) {
if ( ! $success ) {
error_log( "[$slug] Feedback send failed." );
}
}, 10, 3 );
// Modify the payload array before it is posted to the server.
// @param array $payload Sanitized data array.
// @param string $slug Plugin slug.
// @return array
add_filter( 'feedback_sdk/payload', function( array $payload, string $slug ): array {
$payload['my_custom_field'] = 'value';
return $payload;
}, 10, 2 );
// Modify the reasons array before it is localized into the modal.
// @param array $reasons Array of {key, icon, label, ph} objects.
// @param string $slug Plugin slug.
// @return array
add_filter( 'feedback_sdk/reasons', function( array $reasons, string $slug ): array {
// Add, remove, or reorder reasons here.
return $reasons;
}, 10, 2 );
feedback-sdk/
│
├── feedback-sdk.php # Entry point — PSR-4 autoloader bootstrap
├── composer.json
│
├── ooks.php # Registers admin_enqueue_scripts + wp_ajax actions
│ │ └── Assets.php # wp_enqueue_*, theme CSS variables, reasons builder
│ │
│ ├── Admin/
│ │ └── Deactivation.php # Renders overlay <div>, handles AJAX submit/skip
│ │
│ └── API/
│ └── Client.php # wp_remote_post() sender + transient retry queue
│
└── assets/
├── css/
│ └── modal.css # All modal styles via CSS custom properties
└── js/
└── modal.js # jQuery plugin: $.fn.feedbackSdkModal