Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 | 17x 16x 16x 12x 3x 20x 76x 180x 31x 1x 1x 63x 31x 75x 75x 5x 5x 2x 75x 75x 20x 6x 78x 25x 75x 75x 17x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 3x 25x 5x 8x 5x | import { getRedirectUrl } from '@automattic/jetpack-components';
import { merge } from 'lodash';
import { JETPACK_SET_INITIAL_STATE, MOCK_SWITCH_USER_PERMISSIONS } from 'state/action-types';
import { isCurrentUserLinked } from 'state/connection';
import { getPlanDuration } from 'state/plans/reducer';
export const initialState = ( state = window.Initial_State, action ) => {
switch ( action.type ) {
case JETPACK_SET_INITIAL_STATE:
return Object.assign( {}, state, action.initialState );
case MOCK_SWITCH_USER_PERMISSIONS:
return merge( {}, state, { userData: action.initialState } );
default:
return state;
}
};
/**
* Returns bool if current version is Dev version
* Which means -alpha, -beta, etc...
*
* @param {object} state - Global state tree
* @return {boolean} true if dev version
*/
export function isDevVersion( state ) {
return !! state.jetpack.initialState.isDevVersion;
}
/**
* Returns a string of the current Jetpack version defined
* by JETPACK__VERSION
*
* @param {object} state - Global state tree
* @return {string} Version number. Empty string if the data is not yet available.
*/
export function getCurrentVersion( state ) {
return state.jetpack.initialState?.currentVersion ?? '';
}
/**
* Returns an object of the current site roles.
*
* @param {object} state - Global state tree
* @return {object} Site roles
*/
export function getSiteRoles( state ) {
return state.jetpack.initialState.stats?.roles ?? {};
}
/**
* Returns the initial state of the stats data.
*
* @param {object} state - Global state tree
* @return {object} The initial state of the stats data.
*/
export function getInitialStateStatsData( state ) {
return state.jetpack.initialState.stats?.data;
}
/**
* Returns an object of plugins that are using the Jetpack connection.
*
* @param {object} state - Global state tree
* @return {object} Plugins that are using the Jetpack connection.
*/
export function getInitialStateConnectedPlugins( state ) {
return state.jetpack.initialState?.connectedPlugins ?? {};
}
/**
* Returns the email address of the connected user if they are the current user.
*
* @param {object} state - Global state tree
* @return {string} The email address of the current user. .
*/
export function getAdminEmailAddress( state ) {
return state.jetpack.initialState?.userData?.currentUser?.wpcomUser?.email;
}
/**
* Returns the current users email address.
*
* @param {object} state - Global state tree
* @return {string} The email address of the current user. .
*/
export function getCurrenUserEmailAddress( state ) {
return state.jetpack.initialState?.userData?.currentUser?.email;
}
/**
* Returns the site's raw url.
*
* @param {object} state - Global state tree
* @return {object} The site's raw url.
*/
export function getSiteRawUrl( state ) {
return state.jetpack.initialState?.rawUrl ?? {};
}
/**
* Returns the site's admin url.
*
* @param {object} state - Global state tree
* @return {object} The site's admin url.
*/
export function getSiteAdminUrl( state ) {
return state.jetpack.initialState?.adminUrl ?? {};
}
/**
* Returns the site title.
*
* @param {object} state - Global state tree
* @return {string} The site's title.
*/
export function getSiteTitle( state ) {
return state.jetpack.initialState?.siteTitle ?? '';
}
/**
* Return whether or not the site is public.
*
* @param {object} state - Global state tree
* @return {boolean} Whether the site is public.
*/
export function isSitePublic( state ) {
return state.jetpack.initialState?.connectionStatus?.isPublic;
}
/**
* Return whether or not Gutenberg is available.
*
* @param {object} state - Global state tree
* @return {boolean} Whether Gutenberg is available.
*/
export function isGutenbergAvailable( state ) {
return state.jetpack.initialState?.is_gutenberg_available ?? false;
}
/**
* Return whether or not the current user is a subscriber on the site.
*
* @param {object} state - Global state tree
* @return {boolean} Whether the current user is a subscriber.
*/
export function userIsSubscriber( state ) {
return ! state.jetpack.initialState.userData.currentUser.permissions?.edit_posts;
}
/**
* Return whether or not the user can publish posts.
*
* @param {object} state - Global state tree
* @return {boolean} Whether the user can publish posts.
*/
export function userCanPublish( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.publish_posts ?? false;
}
/**
* Return whether or not the user can manage modules.
*
* @param {object} state - Global state tree
* @return {boolean} Whether the user can manage modules.
*/
export function userCanManageModules( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.manage_modules ?? false;
}
/**
* Return whether or not the user can manage options.
*
* @param {object} state - Global state tree
* @return {boolean} Whether the user can manage options.
*/
export function userCanManageOptions( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.manage_options ?? false;
}
/**
* Return true if user can edit posts, usually admins, editors, authors and contributors.
*
* @param {object} state - Global state tree
*
* @return {boolean} Whether user can edit posts.
*/
export function userCanEditPosts( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.edit_posts ?? false;
}
/**
* Return true if user can manage plugins, which means being able to install, activate, update and delete plugins.
*
* @param {object} state - Global state tree
*
* @return {boolean} Whether user can manage plugins.
*/
export function userCanManagePlugins( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.manage_plugins ?? false;
}
/**
* Returns true if the user has permission to disconnect the site.
*
* @param {object} state - Global state tree
* @return {boolean} Whether the user can disconnect the site.
*/
export function userCanDisconnectSite( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.disconnect ?? false;
}
/**
* Returns true if the user has permission to connect the site.
*
* @param {object} state - Global state tree
* @return {boolean} Whether the user can connect the site.
*/
export function userCanConnectSite( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.connect ?? false;
}
/**
* Returns true if current user can connect their WordPress.com account.
*
* @param {object} state - Global state tree
*
* @return {boolean} Whether current user can connect their WordPress.com account.
*/
export function userCanConnectAccount( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.connect_user ?? false;
}
/**
* Returns true if current user is connection owner.
*
* @param {object} state - Global state tree
* @return {boolean} true if the current user is connection owner, false otherwise
*
* @deprecated 9.3.0
*/
export function userIsMaster( state ) {
return state.jetpack.initialState.userData.currentUser?.isMaster ?? false;
}
/**
* Return the current user's WordPress.com login.
*
* @param {object} state - Global state tree
* @return {string} The WordPress.com login of the current user.
*/
export function getUserWpComLogin( state ) {
return state.jetpack.initialState.userData.currentUser?.wpcomUser?.login ?? '';
}
/**
* Returns the WPCOM ID of the connected user.
*
* @param {object} state - Global state tree
* @return {number} the ID of the user
*/
export function getUserWpComId( state ) {
return state.jetpack.initialState.userData.currentUser?.wpcomUser?.ID ?? '';
}
/**
* Return the current user's WordPress.com email.
*
* @param {object} state - Global state tree
* @return {string} The WordPress.com email of the current user.
*/
export function getUserWpComEmail( state ) {
return state.jetpack.initialState.userData.currentUser?.wpcomUser?.email ?? '';
}
/**
* Return the current user's WordPress.com avatar URL.
*
* @param {object} state - Global state tree
* @return {string} The WordPress.com avatar URL of the current user.
*/
export function getUserWpComAvatar( state ) {
return state.jetpack.initialState.userData.currentUser?.wpcomUser?.avatar;
}
/**
* Return the current user's WordPress.com Gravatar.
*
* @param {object} state - Global state tree
* @return {string} The WordPress.com Gravatar of the current user.
*/
export function getUserGravatar( state ) {
return state.jetpack.initialState.userData.currentUser?.gravatar;
}
/**
* Return the current user's username.
*
* @param {object} state - Global state tree
* @return {string} The username of the current user.
*/
export function getUsername( state ) {
return state.jetpack.initialState.userData.currentUser?.username;
}
/**
* Gets the current user display name.
* @param {object} state - Global state tree
* @return {string} The user display name.
*/
export function getDisplayName( state ) {
const displayName = state.jetpack.initialState.userData.currentUser?.displayName;
if ( displayName === null ) {
return getUsername( state );
}
return displayName;
}
/**
* Gets the current wp-admin user id
* @param {object} state - Global state tree
* @return {number} The user id in wp-admin
*/
export function getUserId( state ) {
return state.jetpack.initialState.userData.currentUser?.id ?? '';
}
/**
* Return whether the current user can view stats.
*
* @param {object} state - Global state tree
* @return {boolean} Whether the current user can view stats.
*/
export function userCanViewStats( state ) {
return state.jetpack.initialState.userData.currentUser.permissions?.view_stats ?? false;
}
/**
* Returns the WPCOM ID of a connected site.
*
* @param {object} state - Global state tree
* @return {number} the ID of the site
*/
export function getSiteId( state ) {
return state.jetpack.initialState.siteData?.blog_id;
}
/**
* Returns the site icon as an image URL.
*
* @param {object} state - Global state tree
*
* @return {string} the URL of the icon
*/
export function getSiteIcon( state ) {
return state.jetpack.initialState.siteData?.icon;
}
/**
* Returns the site representative image as an image URL.
*
* @param {object} state - Global state tree
*
* @return {string} the URL of the representative image
*/
export function getSiteRepresentativeImage( state ) {
return state.jetpack.initialState.siteData?.representativeImage;
}
/**
* Check whether the site is accessible by search engines or not. It's true by default in an initial WP installation.
*
* @param {object} state - Global state tree
*
* @return {boolean} False if site is set to discourage search engines from indexing it. True otherwise.
*/
export function isSiteVisibleToSearchEngines( state ) {
return state.jetpack.initialState.siteData?.siteVisibleToSearchEngines ?? true;
}
/**
* Return the WP API nonce.
*
* @param {object} state - Global state tree
* @return {string} The WP API nonce.
*/
export function getApiNonce( state ) {
return state.jetpack.initialState?.WP_API_nonce;
}
/**
* Return the WP API root URL.
*
* @param {object} state - Global state tree
* @return {string} The WP API root URL.
*/
export function getApiRootUrl( state ) {
return state.jetpack.initialState?.WP_API_root;
}
/**
* Return the data the plugins page needs to send the deactivation survey.
*
* @param {object} state - Global state tree
* @return {object|undefined} The site ID and whether any user is connected.
*/
export function getPluginDeactivationData( state ) {
return state.jetpack.initialState?.pluginDeactivation;
}
/**
* Returns the registration nonce.
*
* @deprecated since 14.5
*
* @return {string} The empty string for backward compatibility.
*/
export function getRegistrationNonce() {
return '';
}
/**
* Returns the plugin base URL.
*
* @param {object} state - Global state tree
* @return {string} The registration nonce
*/
export function getPluginBaseUrl( state ) {
return state.jetpack.initialState?.pluginBaseUrl;
}
/**
* Returns a purchase token that is used for Jetpack logged out visitor checkout.
*
* @param {object} state - Global state tree
*
* @return {string|boolean} purchase token or false if not the connection owner.
*/
export function getPurchaseToken( state ) {
return state.jetpack.initialState?.purchaseToken;
}
/**
* Returns current Calypso environment.
*
* @param {object} state - Global state tree
*
* @return {string} Calypso environment name.
*/
export function getCalypsoEnv( state ) {
return state.jetpack.initialState?.calypsoEnv;
}
/**
* Returns the current user tracks data.
*
* @param { object } state - Global state tree
* @return { object } The current user tracks data.
*/
export function getTracksUserData( state ) {
return state.jetpack.initialState?.tracksUserData;
}
/**
* Return the current IP address of the site.
*
* @param {object} state - Global state tree
* @return {string} The current IP address of the site.
*/
export function getCurrentIp( state ) {
return state.jetpack.initialState?.currentIp;
}
/**
* Returns a permalink to the last published entry of 'post' type.
*
* @param {object} state - Global state tree
*
* @return {string} URL to last published post.
*/
export function getLastPostUrl( state ) {
return state.jetpack.initialState?.lastPostUrl;
}
/**
* Check if promotions like banners are visible or hidden.
*
* @param {object} state - Global state tree
*
* @return {boolean} True if promotions are active, false otherwise.
*/
export function arePromotionsActive( state ) {
return state.jetpack.initialState.siteData?.showPromotions ?? true;
}
/**
* Get the current theme's stylesheet (slug).
*
* @param {object} state - Global state tree.
* @return {string} theme stylesheet, e.g. twentytwentythree.
*/
export function currentThemeStylesheet( state ) {
return state.jetpack.initialState.themeData?.stylesheet;
}
/**
* Check that theme supports a certain feature
*
* @param {object} state - Global state tree.
* @param {string} feature - Feature to check if current theme supports. Can be 'infinite-scroll'.
*
* @return {boolean} URL to last published post.
*/
export function currentThemeSupports( state, feature ) {
return state.jetpack.initialState.themeData?.support?.[ feature ] ?? false;
}
/**
* Check that the current theme is a block theme.
*
* @param {object} state - Global state tree.
* @return {boolean} True if the current theme is a block theme, false otherwise.
*/
export function currentThemeIsBlockTheme( state ) {
return state.jetpack.initialState.themeData?.isBlockTheme ?? false;
}
/**
* Check if backups UI should be displayed.
*
* @param {object} state - Global state tree
*
* @return {boolean} True if backups UI should be displayed.
*/
export function showBackups( state ) {
return state.jetpack.initialState.siteData?.showBackups ?? true;
}
/**
* Check if scan UI should be displayed.
*
* @param {object} state - Global state tree
*
* @return {boolean} True if scan UI should be displayed.
*/
export function showScan( state ) {
return state.jetpack.initialState.siteData?.showScan ?? true;
}
/**
* Determines if My Jetpack should be referenced.
*
* @param {object} state - Global state tree
* @return {boolean} True if the My Jetpack should be referenced, false otherwise.
*/
export function showMyJetpack( state ) {
return state.jetpack.initialState.siteData?.showMyJetpack ?? true;
}
/**
* Determines if the Jetpack Licensing UI should be displayed
*
* @param {object} state - Global state tree
*
* @return {boolean} True if the Jetpack Licensing UI should be displayed, false otherwise.
*/
export function showLicensingUi( state ) {
return state.jetpack.initialState.licensing?.showLicensingUi ?? false;
}
/**
* Check if the site is part of a Multisite network.
*
* @param {object} state - Global state tree
*
* @return {boolean} True if the site is part of a Multisite network.
*/
export function isMultisite( state ) {
return state.jetpack.initialState.siteData?.isMultisite ?? false;
}
/**
* Get the site's date format, in format accepted by DateTimeInterface::format().
*
* @param {object} state - Global state tree
*
* @return {string} Date format of the site.
*/
export function getDateFormat( state ) {
return state.jetpack.initialState.siteData?.dateFormat ?? false;
}
/**
* Returns the affiliate code, if it exists. Otherwise an empty string.
*
* @param {object} state - Global state tree
*
* @return {string} The affiliate code.
*/
export function getAffiliateCode( state ) {
return state.jetpack.initialState?.aff ?? '';
}
/**
* Returns the partner subsidiary id, if it exists. Otherwise an empty string.
*
* @param {object} state - Global state tree
*
* @return {string} The partner subsidiary id.
*/
export function getPartnerSubsidiaryId( state ) {
return state.jetpack.initialState?.partnerSubsidiaryId ?? '';
}
/**
* Return an upgrade URL
*
* @param {object} state - Global state tree
* @param {string} source - Context where this URL is clicked.
* @param {string} userId - Current user id.
* @param {boolean} planDuration - Add plan duration to the URL.
*
* @return {string} Upgrade URL with source, site, and affiliate code added.
*/
export const getUpgradeUrl = ( state, source, userId = '', planDuration = false ) => {
const affiliateCode = getAffiliateCode( state );
const subsidiaryId = getPartnerSubsidiaryId( state );
const uid = userId || getUserId( state );
const purchaseToken = getPurchaseToken( state );
const calypsoEnv = getCalypsoEnv( state );
const blogID = getSiteId( state );
Iif ( planDuration && 'monthly' === getPlanDuration( state ) ) {
source += '-monthly';
}
const redirectArgs = {
site: blogID ?? getSiteRawUrl( state ),
};
Iif ( affiliateCode ) {
redirectArgs.aff = affiliateCode;
}
Iif ( uid ) {
redirectArgs.u = uid;
}
Iif ( subsidiaryId ) {
redirectArgs.subsidiaryId = subsidiaryId;
}
redirectArgs.query = '';
Iif ( ! isCurrentUserLinked( state ) ) {
redirectArgs.query += 'unlinked=1&';
}
Iif ( purchaseToken ) {
redirectArgs.query += `purchasetoken=${ purchaseToken }`;
}
Iif ( calypsoEnv ) {
redirectArgs.calypso_env = calypsoEnv;
}
return getRedirectUrl( source, redirectArgs );
};
/**
* Get the connection errors.
*
* @param {object} state - Global state tree.
* @return {Array} Connection errors.
*/
export function getConnectionErrors( state ) {
return ( state.jetpack.initialState?.connectionStatus?.errors ?? [] ).filter( error =>
Object.hasOwn( error, 'action' )
);
}
/**
* Check if the user is on Safari browser.
*
* @param {object} state - Global state tree.
*
* @return {boolean} True the user is on Safari browser.
*/
export function isSafari( state ) {
return !! state.jetpack.initialState.isSafari;
}
/**
* Check if the `JETPACK_SHOULD_NOT_USE_CONNECTION_IFRAME` constant is true.
*
* @param {object} state - Global state tree.
*
* @return {boolean} True, the `JETPACK_SHOULD_NOT_USE_CONNECTION_IFRAME` constant is true.
*/
export function doNotUseConnectionIframe( state ) {
return !! state.jetpack.initialState.doNotUseConnectionIframe;
}
/**
* Returns the Jetpack Cloud URL for the specified resource for the current site.
*
* @param {object} state - Global state tree.
* @param {string} slug - Jetpack Cloud resource slug.
* @return {string} The valid Jetpack Cloud URL
*/
export function getJetpackCloudUrl( state, slug ) {
return `https://cloud.jetpack.com/${ slug }/${ getSiteRawUrl( state ) }`;
}
/**
* Returns if the new Stats experience is enabled.
*
* @param {object} state - Global state tree.
* @return {boolean} True if the new Stats experience is enabled.
*/
export function isOdysseyStatsEnabled( state ) {
return !! state.jetpack.initialState.isOdysseyStatsEnabled;
}
/**
* Returns true if Blaze can be used on the site.
*
* @param {object} state - Global state tree.
* @return {object} A boolean indicating if Blaze can be used and a reason why if it cannot.
*/
export function shouldInitializeBlaze( state ) {
return state.jetpack.initialState.shouldInitializeBlaze;
}
/**
* Returns true if the wp-admin Blaze dashboard is enabled.
*
* @param {object} state - Global state tree.
* @return {boolean} True if the Blaze dashboard is enabled.
*/
export function isBlazeDashboardEnabled( state ) {
return !! state.jetpack.initialState.isBlazeDashboardEnabled;
}
/**
* Returns true if the wp-admin Subscriber dashboard is enabled.
*
* @param {object} state - Global state tree.
* @return {boolean} True if the Subscriber dashboard is enabled.
*/
export function isWpAdminSubscriberManagementEnabled( state ) {
return !! state.jetpack.initialState.isWpAdminSubscriberManagementEnabled;
}
/**
* Check if the Sharing block is available on the site.
*
* @param {object} state - Global state tree.
* @return {boolean} True if the Sharing block is available on the site.
*/
export function isSharingBlockAvailable( state ) {
return !! state.jetpack.initialState.siteData.isSharingBlockAvailable;
}
/**
* Check if the Like block is available on the site.
*
* @param {object} state - Global state tree.
* @return {boolean} True if the Like block is available on the site.
*/
export function isLikeBlockAvailable( state ) {
return !! state.jetpack.initialState.siteData.isLikeBlockAvailable;
}
/**
* Check if the comment form can offer the block editor.
*
* @param {object} state - Global state tree.
* @return {boolean} True if the comment form can offer the block editor.
*/
export function isCommentBlocksAvailable( state ) {
return !! state.jetpack.initialState.siteData?.isCommentBlocksAvailable;
}
/**
* Returns true if Subscription Site feature is enabled on the site.
*
* @param {object} state - Global state tree.
* @return {boolean} True if Subscription Site feature is enabled on the site.
*/
export function isSubscriptionSiteEnabled( state ) {
return !! state.jetpack.initialState.isSubscriptionSiteEnabled;
}
/**
* returns the newletter date example.
*
* @param {object} state - Global state tree.
* @return {string} Newsletter date example.
*/
export function getNewsletterDateExample( state ) {
return state.jetpack.initialState.newsletterDateExample;
}
/**
* Returns true if Subscription Site editing feature is supported.
*
* @param {object} state - Global state tree.
* @return {boolean} True if Subscription Site editing feature is supported.
*/
export function subscriptionSiteEditSupported( state ) {
return !! state.jetpack.initialState.subscriptionSiteEditSupported;
}
/**
* Returns true if the wp-admin SEO Enhancer setting/feature is available.
*
* @param {object} state - Global state tree.
* @return {boolean} True if the SEO Enhancer is available.
*/
export function isSeoEnhancerAvailable( state ) {
return 'ai_seo_enhancer_enabled' in state.jetpack.initialState.getModules[ 'seo-tools' ].options;
}
/**
* Returns whether Jetpack AI is effectively enabled, as the server computed it
* through the full gate chain. Defaults to true when absent so the UI never
* reports AI off on its own authority.
*
* @param {object} state - Global state tree.
* @return {boolean} Whether Jetpack AI is effectively enabled.
*/
export function isAiEnabled( state ) {
return state.jetpack.initialState.isAiEnabled ?? true;
}
/**
* Returns whether the AI SEO feature is effectively enabled, as the server
* computed it (its own toggle plus the AI gates). Defaults to true when absent
* so the UI never reports the feature off on its own authority.
*
* @param {object} state - Global state tree.
* @return {boolean} Whether the AI SEO feature is effectively enabled.
*/
export function isAiSeoEnabled( state ) {
return state.jetpack.initialState.isAiSeoEnabled ?? true;
}
|