Commit inicial powerservice
This commit is contained in:
BIN
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
File diff suppressed because one or more lines are too long
+112
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* LinksPage component.
|
||||
*
|
||||
* Main Links admin page with Posts and Links tabs.
|
||||
* Uses DashboardHeader and TabPanel from @rank-math/components.
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n'
|
||||
import { useState, useEffect, createElement } from '@wordpress/element'
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import Posts from './tabs/Posts'
|
||||
import Links from './tabs/Links'
|
||||
import BulkUpdate from './tabs/BulkUpdate'
|
||||
import KeywordMaps from './tabs/KeywordMaps'
|
||||
import { DashboardHeader, TabPanel } from '@rank-math/components'
|
||||
|
||||
/**
|
||||
* Parse URL hash to get active tab name.
|
||||
*
|
||||
* @param {string} hash URL hash string.
|
||||
* @return {string} Active tab name ('posts' or 'links').
|
||||
*/
|
||||
const getTabFromHash = ( hash ) => {
|
||||
if ( ! hash || hash === '#' ) {
|
||||
return 'posts'
|
||||
}
|
||||
const tabName = hash.replace( '#', '' ).split( '?' )[ 0 ]
|
||||
return tabName
|
||||
}
|
||||
|
||||
const getTabs = () => [
|
||||
{
|
||||
id: 'posts',
|
||||
name: 'posts',
|
||||
title: __( 'Posts', 'seo-by-rank-math' ),
|
||||
view: Posts,
|
||||
className: 'rank-math-posts-tab rank-math-tab',
|
||||
},
|
||||
{
|
||||
id: 'links',
|
||||
name: 'links',
|
||||
title: __( 'Links', 'seo-by-rank-math' ),
|
||||
view: Links,
|
||||
className: 'rank-math-links-tab rank-math-tab',
|
||||
},
|
||||
{
|
||||
id: 'bulk-update',
|
||||
name: 'bulk-update',
|
||||
title: __( 'Bulk Update', 'seo-by-rank-math' ),
|
||||
view: BulkUpdate,
|
||||
className: 'rank-math-bulk-update-tab rank-math-tab',
|
||||
},
|
||||
{
|
||||
id: 'keyword-maps',
|
||||
name: 'keyword-maps',
|
||||
title: __( 'Keyword Maps', 'seo-by-rank-math' ),
|
||||
view: KeywordMaps,
|
||||
className: 'rank-math-keyword-maps-tab rank-math-tab',
|
||||
},
|
||||
]
|
||||
|
||||
/**
|
||||
* Main Links page component.
|
||||
*/
|
||||
const LinksPage = () => {
|
||||
const [ currentHash, setCurrentHash ] = useState( window.location.hash )
|
||||
|
||||
useEffect( () => {
|
||||
const handleHashChange = () => {
|
||||
setCurrentHash( window.location.hash )
|
||||
}
|
||||
window.addEventListener( 'hashchange', handleHashChange )
|
||||
return () => window.removeEventListener( 'hashchange', handleHashChange )
|
||||
}, [] )
|
||||
|
||||
const activeTab = getTabFromHash( currentHash )
|
||||
|
||||
return (
|
||||
<>
|
||||
<DashboardHeader page={ __( 'AI Link Genius', 'seo-by-rank-math' ) } />
|
||||
<div className="wrap rank-math-wrap rank-math-links-page">
|
||||
<TabPanel
|
||||
key={ activeTab }
|
||||
className="rank-math-tabs"
|
||||
activeClass="is-active"
|
||||
initialTabName={ activeTab }
|
||||
tabs={ getTabs() }
|
||||
onSelect={ ( tabName ) => {
|
||||
const currentTabName = getTabFromHash( window.location.hash )
|
||||
if ( currentTabName !== tabName ) {
|
||||
window.location.hash = tabName
|
||||
}
|
||||
} }
|
||||
>
|
||||
{ ( tab ) => (
|
||||
<div className={ 'rank-math-tab-content rank-math-tab-content-' + tab.name }>
|
||||
{ createElement( tab.view, { key: tab.name } ) }
|
||||
</div>
|
||||
) }
|
||||
</TabPanel>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default LinksPage
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* useTableData hook.
|
||||
*
|
||||
* Fetches paginated, filterable table data from a REST endpoint.
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import { useState, useEffect, useCallback, useRef } from '@wordpress/element'
|
||||
import apiFetch from '@wordpress/api-fetch'
|
||||
|
||||
/**
|
||||
* Fetch data from a REST endpoint with query args.
|
||||
*
|
||||
* @param {string} endpoint REST endpoint path (e.g. '/rankmath/v1/links/posts').
|
||||
* @param {Object} params Query parameters.
|
||||
* @return {Promise<Object>} Response data.
|
||||
*/
|
||||
const fetchData = ( endpoint, params ) => {
|
||||
const query = Object.entries( params )
|
||||
.filter( ( [ , v ] ) => v !== '' && v !== null && v !== undefined )
|
||||
.map( ( [ k, v ] ) => {
|
||||
if ( Array.isArray( v ) ) {
|
||||
return v.map( ( item ) => `${ encodeURIComponent( k ) }[]=${ encodeURIComponent( item ) }` ).join( '&' )
|
||||
}
|
||||
return `${ encodeURIComponent( k ) }=${ encodeURIComponent( v ) }`
|
||||
} )
|
||||
.join( '&' )
|
||||
|
||||
return apiFetch( { path: `${ endpoint }?${ query }` } )
|
||||
}
|
||||
|
||||
/**
|
||||
* useTableData hook.
|
||||
*
|
||||
* @param {Object} options Hook options.
|
||||
* @param {string} options.dataEndpoint REST endpoint for rows.
|
||||
* @param {string} options.statsEndpoint REST endpoint for stats.
|
||||
* @param {Object} options.initialFilters Initial filter values.
|
||||
* @return {Object} Table state and handlers.
|
||||
*/
|
||||
const useTableData = ( { dataEndpoint, statsEndpoint, initialFilters = {} } ) => {
|
||||
const [ data, setData ] = useState( [] )
|
||||
const [ stats, setStats ] = useState( null )
|
||||
const [ loading, setLoading ] = useState( true )
|
||||
const [ filters, setFilters ] = useState( initialFilters )
|
||||
const [ sortConfig, setSortConfig ] = useState( {
|
||||
orderby: initialFilters.orderby || '',
|
||||
order: initialFilters.order || 'ASC',
|
||||
} )
|
||||
const [ pagination, setPagination ] = useState( {
|
||||
page: 1,
|
||||
perPage: 10,
|
||||
total: 0,
|
||||
pages: 0,
|
||||
} )
|
||||
|
||||
const fetchingRef = useRef( false )
|
||||
const isMountedRef = useRef( true )
|
||||
|
||||
useEffect( () => {
|
||||
isMountedRef.current = true
|
||||
return () => {
|
||||
isMountedRef.current = false
|
||||
}
|
||||
}, [] )
|
||||
|
||||
const fetchAll = useCallback( async ( currentFilters, currentSort, currentPage, perPage ) => {
|
||||
if ( fetchingRef.current ) {
|
||||
return
|
||||
}
|
||||
fetchingRef.current = true
|
||||
setLoading( true )
|
||||
|
||||
const params = {
|
||||
...currentFilters,
|
||||
orderby: currentSort.orderby,
|
||||
order: currentSort.order,
|
||||
page: currentPage,
|
||||
per_page: perPage,
|
||||
}
|
||||
|
||||
try {
|
||||
const [ dataResponse, statsResponse ] = await Promise.all( [
|
||||
fetchData( dataEndpoint, params ),
|
||||
statsEndpoint ? fetchData( statsEndpoint, {} ) : Promise.resolve( null ),
|
||||
] )
|
||||
|
||||
if ( ! isMountedRef.current ) {
|
||||
return
|
||||
}
|
||||
|
||||
// Determine data key from response (posts or links).
|
||||
const dataKey = dataResponse.posts ? 'posts' : 'links'
|
||||
setData( dataResponse[ dataKey ] || [] )
|
||||
setPagination( ( prev ) => ( {
|
||||
...prev,
|
||||
page: currentPage,
|
||||
perPage,
|
||||
total: dataResponse.total || 0,
|
||||
pages: dataResponse.pages || 0,
|
||||
} ) )
|
||||
|
||||
if ( statsResponse ) {
|
||||
setStats( statsResponse )
|
||||
}
|
||||
} catch ( error ) {
|
||||
if ( isMountedRef.current ) {
|
||||
setData( [] )
|
||||
}
|
||||
} finally {
|
||||
if ( isMountedRef.current ) {
|
||||
setLoading( false )
|
||||
}
|
||||
fetchingRef.current = false
|
||||
}
|
||||
}, [ dataEndpoint, statsEndpoint ] ) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Re-fetch when filters, sort, or page changes.
|
||||
useEffect( () => {
|
||||
fetchAll( filters, sortConfig, pagination.page, pagination.perPage )
|
||||
}, [ filters, sortConfig, pagination.page, pagination.perPage ] ) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const handleFilterChange = useCallback( ( key, value ) => {
|
||||
setFilters( ( prev ) => ( { ...prev, [ key ]: value } ) )
|
||||
setPagination( ( prev ) => ( { ...prev, page: 1 } ) )
|
||||
}, [] )
|
||||
|
||||
const handlePageChange = useCallback( ( newPage ) => {
|
||||
setPagination( ( prev ) => ( { ...prev, page: newPage } ) )
|
||||
}, [] )
|
||||
|
||||
const handlePerPageChange = useCallback( ( newPerPage ) => {
|
||||
setPagination( ( prev ) => ( { ...prev, page: 1, perPage: newPerPage } ) )
|
||||
}, [] )
|
||||
|
||||
const handleSortChange = useCallback( ( orderby, order ) => {
|
||||
setSortConfig( { orderby, order } )
|
||||
setPagination( ( prev ) => ( { ...prev, page: 1 } ) )
|
||||
}, [] )
|
||||
|
||||
return {
|
||||
data,
|
||||
stats,
|
||||
loading,
|
||||
pagination,
|
||||
filters,
|
||||
sortConfig,
|
||||
handleFilterChange,
|
||||
handlePageChange,
|
||||
handlePerPageChange,
|
||||
handleSortChange,
|
||||
}
|
||||
}
|
||||
|
||||
export default useTableData
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import ErrorCTA from '@components/ErrorCTA'
|
||||
|
||||
const BulkUpdate = () => {
|
||||
const imagesUrl = window.rankMath.links?.imagesUrl || ''
|
||||
|
||||
return (
|
||||
<div className="rank-math-pro-tab-preview">
|
||||
<img src={ imagesUrl + 'bulk-update.jpg' } alt="" />
|
||||
<ErrorCTA showProNotice={ true } width="width-50" medium="Bulk+Update" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BulkUpdate
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import ErrorCTA from '@components/ErrorCTA'
|
||||
|
||||
const KeywordMaps = () => {
|
||||
const imagesUrl = window.rankMath.links?.imagesUrl || ''
|
||||
|
||||
return (
|
||||
<div className="rank-math-pro-tab-preview">
|
||||
<img src={ imagesUrl + 'keyword-maps.jpg' } alt="" />
|
||||
<ErrorCTA showProNotice={ true } width="width-50" medium="Keyword+Maps" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default KeywordMaps
|
||||
+268
@@ -0,0 +1,268 @@
|
||||
/**
|
||||
* Links tab component.
|
||||
*
|
||||
* Shows links with URL, source post, and type.
|
||||
* PRO-only filters (anchor type, nofollow status) appear in the filter row
|
||||
* but open an upgrade CTA when applied.
|
||||
*/
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { get } from 'lodash'
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n'
|
||||
import { useState, useCallback, useMemo } from '@wordpress/element'
|
||||
import { Modal } from '@wordpress/components'
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import useTableData from '../hooks/useTableData'
|
||||
import { parseHashParams, URL_PARAMS, setLinkTypeInHash } from '../urlState'
|
||||
import ErrorCTA from '@components/ErrorCTA'
|
||||
|
||||
const { ListTable, TableSkeleton } = window.rankMathComponents
|
||||
|
||||
/**
|
||||
* PRO upgrade modal.
|
||||
*
|
||||
* @param {Function} onClose Callback to close the modal.
|
||||
*/
|
||||
const ProCTAModal = ( { onClose } ) => (
|
||||
<Modal
|
||||
onRequestClose={ onClose }
|
||||
className="rank-math-contentai-modal rank-math-modal rank-math-error-modal"
|
||||
shouldCloseOnClickOutside={ true }
|
||||
>
|
||||
<ErrorCTA showProNotice={ true } medium="Links" />
|
||||
</Modal>
|
||||
)
|
||||
|
||||
/**
|
||||
* Read link filters from the URL hash (set when navigating from Posts tab counts).
|
||||
*
|
||||
* @return {Object} Initial filter values from URL.
|
||||
*/
|
||||
const getLinksFiltersFromURL = () => {
|
||||
const { searchParams } = parseHashParams()
|
||||
const linkType = searchParams.get( URL_PARAMS.LINK_TYPE ) || ''
|
||||
let isInternal = ''
|
||||
if ( linkType === 'internal' ) {
|
||||
isInternal = '1'
|
||||
} else if ( linkType === 'external' ) {
|
||||
isInternal = '0'
|
||||
}
|
||||
return {
|
||||
source_id: parseInt( searchParams.get( URL_PARAMS.SOURCE_ID ), 10 ) || 0,
|
||||
target_post_id: parseInt( searchParams.get( URL_PARAMS.TARGET_POST_ID ), 10 ) || 0,
|
||||
is_internal: isInternal,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Link type badge.
|
||||
*
|
||||
* @param {string} type 'internal' or 'external'
|
||||
*/
|
||||
const LinkTypeBadge = ( { type } ) => (
|
||||
<span className={ `rank-math-link-type-badge ${ type }` }>
|
||||
{ type === 'internal' ? __( 'Internal', 'seo-by-rank-math' ) : __( 'External', 'seo-by-rank-math' ) }
|
||||
</span>
|
||||
)
|
||||
|
||||
/**
|
||||
* Links tab.
|
||||
*
|
||||
* @return {JSX.Element} Links tab content.
|
||||
*/
|
||||
const Links = () => {
|
||||
const [ upgradeModalOpen, setUpgradeModalOpen ] = useState( false )
|
||||
|
||||
// Read initial filters from URL hash (set when clicking counts in Posts tab)
|
||||
const urlFilters = getLinksFiltersFromURL()
|
||||
|
||||
const {
|
||||
data: links,
|
||||
stats,
|
||||
loading,
|
||||
pagination,
|
||||
filters,
|
||||
sortConfig,
|
||||
handleFilterChange,
|
||||
handlePageChange,
|
||||
handlePerPageChange,
|
||||
handleSortChange,
|
||||
} = useTableData( {
|
||||
dataEndpoint: '/rankmath/v1/links/links',
|
||||
statsEndpoint: '/rankmath/v1/links/links-stats',
|
||||
initialFilters: {
|
||||
search: '',
|
||||
source_id: urlFilters.source_id,
|
||||
target_post_id: urlFilters.target_post_id,
|
||||
is_internal: urlFilters.is_internal,
|
||||
orderby: 'id',
|
||||
order: 'DESC',
|
||||
},
|
||||
} )
|
||||
|
||||
// Table headers
|
||||
const headers = useMemo( () => [
|
||||
{
|
||||
key: 'source_title',
|
||||
label: __( 'Source Post', 'seo-by-rank-math' ),
|
||||
isSortable: true,
|
||||
isHideable: false,
|
||||
render: ( value, row ) => (
|
||||
<>
|
||||
{ row.source_edit_url ? (
|
||||
<a href={ row.source_edit_url } target="_blank" rel="noopener noreferrer">
|
||||
{ value || __( '(no title)', 'seo-by-rank-math' ) }
|
||||
</a>
|
||||
) : (
|
||||
value || __( '(no title)', 'seo-by-rank-math' )
|
||||
) }
|
||||
{ row.source_url && (
|
||||
<div className="rank-math-post-url">{ row.source_url }</div>
|
||||
) }
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'url',
|
||||
label: __( 'Destination', 'seo-by-rank-math' ),
|
||||
isSortable: true,
|
||||
isHideable: false,
|
||||
render: ( value, row ) => (
|
||||
<>
|
||||
<a href={ value } target="_blank" rel="noopener noreferrer">
|
||||
{ row.target_title || value }
|
||||
</a>
|
||||
{ row.target_title && (
|
||||
<div className="rank-math-post-url">{ value }</div>
|
||||
) }
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'type',
|
||||
label: __( 'Link Type', 'seo-by-rank-math' ),
|
||||
isSortable: true,
|
||||
render: ( value ) => <LinkTypeBadge type={ value } />,
|
||||
},
|
||||
], [] )
|
||||
|
||||
// Link type toggle options
|
||||
const linkTypeOptions = [
|
||||
{ label: __( 'All', 'seo-by-rank-math' ), value: '' },
|
||||
{ label: __( 'Internal', 'seo-by-rank-math' ), value: '1', statusType: 'internal' },
|
||||
{ label: __( 'External', 'seo-by-rank-math' ), value: '0', statusType: 'external' },
|
||||
]
|
||||
|
||||
// Link status toggle options (PRO-only — clicking any non-All value opens upgrade modal)
|
||||
const linkStatusOptions = [
|
||||
{ label: __( 'All', 'seo-by-rank-math' ), value: '', statusType: 'all' },
|
||||
{ label: __( 'Success', 'seo-by-rank-math' ), value: '2xx', statusType: 'success' },
|
||||
{ label: __( 'Broken', 'seo-by-rank-math' ), value: 'broken', statusType: 'error' },
|
||||
{ label: __( 'Redirects', 'seo-by-rank-math' ), value: '3xx', statusType: 'warning' },
|
||||
{ label: __( 'Robots Blocked', 'seo-by-rank-math' ), value: 'robots_blocked', statusType: 'blocked' },
|
||||
{ label: __( 'Marked Safe', 'seo-by-rank-math' ), value: 'marked_safe', statusType: 'markedSafe' },
|
||||
{ label: __( 'Unchecked', 'seo-by-rank-math' ), value: 'unchecked', statusType: 'unchecked' },
|
||||
]
|
||||
|
||||
const handleStatusToggle = useCallback( ( value ) => {
|
||||
if ( value !== '' ) {
|
||||
setUpgradeModalOpen( true )
|
||||
}
|
||||
}, [ setUpgradeModalOpen ] )
|
||||
|
||||
const handleSortChange2 = useCallback( ( key ) => {
|
||||
const newOrder = sortConfig.orderby === key && sortConfig.order === 'ASC' ? 'DESC' : 'ASC'
|
||||
handleSortChange( key, newOrder )
|
||||
}, [ sortConfig, handleSortChange ] )
|
||||
|
||||
// Footer stats
|
||||
const footerStats = useMemo( () => {
|
||||
if ( ! stats ) {
|
||||
return []
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
label: __( 'Total Links', 'seo-by-rank-math' ),
|
||||
value: get( stats, 'total', 0 ),
|
||||
},
|
||||
{
|
||||
label: __( 'Internal Links', 'seo-by-rank-math' ),
|
||||
value: get( stats, 'internal', 0 ),
|
||||
},
|
||||
{
|
||||
label: __( 'External Links', 'seo-by-rank-math' ),
|
||||
value: get( stats, 'external', 0 ),
|
||||
},
|
||||
]
|
||||
}, [ stats ] )
|
||||
|
||||
// Controlled sort config
|
||||
const tableSortConfig = useMemo( () => ( {
|
||||
key: sortConfig.orderby,
|
||||
direction: sortConfig.order === 'ASC' ? 'asc' : 'desc',
|
||||
} ), [ sortConfig ] )
|
||||
|
||||
if ( loading && links.length === 0 ) {
|
||||
return <TableSkeleton columns={ 3 } rows={ 10 } />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="rank-math-section-card">
|
||||
{ upgradeModalOpen && (
|
||||
<ProCTAModal onClose={ () => setUpgradeModalOpen( false ) } />
|
||||
) }
|
||||
<ListTable
|
||||
headers={ headers }
|
||||
rows={ links }
|
||||
stats={ footerStats }
|
||||
// Server-side pagination
|
||||
currentPage={ pagination.page }
|
||||
rowsPerPage={ pagination.perPage }
|
||||
totalItems={ pagination.total }
|
||||
totalPages={ pagination.pages }
|
||||
onPageChange={ handlePageChange }
|
||||
onRowsPerPageChange={ handlePerPageChange }
|
||||
// Server-side sorting
|
||||
sortConfig={ tableSortConfig }
|
||||
onSortChange={ handleSortChange2 }
|
||||
// Server-side filtering
|
||||
activeFilters={ filters }
|
||||
onFilterChange={ ( newFilters ) => {
|
||||
Object.entries( newFilters ).forEach( ( [ key, value ] ) => {
|
||||
handleFilterChange( key, value )
|
||||
} )
|
||||
} }
|
||||
// Link type toggle (tab style)
|
||||
primaryToggle={ {
|
||||
options: linkTypeOptions,
|
||||
value: filters.is_internal !== undefined && filters.is_internal !== '' ? String( filters.is_internal ) : '',
|
||||
filterKey: 'is_internal',
|
||||
onChange: ( value ) => {
|
||||
handleFilterChange( 'is_internal', value )
|
||||
setLinkTypeInHash( value )
|
||||
},
|
||||
} }
|
||||
// Link status toggle (colored pills — PRO-only, opens upgrade modal)
|
||||
secondaryToggle={ {
|
||||
options: linkStatusOptions,
|
||||
value: '',
|
||||
onChange: handleStatusToggle,
|
||||
} }
|
||||
storageKey="links-links"
|
||||
/>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Links
|
||||
+364
@@ -0,0 +1,364 @@
|
||||
/**
|
||||
* Posts tab component.
|
||||
*
|
||||
* Shows posts with their internal/external/incoming link counts and SEO score.
|
||||
* Uses the shared ListTable component from @rank-math/components.
|
||||
*/
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { entries, map, reject } from 'lodash'
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n'
|
||||
import { useState, useCallback, useMemo } from '@wordpress/element'
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import useTableData from '../hooks/useTableData'
|
||||
import {
|
||||
parseHashParams,
|
||||
getPostsFiltersFromURL,
|
||||
setPostsFiltersInHash,
|
||||
clearPostsFiltersFromHash,
|
||||
navigateToLinksTab,
|
||||
} from '../urlState'
|
||||
|
||||
const { ListTable, TableSkeleton } = window.rankMathComponents
|
||||
|
||||
/**
|
||||
* Get available post type options from localized data.
|
||||
*
|
||||
* @return {Array} Array of {label, value} options.
|
||||
*/
|
||||
const getPostTypeOptions = () => {
|
||||
const postTypes = map(
|
||||
entries( window.rankMath.links?.postTypes ),
|
||||
( [ value, label ] ) => ( { value, label } )
|
||||
)
|
||||
return reject( postTypes, { value: 'attachment' } )
|
||||
}
|
||||
|
||||
/**
|
||||
* Render SEO score badge.
|
||||
*
|
||||
* @param {number} score SEO score value (0-100).
|
||||
*/
|
||||
const SeoScoreBadge = ( { score } ) => {
|
||||
if ( ! score ) {
|
||||
return (
|
||||
<span className="rank-math-seo-score na">
|
||||
<strong>{ __( 'Not Set', 'seo-by-rank-math' ) }</strong>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
let scoreClass = 'bad'
|
||||
if ( score > 80 ) {
|
||||
scoreClass = 'great'
|
||||
} else if ( score > 50 ) {
|
||||
scoreClass = 'good'
|
||||
}
|
||||
return (
|
||||
<span className={ `rank-math-seo-score ${ scoreClass }` }>
|
||||
<strong>{ score } / 100</strong>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts tab.
|
||||
*
|
||||
* @return {JSX.Element} Posts tab content.
|
||||
*/
|
||||
const Posts = () => {
|
||||
// Read initial filters from URL hash
|
||||
const { tabName, searchParams } = parseHashParams()
|
||||
const urlFilters = getPostsFiltersFromURL( searchParams )
|
||||
|
||||
const [ appliedFilters, setAppliedFilters ] = useState( () => ( {
|
||||
post_type: urlFilters.post_type || [],
|
||||
is_orphan: urlFilters.is_orphan || '',
|
||||
seo_score_range: urlFilters.seo_score_range || '',
|
||||
} ) )
|
||||
|
||||
const {
|
||||
data: posts,
|
||||
stats,
|
||||
loading,
|
||||
pagination,
|
||||
filters,
|
||||
sortConfig,
|
||||
handleFilterChange,
|
||||
handlePageChange,
|
||||
handlePerPageChange,
|
||||
handleSortChange,
|
||||
} = useTableData( {
|
||||
dataEndpoint: '/rankmath/v1/links/posts',
|
||||
statsEndpoint: '/rankmath/v1/links/posts-stats',
|
||||
initialFilters: {
|
||||
search: '',
|
||||
post_type: urlFilters.post_type || [],
|
||||
is_orphan: urlFilters.is_orphan || '',
|
||||
seo_score_range: urlFilters.seo_score_range || '',
|
||||
orderby: 'post_title',
|
||||
order: 'ASC',
|
||||
},
|
||||
} )
|
||||
|
||||
// Navigate to Links tab filtered by this post's links
|
||||
const handleNavigateToLinks = useCallback( ( postId, linkType ) => {
|
||||
const linkFilters = {}
|
||||
if ( linkType === 'incoming' ) {
|
||||
linkFilters.target_post_id = postId
|
||||
} else {
|
||||
linkFilters.source_id = postId
|
||||
if ( linkType === 'internal' ) {
|
||||
linkFilters.link_type = 'internal'
|
||||
} else if ( linkType === 'external' ) {
|
||||
linkFilters.link_type = 'external'
|
||||
}
|
||||
}
|
||||
navigateToLinksTab( linkFilters )
|
||||
}, [] )
|
||||
|
||||
// Table headers definition
|
||||
const headers = useMemo( () => [
|
||||
{
|
||||
key: 'post_title',
|
||||
label: __( 'Post Title', 'seo-by-rank-math' ),
|
||||
isSortable: true,
|
||||
isHideable: false,
|
||||
render: ( value, row ) => (
|
||||
<>
|
||||
{ row.edit_url ? (
|
||||
<a href={ row.edit_url } target="_blank" rel="noopener noreferrer">
|
||||
{ value || __( '(no title)', 'seo-by-rank-math' ) }
|
||||
</a>
|
||||
) : (
|
||||
value || __( '(no title)', 'seo-by-rank-math' )
|
||||
) }
|
||||
{ row.post_url && (
|
||||
<div className="rank-math-post-url">{ row.post_url }</div>
|
||||
) }
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'internal_link_count',
|
||||
label: __( 'Internal Links', 'seo-by-rank-math' ),
|
||||
isSortable: true,
|
||||
render: ( value, row ) => {
|
||||
const count = parseInt( value, 10 ) || 0
|
||||
if ( count === 0 ) {
|
||||
return <span className="rank-math-count-badge">{ count }</span>
|
||||
}
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="rank-math-count-badge rank-math-count-badge-link rank-math-tooltip"
|
||||
onClick={ () => handleNavigateToLinks( row.post_id, 'internal' ) }
|
||||
>
|
||||
{ count }
|
||||
<span>{ __( 'View internal links from this post', 'seo-by-rank-math' ) }</span>
|
||||
</button>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'external_link_count',
|
||||
label: __( 'External Links', 'seo-by-rank-math' ),
|
||||
isSortable: true,
|
||||
render: ( value, row ) => {
|
||||
const count = parseInt( value, 10 ) || 0
|
||||
if ( count === 0 ) {
|
||||
return <span className="rank-math-count-badge">{ count }</span>
|
||||
}
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="rank-math-count-badge rank-math-count-badge-link rank-math-tooltip"
|
||||
onClick={ () => handleNavigateToLinks( row.post_id, 'external' ) }
|
||||
>
|
||||
{ count }
|
||||
<span>{ __( 'View external links from this post', 'seo-by-rank-math' ) }</span>
|
||||
</button>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'incoming_link_count',
|
||||
label: __( 'Incoming Links', 'seo-by-rank-math' ),
|
||||
isSortable: true,
|
||||
render: ( value, row ) => {
|
||||
const count = parseInt( value, 10 ) || 0
|
||||
if ( count === 0 ) {
|
||||
return (
|
||||
<span className="rank-math-orphan-warning rank-math-tooltip" title={ __( 'Orphan post — no incoming links', 'seo-by-rank-math' ) }>
|
||||
<i className="dashicons dashicons-warning" />
|
||||
<span>{ __( 'This post has no internal links. We recommend that you add links to this URL in other posts of your website.', 'seo-by-rank-math' ) }</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="rank-math-count-badge rank-math-count-badge-link rank-math-tooltip"
|
||||
onClick={ () => handleNavigateToLinks( row.post_id, 'incoming' ) }
|
||||
>
|
||||
{ count }
|
||||
<span>{ __( 'View incoming links to this post', 'seo-by-rank-math' ) }</span>
|
||||
</button>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'seo_score',
|
||||
label: __( 'SEO Score', 'seo-by-rank-math' ),
|
||||
isSortable: true,
|
||||
render: ( value ) => <SeoScoreBadge score={ value } />,
|
||||
},
|
||||
{
|
||||
key: 'post_type_label',
|
||||
label: __( 'Type', 'seo-by-rank-math' ),
|
||||
isSortable: false,
|
||||
render: ( value, row ) => value || row.post_type,
|
||||
},
|
||||
], [ handleNavigateToLinks ] )
|
||||
|
||||
// Orphan filter toggle options — statusType drives active/hover color
|
||||
const orphanOptions = [
|
||||
{ label: __( 'All Posts', 'seo-by-rank-math' ), value: '', statusType: 'all' },
|
||||
{ label: __( 'Orphan Posts', 'seo-by-rank-math' ), value: 'orphan', statusType: 'orphan' },
|
||||
{ label: __( 'With Incoming Links', 'seo-by-rank-math' ), value: 'linked', statusType: 'linked' },
|
||||
]
|
||||
|
||||
// SEO score range filter toggle options — statusType drives colored pill colors
|
||||
const seoScoreOptions = [
|
||||
{ label: __( 'All Scores', 'seo-by-rank-math' ), value: '', statusType: 'all' },
|
||||
{ label: __( 'Great', 'seo-by-rank-math' ), value: 'great', statusType: 'great' },
|
||||
{ label: __( 'Good', 'seo-by-rank-math' ), value: 'good', statusType: 'good' },
|
||||
{ label: __( 'Bad', 'seo-by-rank-math' ), value: 'bad', statusType: 'bad' },
|
||||
{ label: __( 'Not Set', 'seo-by-rank-math' ), value: 'no-score', statusType: 'no-score' },
|
||||
]
|
||||
|
||||
// Post type filter via FilterStaging (multi-select)
|
||||
const filterStagingFilters = useMemo( () => [
|
||||
{
|
||||
key: 'post_type',
|
||||
label: __( 'Post Type', 'seo-by-rank-math' ),
|
||||
multiSelect: true,
|
||||
allLabel: __( 'All Types', 'seo-by-rank-math' ),
|
||||
options: getPostTypeOptions(),
|
||||
},
|
||||
], [] )
|
||||
|
||||
const handleSortChange2 = useCallback( ( key ) => {
|
||||
const newOrder = sortConfig.orderby === key && sortConfig.order === 'ASC' ? 'DESC' : 'ASC'
|
||||
handleSortChange( key, newOrder )
|
||||
}, [ sortConfig, handleSortChange ] )
|
||||
|
||||
// Apply staged filters to URL hash and to API
|
||||
const handleApplyFilters = useCallback( ( pendingFilters ) => {
|
||||
setAppliedFilters( pendingFilters )
|
||||
setPostsFiltersInHash( tabName, pendingFilters )
|
||||
if ( pendingFilters.post_type !== undefined ) {
|
||||
handleFilterChange( 'post_type', pendingFilters.post_type )
|
||||
}
|
||||
}, [ tabName, handleFilterChange ] )
|
||||
|
||||
const handleClearFilters = useCallback( ( clearedFilters ) => {
|
||||
setAppliedFilters( clearedFilters )
|
||||
clearPostsFiltersFromHash( tabName )
|
||||
handleFilterChange( 'post_type', [] )
|
||||
}, [ tabName, handleFilterChange ] )
|
||||
|
||||
// Sync toggle filters immediately to URL hash
|
||||
const handleOrphanChange = useCallback( ( value ) => {
|
||||
handleFilterChange( 'is_orphan', value )
|
||||
const newFilters = { ...appliedFilters, is_orphan: value }
|
||||
setAppliedFilters( newFilters )
|
||||
setPostsFiltersInHash( tabName, newFilters )
|
||||
}, [ appliedFilters, tabName, handleFilterChange ] )
|
||||
|
||||
const handleSeoScoreChange = useCallback( ( value ) => {
|
||||
handleFilterChange( 'seo_score_range', value )
|
||||
const newFilters = { ...appliedFilters, seo_score_range: value }
|
||||
setAppliedFilters( newFilters )
|
||||
setPostsFiltersInHash( tabName, newFilters )
|
||||
}, [ appliedFilters, tabName, handleFilterChange ] )
|
||||
|
||||
// Stats for the pagination footer
|
||||
const footerStats = useMemo( () => {
|
||||
if ( ! stats ) {
|
||||
return []
|
||||
}
|
||||
|
||||
return [
|
||||
{ label: __( 'Total Posts', 'seo-by-rank-math' ), value: ( stats.total_posts || 0 ).toLocaleString() },
|
||||
{ label: __( 'Orphan Posts', 'seo-by-rank-math' ), value: ( stats.orphan_posts || 0 ).toLocaleString() },
|
||||
]
|
||||
}, [ stats ] )
|
||||
|
||||
// Controlled sort config for ListTable
|
||||
const tableSortConfig = useMemo( () => ( {
|
||||
key: sortConfig.orderby,
|
||||
direction: sortConfig.order === 'ASC' ? 'asc' : 'desc',
|
||||
} ), [ sortConfig ] )
|
||||
|
||||
if ( loading && posts.length === 0 ) {
|
||||
return <TableSkeleton columns={ 6 } rows={ 10 } />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="rank-math-section-card">
|
||||
<ListTable
|
||||
headers={ headers }
|
||||
rows={ posts }
|
||||
exportFilename="rank-math-posts"
|
||||
stats={ footerStats }
|
||||
// Server-side pagination
|
||||
currentPage={ pagination.page }
|
||||
rowsPerPage={ pagination.perPage }
|
||||
totalItems={ pagination.total }
|
||||
totalPages={ pagination.pages }
|
||||
onPageChange={ handlePageChange }
|
||||
onRowsPerPageChange={ handlePerPageChange }
|
||||
// Server-side sorting
|
||||
sortConfig={ tableSortConfig }
|
||||
onSortChange={ handleSortChange2 }
|
||||
// Server-side filtering (search handled by ListTable's debounced search)
|
||||
activeFilters={ filters }
|
||||
onFilterChange={ ( newFilters ) => {
|
||||
Object.entries( newFilters ).forEach( ( [ key, value ] ) => {
|
||||
handleFilterChange( key, value )
|
||||
} )
|
||||
} }
|
||||
// Orphan filter as primaryToggle (tab style)
|
||||
primaryToggle={ {
|
||||
options: orphanOptions,
|
||||
value: filters.is_orphan || '',
|
||||
onChange: handleOrphanChange,
|
||||
} }
|
||||
// SEO score filter as secondaryToggle (colored pills)
|
||||
secondaryToggle={ {
|
||||
options: seoScoreOptions,
|
||||
value: filters.seo_score_range || '',
|
||||
onChange: handleSeoScoreChange,
|
||||
} }
|
||||
// Post type filter via FilterStaging (multi-select dropdown)
|
||||
filters={ filterStagingFilters }
|
||||
appliedFilters={ appliedFilters }
|
||||
onApplyFilters={ handleApplyFilters }
|
||||
onClearFilters={ handleClearFilters }
|
||||
storageKey="links-posts"
|
||||
/>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Posts
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* URL State Management Utilities
|
||||
*
|
||||
* Handles URL hash parameter synchronization for table state.
|
||||
* Format: #tabname?param=value
|
||||
*/
|
||||
|
||||
export const URL_PARAMS = {
|
||||
POST_TYPE: 'post_type',
|
||||
IS_ORPHAN: 'is_orphan',
|
||||
SEO_SCORE_RANGE: 'seo_score_range',
|
||||
LINK_TYPE: 'link_type',
|
||||
SOURCE_ID: 'source_id',
|
||||
TARGET_POST_ID: 'target_post_id',
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse current hash to get tab name and search params.
|
||||
*
|
||||
* @return {Object} Object with tabName and searchParams.
|
||||
*/
|
||||
export function parseHashParams() {
|
||||
const hash = window.location.hash // eslint-disable-line no-undef
|
||||
|
||||
if ( ! hash || hash === '#' ) {
|
||||
return { tabName: 'posts', searchParams: new URLSearchParams() } // eslint-disable-line no-undef
|
||||
}
|
||||
|
||||
const hashWithoutPrefix = hash.replace( '#', '' )
|
||||
const [ tabName, queryString ] = hashWithoutPrefix.split( '?' )
|
||||
|
||||
return {
|
||||
tabName: tabName || 'posts',
|
||||
searchParams: new URLSearchParams( queryString || '' ), // eslint-disable-line no-undef
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Posts tab filters from URL search params.
|
||||
*
|
||||
* @param {URLSearchParams} searchParams URL search parameters.
|
||||
* @return {Object} Filter object for Posts tab.
|
||||
*/
|
||||
export function getPostsFiltersFromURL( searchParams ) {
|
||||
const postTypeParam = searchParams.get( URL_PARAMS.POST_TYPE ) || ''
|
||||
const postTypes = postTypeParam ? postTypeParam.split( ',' ).filter( Boolean ) : []
|
||||
|
||||
return {
|
||||
post_type: postTypes.length > 0 ? postTypes : [],
|
||||
is_orphan: searchParams.get( URL_PARAMS.IS_ORPHAN ) || '',
|
||||
seo_score_range: searchParams.get( URL_PARAMS.SEO_SCORE_RANGE ) || '',
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Posts tab filters in URL hash.
|
||||
*
|
||||
* @param {string} tabName Current tab name.
|
||||
* @param {Object} filters Filter object to serialize.
|
||||
*/
|
||||
export function setPostsFiltersInHash( tabName, filters ) {
|
||||
const { searchParams } = parseHashParams()
|
||||
|
||||
searchParams.delete( URL_PARAMS.POST_TYPE )
|
||||
searchParams.delete( URL_PARAMS.IS_ORPHAN )
|
||||
searchParams.delete( URL_PARAMS.SEO_SCORE_RANGE )
|
||||
|
||||
if ( filters.post_type && filters.post_type.length > 0 ) {
|
||||
searchParams.set( URL_PARAMS.POST_TYPE, filters.post_type.join( ',' ) )
|
||||
}
|
||||
if ( filters.is_orphan ) {
|
||||
searchParams.set( URL_PARAMS.IS_ORPHAN, filters.is_orphan )
|
||||
}
|
||||
if ( filters.seo_score_range ) {
|
||||
searchParams.set( URL_PARAMS.SEO_SCORE_RANGE, filters.seo_score_range )
|
||||
}
|
||||
|
||||
// Reset to page 1 when filters change.
|
||||
searchParams.set( 'page', '1' )
|
||||
|
||||
const queryString = searchParams.toString()
|
||||
window.location.hash = queryString ? `${ tabName }?${ queryString }` : tabName // eslint-disable-line no-undef
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all Posts tab filters from URL hash.
|
||||
*
|
||||
* @param {string} tabName Current tab name.
|
||||
*/
|
||||
export function clearPostsFiltersFromHash( tabName ) {
|
||||
const { searchParams } = parseHashParams()
|
||||
searchParams.delete( URL_PARAMS.POST_TYPE )
|
||||
searchParams.delete( URL_PARAMS.IS_ORPHAN )
|
||||
searchParams.delete( URL_PARAMS.SEO_SCORE_RANGE )
|
||||
|
||||
// Reset to page 1 when filters are cleared.
|
||||
searchParams.set( 'page', '1' )
|
||||
|
||||
const queryString = searchParams.toString()
|
||||
window.location.hash = queryString ? `${ tabName }?${ queryString }` : tabName // eslint-disable-line no-undef
|
||||
}
|
||||
|
||||
/**
|
||||
* Set link_type filter in URL hash for Links tab.
|
||||
*
|
||||
* @param {string} isInternal Filter value: '1' (internal), '0' (external), or '' (all).
|
||||
*/
|
||||
export function setLinkTypeInHash( isInternal ) {
|
||||
const { searchParams } = parseHashParams()
|
||||
|
||||
searchParams.delete( URL_PARAMS.LINK_TYPE )
|
||||
|
||||
if ( isInternal === '1' ) {
|
||||
searchParams.set( URL_PARAMS.LINK_TYPE, 'internal' )
|
||||
} else if ( isInternal === '0' ) {
|
||||
searchParams.set( URL_PARAMS.LINK_TYPE, 'external' )
|
||||
}
|
||||
|
||||
const queryString = searchParams.toString()
|
||||
window.location.hash = queryString ? `links?${ queryString }` : 'links' // eslint-disable-line no-undef
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to Links tab with pre-set source/target filters.
|
||||
*
|
||||
* @param {string} tabName Current tab name ('posts').
|
||||
* @param {Object} linkFilters Object with source_id, target_post_id, link_type.
|
||||
*/
|
||||
export function navigateToLinksTab( linkFilters ) {
|
||||
const searchParams = new URLSearchParams() // eslint-disable-line no-undef
|
||||
|
||||
if ( linkFilters.source_id ) {
|
||||
searchParams.set( URL_PARAMS.SOURCE_ID, linkFilters.source_id )
|
||||
}
|
||||
if ( linkFilters.target_post_id ) {
|
||||
searchParams.set( URL_PARAMS.TARGET_POST_ID, linkFilters.target_post_id )
|
||||
}
|
||||
if ( linkFilters.link_type ) {
|
||||
searchParams.set( URL_PARAMS.LINK_TYPE, linkFilters.link_type )
|
||||
}
|
||||
|
||||
const queryString = searchParams.toString()
|
||||
window.location.hash = queryString ? `links?${ queryString }` : 'links' // eslint-disable-line no-undef
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Links page entry point.
|
||||
*
|
||||
* Mounts the React app on #rank-math-links-page-container.
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import { createElement, createRoot } from '@wordpress/element'
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import LinksPage from './features/links-page/LinksPage'
|
||||
import './scss/links-page.scss'
|
||||
|
||||
const container = document.getElementById( 'rank-math-links-page-container' )
|
||||
if ( container ) {
|
||||
createRoot( container ).render( createElement( LinksPage ) )
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* SCSS Variables
|
||||
*
|
||||
* Design tokens for the Links module (Free)
|
||||
* Aligned with WordPress admin color palette and PRO design system
|
||||
*/
|
||||
|
||||
// ============================================
|
||||
// Colors - Primary
|
||||
// ============================================
|
||||
$color-primary: #2271b1;
|
||||
$color-primary-hover: #135e96;
|
||||
$color-primary-dark: #0a4b78;
|
||||
$color-primary-light: #e0e5f0;
|
||||
$color-primary-lightest: #f0f4f8;
|
||||
|
||||
// ============================================
|
||||
// Colors - Semantic
|
||||
// ============================================
|
||||
$color-success: #4ab147;
|
||||
$color-success-bg: #d4edda;
|
||||
$color-success-text: #155724;
|
||||
$color-success-dark: #2d7a2a;
|
||||
|
||||
$color-danger: #d63638;
|
||||
$color-danger-hover: #b32d2e;
|
||||
$color-danger-bg: #f8d7da;
|
||||
$color-danger-text: #721c24;
|
||||
|
||||
$color-warning: #f0b849;
|
||||
$color-warning-bg: #fff3cd;
|
||||
$color-warning-text: #856404;
|
||||
|
||||
$color-info: #00a0d2;
|
||||
$color-info-bg: #d1ecf1;
|
||||
$color-info-text: #0c5460;
|
||||
|
||||
// ============================================
|
||||
// Colors - Grays & Text
|
||||
// ============================================
|
||||
$color-text-primary: #1e1e1e;
|
||||
$color-text-secondary: #50575e;
|
||||
$color-text-tertiary: #757575;
|
||||
$color-text-muted: #a0a5aa;
|
||||
$color-text-dark: #1d2327;
|
||||
$color-text-light: #646970;
|
||||
|
||||
$color-border: #e0e0e0;
|
||||
$color-border-light: #f0f0f0;
|
||||
$color-border-dark: #dcdcde;
|
||||
$color-border-input: #8c8f94;
|
||||
|
||||
$color-bg-white: #fff;
|
||||
$color-bg-light: #f8f9fa;
|
||||
$color-bg-lighter: #fafafa;
|
||||
$color-bg-hover: #f6f7f7;
|
||||
$color-bg-gray: #f0f0f1;
|
||||
|
||||
// Skeleton loading colors
|
||||
$color-skeleton-base: #f2f3f5;
|
||||
$color-skeleton-highlight: #e9eaed;
|
||||
|
||||
// ============================================
|
||||
// Spacing
|
||||
// ============================================
|
||||
$spacing-xs: 4px;
|
||||
$spacing-sm: 8px;
|
||||
$spacing-md: 12px;
|
||||
$spacing-lg: 16px;
|
||||
$spacing-xl: 20px;
|
||||
$spacing-2xl: 24px;
|
||||
$spacing-3xl: 32px;
|
||||
$spacing-4xl: 40px;
|
||||
|
||||
// ============================================
|
||||
// Border Radius
|
||||
// ============================================
|
||||
$radius-sm: 3px;
|
||||
$radius-md: 4px;
|
||||
$radius-lg: 6px;
|
||||
$radius-xl: 8px;
|
||||
|
||||
// ============================================
|
||||
// Transitions
|
||||
// ============================================
|
||||
$transition-fast: 0.15s ease;
|
||||
$transition-normal: 0.2s ease;
|
||||
|
||||
// ============================================
|
||||
// Shadows
|
||||
// ============================================
|
||||
$shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
$shadow-focus: 0 0 0 1px #2271b1;
|
||||
|
||||
// ============================================
|
||||
// Typography
|
||||
// ============================================
|
||||
$font-size-xs: 11px;
|
||||
$font-size-sm: 12px;
|
||||
$font-size-base: 13px;
|
||||
$font-size-md: 14px;
|
||||
$font-size-lg: 18px;
|
||||
|
||||
$font-weight-normal: 400;
|
||||
$font-weight-medium: 500;
|
||||
$font-weight-semibold: 600;
|
||||
$font-weight-bold: 700;
|
||||
|
||||
$line-height-normal: 1.4;
|
||||
$line-height-relaxed: 1.5;
|
||||
|
||||
// ============================================
|
||||
// Component-specific
|
||||
// ============================================
|
||||
|
||||
// Table
|
||||
$table-header-bg: $color-bg-light;
|
||||
$table-row-hover: #f5f5f5;
|
||||
$table-cell-padding: $spacing-lg $spacing-xl;
|
||||
|
||||
// Badge
|
||||
$badge-padding: 4px 10px;
|
||||
$badge-font-size: $font-size-sm;
|
||||
$badge-radius: $radius-md;
|
||||
|
||||
// Button
|
||||
$button-padding: 8px $spacing-lg;
|
||||
$button-height: 36px;
|
||||
|
||||
// Input
|
||||
$input-height: 38px;
|
||||
$input-padding: 6px $spacing-md;
|
||||
$input-border-width: 1px;
|
||||
|
||||
// Breakpoints
|
||||
$breakpoint-mobile: 782px;
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
/**
|
||||
* Links Page Styles (Free)
|
||||
*
|
||||
* Matches the PRO Link Genius UI design system.
|
||||
*/
|
||||
|
||||
@import 'variables';
|
||||
|
||||
// ============================================
|
||||
// PRO CTA variables & imports (required by _pro-cta.scss)
|
||||
// ============================================
|
||||
$namespace: 'rank-math';
|
||||
$rm_brand: #6666c3;
|
||||
$primary: #069de3;
|
||||
$text: #242628;
|
||||
$dark_gray: #7f868d;
|
||||
$dark-gray: #7f868d;
|
||||
$color-1: #10AC84;
|
||||
$color-3: #ed5e5e;
|
||||
$light_gray: #dadfe4;
|
||||
|
||||
@import '../../../../../../assets/admin/scss/_mixins';
|
||||
@import '../../../../../../assets/admin/scss/partials/common/_pro-cta';
|
||||
@import '../../../../../../assets/admin/scss/sidebar/_modal';
|
||||
|
||||
// ============================================
|
||||
// TabPanel wrapper reset
|
||||
// ============================================
|
||||
#rank-math-links-page-container {
|
||||
.rank-math-links-page.rank-math-wrap {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.rank-math-tab-panel {
|
||||
width: 100%;
|
||||
|
||||
.components-tab-panel__tab-content {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Tab content wrapper
|
||||
// ============================================
|
||||
.rank-math-tab-content {
|
||||
position: relative;
|
||||
margin-top: 16px;
|
||||
margin-left: 20px;
|
||||
margin-right: 40px;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Section card
|
||||
// ============================================
|
||||
.rank-math-section-card {
|
||||
position: relative;
|
||||
background: $color-bg-white;
|
||||
border: 1px solid $color-border;
|
||||
border-radius: $radius-md;
|
||||
margin-bottom: 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// PRO column blurring (Links tab)
|
||||
// ============================================
|
||||
.rank-math-pro-col-header {
|
||||
position: relative;
|
||||
|
||||
.rank-math-pro-badge {
|
||||
display: inline-block;
|
||||
margin-left: $spacing-xs;
|
||||
padding: 1px 5px;
|
||||
border-radius: $radius-sm;
|
||||
background: $color-warning-bg;
|
||||
color: $color-warning-text;
|
||||
font-size: $font-size-xs;
|
||||
font-weight: $font-weight-semibold;
|
||||
vertical-align: middle;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
}
|
||||
|
||||
.rank-math-pro-cell {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
.rank-math-pro-blur-text {
|
||||
filter: blur(4px);
|
||||
user-select: none;
|
||||
color: $color-text-secondary;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.rank-math-pro-upgrade-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
a {
|
||||
font-size: $font-size-xs;
|
||||
color: $color-primary;
|
||||
font-weight: $font-weight-medium;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Upgrade PRO Modal
|
||||
// ============================================
|
||||
.rank-math-upgrade-pro-modal {
|
||||
.rank-math-upgrade-pro-modal-body {
|
||||
text-align: center;
|
||||
padding: $spacing-lg 0;
|
||||
|
||||
.rank-math-upgrade-pro-icon {
|
||||
display: block;
|
||||
font-size: 36px;
|
||||
color: $color-warning;
|
||||
margin-bottom: $spacing-md;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: $font-size-md;
|
||||
color: $color-text-secondary;
|
||||
margin: 0 0 $spacing-lg;
|
||||
line-height: $line-height-relaxed;
|
||||
}
|
||||
|
||||
.rank-math-upgrade-pro-features {
|
||||
list-style: none;
|
||||
margin: 0 0 $spacing-xl;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: $spacing-sm;
|
||||
padding: $spacing-xs 0;
|
||||
font-size: $font-size-base;
|
||||
color: $color-text-secondary;
|
||||
|
||||
&::before {
|
||||
content: '✓';
|
||||
color: $color-success;
|
||||
font-weight: $font-weight-bold;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.rank-math-upgrade-pro-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: $spacing-md;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.rank-math-upgrade-pro-btn {
|
||||
min-width: 160px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// PRO tab preview (image + CTA overlay)
|
||||
// ============================================
|
||||
.rank-math-pro-tab-preview {
|
||||
position: relative;
|
||||
|
||||
img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
#rank-math-pro-cta {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Toggle filters layout (Links / Posts tabs)
|
||||
// ============================================
|
||||
.rank-math-table-header.has-toggle-filters {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.rank-math-table-toggle-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: stretch;
|
||||
padding: 0 $spacing-2xl 0 0;
|
||||
gap: $spacing-lg;
|
||||
flex-wrap: wrap;
|
||||
border-bottom: 1px solid $color-border;
|
||||
min-height: 52px;
|
||||
}
|
||||
|
||||
.rank-math-table-toggle-left {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 0;
|
||||
|
||||
.rank-math-toggle-button-group.is-tab-style {
|
||||
align-items: stretch;
|
||||
|
||||
.rank-math-toggle-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 0;
|
||||
border-bottom-width: 2px;
|
||||
margin-bottom: -1px;
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.rank-math-table-toggle-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: $spacing-md;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Link type badge (Internal / External)
|
||||
// ============================================
|
||||
.rank-math-link-type-badge {
|
||||
display: inline-block;
|
||||
padding: 3px 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
|
||||
&.internal {
|
||||
background-color: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
&.external {
|
||||
background-color: #d1ecf1;
|
||||
color: #0c5460;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user