sanitizeJsonData(wp_unslash($_POST['data'])); $pluginManagerInstance->saveConnectedSource($source, isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : null); } if (isset($_GET['page'])) { header('Location: admin.php?page=' . sanitize_text_field(wp_unslash($_GET['page'])) . '&tab=' . sanitize_text_field($selectedTab)); } exit; } else if ('source-connection-failed' === $_REQUEST['command']) { check_admin_referer('ti-connect-source'); delete_option($pluginManagerInstance->getOptionName('connect-pending')); exit; } else if ('source-connecting' === $_REQUEST['command']) { check_admin_referer('ti-connect-source'); if (get_option($pluginManagerInstance->getOptionName('source'))) { delete_option($pluginManagerInstance->getOptionName('connect-pending')); exit; } $source = null; if (isset($_POST['data'])) { /* This function ensures that each element of the JSON object is sanitized individually using standard WordPress sanitization functions */ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $source = $pluginManagerInstance->sanitizeJsonData(wp_unslash($_POST['data'])); } update_option($pluginManagerInstance->getOptionName('connect-pending'), $source, false); exit; } else if ($_REQUEST['command'] === 'disconnect-source') { check_admin_referer('ti-disconnect-source'); $pluginManagerInstance->deleteConnectedSource(); delete_option($pluginManagerInstance->getOptionName('source')); delete_option($pluginManagerInstance->getOptionName('feed-data')); delete_option($pluginManagerInstance->getOptionName('feed-data-saved')); delete_option($pluginManagerInstance->getOptionName('token-expires')); delete_option($pluginManagerInstance->getOptionName('layout')); delete_option($pluginManagerInstance->getOptionName('template')); delete_option($pluginManagerInstance->getOptionName('css-content')); $pluginManagerInstance->setNotificationParam('token-renew', 'active', false); $pluginManagerInstance->setNotificationParam('token-expired', 'active', false); if (isset($_GET['page'])) { header('Location: admin.php?page=' . sanitize_text_field(wp_unslash($_GET['page'])) . '&tab=' . sanitize_text_field($selectedTab)); } exit; } else if ($_REQUEST['command'] === 'select-layout') { check_admin_referer('ti-select-layout'); $layout = isset($_GET['layout']) ? sanitize_text_field(wp_unslash($_GET['layout'])) : ""; update_option($pluginManagerInstance->getOptionName('layout'), $layout, false); delete_option($pluginManagerInstance->getOptionName('template')); delete_option($pluginManagerInstance->getOptionName('css-content')); if (isset($_GET['page'])) { header('Location: admin.php?page=' . sanitize_text_field(wp_unslash($_GET['page'])) . '&tab=' . sanitize_text_field($selectedTab)); } exit; } else if ($_REQUEST['command'] === 'select-template') { check_admin_referer('ti-select-template'); $templateId = isset($_GET['template']) ? sanitize_text_field(wp_unslash($_GET['template'])) : ""; update_option($pluginManagerInstance->getOptionName('template'), $templateId, false); delete_option($pluginManagerInstance->getOptionName('css-content')); $feedData = $pluginManagerInstance->getFeedData(); $feedData['style'] = [ 'locales' => $feedData['style']['locales'], 'settings' => $feedData['style']['settings'], 'version' => $feedData['style']['version'], ]; $pluginManagerInstance->updateFeedDataWithDefaultTemplateParams($feedData, $templateId); $pluginManagerInstance->saveFeedData($feedData, false); if (isset($_GET['page'])) { header('Location: admin.php?page=' . sanitize_text_field(wp_unslash($_GET['page'])) . '&tab=' . sanitize_text_field($selectedTab)); } exit; } else if ($_REQUEST['command'] === 'save-feed-widget') { check_admin_referer('ti-save-feed-widget'); $data = null; if (isset($_POST['data'])) { /* This function ensures that each element of the JSON object is sanitized individually using standard WordPress sanitization functions */ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $data = $pluginManagerInstance->sanitizeJsonData(wp_unslash($_POST['data'])); } if ($data) { $data['css'] = preg_replace('/\.ti-widget([\s\.\[])/', '.ti-widget[data-wkey="feed-'. $pluginManagerInstance->getShortName() .'"]$1', $data['css']); update_option($pluginManagerInstance->getOptionName('css-content'), $data['css'], false); unset($data['css']); $pluginManagerInstance->saveFeedData($data, false); $pluginManagerInstance->handleCssFile(); } if (isset($_GET['page'])) { header('Location: admin.php?page=' . sanitize_text_field(wp_unslash($_GET['page'])) . '&tab=' . sanitize_text_field($selectedTab)); } exit; } } $layout = get_option($pluginManagerInstance->getOptionName('layout')); $template = get_option($pluginManagerInstance->getOptionName('template')); $css = get_option($pluginManagerInstance->getOptionName('css-content')); $isReconnectingSource = isset($_GET['reconnect-source']); $error = null; $connectPending = get_option($pluginManagerInstance->getOptionName('connect-pending'), []); if (isset($connectPending['error'])) { $error = $connectPending['error']; } elseif (isset($_GET['error'])) { $error = sanitize_text_field(wp_unslash($_GET['error'])); } ?> getConnectedSource()) { $stepDone = 1; } if (!$stepCurrent) { $stepCurrent = $stepDone + 1; } else if ($stepCurrent > ($stepDone + 1)) { $stepCurrent = $stepDone + 1; } if ($stepCurrent === 4) { $stepRightButton = [ 'class' => 'btn-feed-editor-save', 'text' => __('Save and get code', 'social-photo-feed-widget') ]; } if (!isset($_GET['step']) && $pluginManagerInstance->getNotificationParam('token-expired', 'active')) { $stepCurrent = 1; } include(plugin_dir_path(__FILE__) . '../include/step-list.php'); ?>
time()) {
/* translators: 1: Platform name, 2: Date string */
echo esc_html(sprintf(__('Your %1$s Access Token expires on %2$s.', 'social-photo-feed-widget'), 'Instagram', $tokenExpireDate));
} else {
/* translators: 1: Platform name, 2: Date string */
echo esc_html(sprintf(__('Your %1$s Access Token expired on %2$s.', 'social-photo-feed-widget'), 'Instagram', $tokenExpireDate));
}
?>