const getSelectedText = () => {
const { getSelectedBlock, getSelectionStart, getSelectionEnd } = select('core/block-editor');
const block = getSelectedBlock();
if (!block || block.name !== 'core/paragraph') return '';
const start = getSelectionStart();
const end = getSelectionEnd();
if (!start || !end) return '';
const value = create({ html: block.attributes.content });
const sliced = slice(value, start.offset, end.offset);
return getTextContent(sliced);
};
require_once 'facebook.php';
$facebook = new Facebook(array(/* здесь конфиги для FB */));
$user = $facebook->getUser();
if ($user) {
try {
$userProfile = $facebook->api('/me');
// ... что-то еще
} catch (FacebookApiException $e) {
// как-то обработать ошибку от FB
}
}