'hg-socialfeed', 'label' => 'Social Feed', 'title' => 'HG Social Feed', 'description' => 'Toon berichten en profiellinks van Instagram, Facebook en X.', 'version' => HGSF_VERSION, 'callback' => 'hgsf_admin_page', ]); add_action('admin_enqueue_scripts', static function (string $hook): void { if ($hook === HG_Plugin_Admin::hook('hg-socialfeed')) { wp_enqueue_style('hgsf-admin', plugins_url('assets/admin.css', HGSF_PLUGIN_FILE), ['hg-admin-menu'], HGSF_VERSION); } }); function hgsf_admin_url(string $tab, array $args = []): string { return add_query_arg(['page' => 'hg-socialfeed', 'tab' => $tab] + $args, admin_url('admin.php')); } function hgsf_admin_page(): void { if (!current_user_can('manage_options')) { wp_die('Geen toegang.', '', ['response' => 403]); } $tabs = array_map(static fn (array $provider): string => $provider['label'], HGSF_SOURCES) + ['shortcodes' => 'Shortcodes']; $tab = $_GET['tab'] ?? ''; $tab = is_string($tab) && isset($tabs[$tab]) ? $tab : 'instagram'; $notice = match ($_GET['hgsf_notice'] ?? '') { 'saved' => ['success', 'Instellingen opgeslagen.'], 'synced' => ['success', 'Berichten opgehaald.'], 'failed' => ['error', 'Het ophalen is mislukt. Bekijk de status van het platform.'], 'invalid' => ['error', 'Controleer het profiel en het toegangstoken van het platform.'], 'busy' => ['error', 'Er loopt al een synchronisatie voor dit platform. Probeer het zo opnieuw.'], 'disconnected' => ['success', 'Toegangstoken en opgeslagen berichten verwijderd. De profiellink blijft beschikbaar.'], default => null, }; ?>

HG Social Feed

Beheer de bronnen voor berichten en profieliconen.


Plaatsen op de website

Plaats een shortcode in een shortcodeblok op de gewenste pagina.

[hg_socialfeed]
Toont de recentste berichten van de ingestelde platforms.
[hg_sociallinks]
Toont een iconenbalk met links naar de ingestelde profielen.

Kies specifieke platforms met bijvoorbeeld [hg_socialfeed sources="instagram,facebook"].

[ 'Gebruik een langlevend Instagram-toegangstoken uit het Meta App Dashboard.', 'https://developers.facebook.com/documentation/instagram-platform/instagram-api-with-instagram-login/get-started', ], 'facebook' => [ 'Gebruik een paginatoegangstoken voor een Facebook-pagina die je beheert.', 'https://developers.facebook.com/docs/graph-api/reference/page/published_posts', ], 'x' => [ 'Gebruik het app-only Bearer Token uit de X Developer Console.', 'https://docs.x.com/x-api/getting-started/pricing', ], }; $can_sync = $connection['token'] && ($source !== 'x' || $connection['enabled']); ?>

Stel een profiel in voor de iconenbalk. Voeg een toegangstoken toe om berichten op te halen.

Optioneel voor de profiellink, bijvoorbeeld mijnbedrijf uit facebook.com/mijnbedrijf.
Documentatie

Synchronisatie

Automatisch ophalen staat uit.

De eerste synchronisatie staat nog open.

Het token kon nog niet automatisch worden verlengd. WordPress probeert het bij de volgende synchronisatie opnieuw.

403]); } $source = $_POST['source'] ?? ''; if (!is_string($source) || !isset(HGSF_SOURCES[$source])) { wp_die('Ongeldig platform.', '', ['response' => 400]); } check_admin_referer('hgsf_settings_' . $source, 'hgsf_nonce_' . $source); $result = hgsf_with_connection_lock(static fn () => hgsf_save_settings($source, $_POST), $source); $notice = is_wp_error($result) ? 'busy' : $result; wp_safe_redirect(hgsf_admin_url($source, ['hgsf_notice' => $notice]), 303); exit; } function hgsf_save_settings(string $source, array $input): string { $connection = hgsf_connection($source); $provider = HGSF_SOURCES[$source]; $operation = $input['operation'] ?? ''; if ($operation === 'disconnect') { $connection['id'] = wp_generate_uuid4(); $connection['token'] = ''; $connection['saved_at'] = 0; $connection['enabled'] = false; update_option($provider['connection'], $connection, false); delete_option($provider['snapshot']); return 'disconnected'; } if ($operation === 'sync') { return is_wp_error(hgsf_update_snapshot($connection, $source)) ? 'failed' : 'synced'; } if ($operation !== 'save') { return 'invalid'; } $username = $input['username'] ?? ''; $token = $input['token'] ?? ''; $profile = $source === 'facebook' ? ($input['profile'] ?? '') : ''; if (!is_string($username) || !is_string($token) || !is_string($profile)) { return 'invalid'; } $username = strtolower(ltrim(trim(wp_unslash($username)), '@')); $token = trim(wp_unslash($token)); $profile = trim(wp_unslash($profile)); $enabled = $source === 'x' && ($input['enabled'] ?? '') === '1'; $pattern = match ($source) { 'instagram' => '/^[a-z0-9._]{1,30}$/D', 'facebook' => '/^[0-9]{1,30}$/D', 'x' => '/^[a-z0-9_]{1,15}$/D', }; if (($username !== '' && !preg_match($pattern, $username)) || ($profile !== '' && !preg_match('/^[a-z0-9.]{1,75}$/iD', $profile)) || ($token !== '' && ($username === '' || !hgsf_valid_token($token, $source)))) { return 'invalid'; } $credentials_changed = $username !== $connection['username'] || $token !== ''; $enable_changed = $enabled !== $connection['enabled']; if ($enabled && ($username === '' || ($token === '' && ($credentials_changed || !$connection['token'])))) { return 'invalid'; } if ($credentials_changed) { $connection['id'] = wp_generate_uuid4(); $connection['username'] = $username; $connection['token'] = $token; $connection['saved_at'] = time(); } $connection['profile'] = $profile; $connection['enabled'] = $enabled; update_option($provider['connection'], $connection, false); if ($credentials_changed || $enable_changed) { delete_option($provider['snapshot']); if ($connection['token'] && ($source !== 'x' || $enabled)) { return is_wp_error(hgsf_update_snapshot($connection, $source)) ? 'failed' : 'synced'; } } return 'saved'; } add_action('admin_post_hgsf_settings', 'hgsf_handle_settings');