Skip to content

Commit

Permalink
add isWooSEOActive to store
Browse files Browse the repository at this point in the history
  • Loading branch information
vraja-pro committed Jan 22, 2024
1 parent 956dfee commit ddf40a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/js/src/components/SchemaTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import PropTypes from "prop-types";
import styled from "styled-components";
import WooCommerceUpsell from "./WooCommerceUpsell";
import { get } from "lodash";
import { useSelect } from "@wordpress/data";

const NewsLandingPageLink = makeOutboundLink();

const SchemaContainer = styled.div`
padding: 16px;
`;

const STORE = "yoast-seo/editor";

/**
* The NewsAlert upsell.
*
Expand Down Expand Up @@ -66,7 +69,9 @@ NewsAlert.propTypes = {
* @returns {Object[]} A copy of the schema type options.
*/
const getSchemaTypeOptions = ( schemaTypeOptions, defaultType, postTypeName ) => {
const disablePageTypeSelect = get( window, "wpseoScriptData.postType", "" ) === "product" && get( window, "wpseoScriptData.isWooCommerceSEOActive", false );
const isProduct = useSelect( ( select ) => select( STORE ).getIsProduct(), [] );
const isWooSeoActive = useSelect( select => select( STORE ).getIsWooSeoActive(), [] );
const disablePageTypeSelect = isProduct && isWooSeoActive;
const schemaOption = disablePageTypeSelect ? { name: __( "Item Page", "wordpress-seo" ), value: "ItemPage" } : schemaTypeOptions.find( option => option.value === defaultType );
return [
{
Expand Down Expand Up @@ -165,7 +170,10 @@ const Content = ( props ) => {
const woocommerceUpsell = get( window, "wpseoScriptData.woocommerceUpsell", "" );
const [ focusedArticleType, setFocusedArticleType ] = useState( props.schemaArticleTypeSelected );
const woocommerceUpsellText = __( "Want your products stand out in search results with rich results like price, reviews and more?", "wordpress-seo" );
const disablePageTypeSelect = get( window, "wpseoScriptData.postType", "" ) === "product" && get( window, "wpseoScriptData.isWooCommerceSEOActive", false );
const isProduct = useSelect( ( select ) => select( STORE ).getIsProduct(), [] );
const isWooSeoActive = useSelect( select => select( STORE ).getIsWooSeoActive(), [] );

const disablePageTypeSelect = isProduct && isWooSeoActive;

const handleOptionChange = useCallback(
( _, value ) => {
Expand Down
8 changes: 8 additions & 0 deletions packages/js/src/redux/selectors/isWooSEO.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ import { get } from "lodash";
* @returns {Boolean} Whether the plugin is WooCommerce SEO or not.
*/
export const getIsWooSeoUpsell = () => get( window, "wpseoScriptData.woocommerceUpsell", false );


/**
* Determines whether the WooCommerce SEO addon is active.
*
* @returns {Boolean} Whether the plugin is WooCommerce SEO or not.
*/
export const getIsWooSeoActive = () => Boolean( get( window, "wpseoScriptData.isWooCommerceSeoActive", false ) );

0 comments on commit ddf40a8

Please sign in to comment.