Skip to content

Commit

Permalink
Added basic Bricks compatibility (see #677)
Browse files Browse the repository at this point in the history
  • Loading branch information
sybrew committed Nov 13, 2024
1 parent 3dc244c commit 3b522e2
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 9 deletions.
2 changes: 1 addition & 1 deletion autodescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: The SEO Framework
* Plugin URI: https://theseoframework.com/
* Description: An automated, advanced, accessible, unbranded and extremely fast SEO solution for your WordPress website.
* Version: 5.1.0-beta-5
* Version: 5.1.0-beta-6
* Author: The SEO Framework Team
* Author URI: https://theseoframework.com/
* License: GPLv3
Expand Down
3 changes: 3 additions & 0 deletions bootstrap/init-compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
if ( Helper\Compatibility::is_theme_active( 'genesis' ) )
require \THE_SEO_FRAMEWORK_DIR_PATH_COMPAT . 'theme-genesis.php';

if ( Helper\Compatibility::is_theme_active( 'bricks' ) )
require \THE_SEO_FRAMEWORK_DIR_PATH_COMPAT . 'theme-bricks.php';

foreach (
array_intersect_key(
[
Expand Down
9 changes: 8 additions & 1 deletion inc/classes/data/post.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ public static function get_content( $post = null ) {
* Detects the following builders:
* - Divi Builder by Elegant Themes
* - Visual Composer by WPBakery
* - Oxygen Builder by Soflyy
* - Bricks Builder by Bricks (or Codeer Limited)
*
* @since 4.1.0
* @since 5.0.0 1. First parameter may now be empty to automatically fetch the post ID.
* 2. Moved from `\The_SEO_Framework\Load`.
* @since 5.1.0 Added Bricks and Oxygen Builder.
*
* @param int $post_id The post ID to check.
* @return bool
Expand All @@ -117,8 +120,12 @@ public static function uses_non_html_page_builder( $post_id = 0 ) {

// Divi Builder by Elegant Themes
// || Visual Composer by WPBakery
// || Oxygen Builder by Soflyy
// || Bricks Builder by Bricks
return ( 'on' === ( $meta['_et_pb_use_builder'][0] ?? '' ) && \defined( 'ET_BUILDER_VERSION' ) )
|| ( 'true' === ( $meta['_wpb_vc_js_status'][0] ?? '' ) && \defined( 'WPB_VC_VERSION' ) );
|| ( 'true' === ( $meta['_wpb_vc_js_status'][0] ?? '' ) && \defined( 'WPB_VC_VERSION' ) )
|| ( 'bricks' === ( $meta['_bricks_editor_mode'][0] ?? '' ) && \defined( 'BRICKS_VERSION' ) )
|| ( \strlen( $meta['_ct_builder_json'][0] ?? '' ) && \defined( 'CT_VERSION' ) );
}

/**
Expand Down
13 changes: 10 additions & 3 deletions inc/classes/helper/compatibility.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,17 @@ public static function can_i_use( $plugins = [] ) {
* @since 4.2.0 No longer "loads" the theme; instead, simply compares input to active theme options.
* @since 5.0.0 1. Moved from `\The_SEO_Framework\Load`.
* 2. Renamed from `is_theme`.
* @since 5.1.0 Added memoization.
*
* @param string|string[] $themes The theme names to test.
* @return bool Any of the themes are active.
*/
public static function is_theme_active( $themes = '' ) {

$active_theme = [
$active_theme = memo() ?? memo( array_unique( [
strtolower( \get_option( 'stylesheet' ) ), // Parent.
strtolower( \get_option( 'template' ) ), // Child.
];
] ) );

foreach ( (array) $themes as $theme )
if ( \in_array( strtolower( $theme ), $active_theme, true ) )
Expand All @@ -277,10 +278,13 @@ public static function is_theme_active( $themes = '' ) {
* Detects the following builders:
* - Divi Builder by Elegant Themes
* - Visual Composer by WPBakery
* - Bricks Builder by Bricks
* - Oxygen Builder by Soflyy
*
* @since 4.1.0
* @since 5.0.0 1. Moved from `\The_SEO_Framework\Load`.
* 2. Renamed from `detect_non_html_page_builder`.
* @since 5.1.0 Added 'CT_VERSION' (Oxygen) and 'BRICKS_VERSION' (Bricks) constants.
*
* @return bool
*/
Expand All @@ -294,7 +298,10 @@ public static function is_non_html_builder_active() {
*/
(bool) \apply_filters(
'the_seo_framework_shortcode_based_page_builder_active',
\defined( 'ET_BUILDER_VERSION' ) || \defined( 'WPB_VC_VERSION' )
\defined( 'ET_BUILDER_VERSION' )
|| \defined( 'WPB_VC_VERSION' )
|| \defined( 'BRICKS_VERSION' )
|| \defined( 'CT_VERSION' ),
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion inc/classes/helper/post-type.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static function get_all_public() {
public static function get_all_forced_supported() {
/**
* @since 3.1.0
* @param string[] $forced Forced supported post types
* @param string[] $forced Forced supported post types.
*/
return (array) \apply_filters(
'the_seo_framework_forced_supported_post_types',
Expand Down
4 changes: 2 additions & 2 deletions inc/classes/helper/taxonomy.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static function get_all_public() {
* Do not consider using this filter. Properly register your taxonomy, noob.
*
* @since 4.2.0
* @param string[] $post_types The public post types.
* @param string[] $taxonomies The public taxonomies.
*/
(array) \apply_filters(
'the_seo_framework_public_taxonomies',
Expand Down Expand Up @@ -187,7 +187,7 @@ public static function get_all_public() {
public static function get_all_forced_supported() {
/**
* @since 4.1.0
* @param string[] $forced Forced supported post types
* @param string[] $forced Forced supported taxonomies.
*/
return (array) \apply_filters(
'the_seo_framework_forced_supported_taxonomies',
Expand Down
58 changes: 58 additions & 0 deletions inc/compat/theme-bricks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* @package The_SEO_Framework\Compat\Theme\Bricks
* @subpackage The_SEO_Framework\Compatibility
*/

namespace The_SEO_Framework;

\defined( 'THE_SEO_FRAMEWORK_PRESENT' ) or die;

\add_filter( 'the_seo_framework_public_post_types', __NAMESPACE__ . '\\_bricks_fix_public_post_types' );
\add_filter( 'the_seo_framework_public_taxonomies', __NAMESPACE__ . '\\_bricks_fix_public_taxonomies' );

/**
* Removes support for Bricks' non-public post types conditionally.
*
* This solely affects The SEO Framework.
*
* @hook the_seo_framework_public_post_types 10
* @since 5.1.0
*
* @param string[] $post_types The list of should-be public post types.
* @return string[] The list of actual public post types.
*/
function _bricks_fix_public_post_types( $post_types ) {

// phpcs:ignore, TSF.Performance.Functions.PHP -- this method is memoized via filter, autoload is false.
if ( \defined( 'BRICKS_DB_TEMPLATE_SLUG' ) && class_exists( \Bricks\Database::class, false ) )
if ( ! \Bricks\Database::get_setting( 'publicTemplates' ) )
$post_types = array_diff( $post_types, [ BRICKS_DB_TEMPLATE_SLUG ] );

return $post_types;
}

/**
* Removes support for Bricks' template taxonomies.
* They aren't used for display, only organizing templates.
*
* This solely affects The SEO Framework.
*
* @hook the_seo_framework_public_taxonomies 10
* @since 5.1.0
*
* @param string[] $taxonomies The list of should-be public taxonomies.
* @return string[] The list of actual public taxonomies.
*/
function _bricks_fix_public_taxonomies( $taxonomies ) {

$unset = [];

if ( \defined( 'BRICKS_DB_TEMPLATE_TAX_TAG' ) )
$unset[] = BRICKS_DB_TEMPLATE_TAX_TAG;

if ( \defined( 'BRICKS_DB_TEMPLATE_TAX_BUNDLE' ) )
$unset[] = BRICKS_DB_TEMPLATE_TAX_BUNDLE;

return array_diff( $taxonomies, $taxonomies );
}
12 changes: 11 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ Punt:
* This works for the Settings, Post Edit, Term Edit, and List Edit pages.
* This is a targeted fail-safe and won't work everywhere all the time.
* If the primary term is set to a term that doesn't exist, the Primary Term selection will now show a warning message.
* **Compatibility:**
* We added basic compatibility for the Bricks theme:
* Templates are no longer supported for SEO or included in the sitemap unless the "Public templates" option is enabled at "Bricks > Settings > Templates > My templates."
* Template Bundles and Template Tags are no longer supported for SEO; they weren't meant to be public anyway.
* When we detect a page is a Bricks template, the SEO Bar clarifies why no description can be generated.
* Bricks's data appears readable without excessive parsing, so we may revisit this and enable description generation in the future. See [issue 677](https://github.com/sybrew/the-seo-framework/issues/677).
* We added detection for Oxygen builder pages. The SEO Bar now clarifies why no description can be generated.
* Note that TSF detects Oxygen's newer "JSON" type data only. If your data hasn't been converted yet, then TSF will display a generic message about the description not being generated.
* **Changed:**
* WordPress 5.7 brought us a new higher contrast color palette. We found our color scheme matching their colors well, but now think it better to implement those colors into TSF. Notably, you'll find that the SEO Bar is darker and easier on the eyes. The pixel and character counters appear more vigorous.
* We didn't copy WordPress's colors one-to-one. At times, we found the yellow too dull, and made it more vibrant.
Expand Down Expand Up @@ -497,7 +505,9 @@ Punt:
* `the_seo_framework_schema_queued_graph_data` is now available. It's used to allow creating graph references.
* `the_seo_framework_robots` is now available. It's used to create a map of robots directives to generate.
* In effect, `the_seo_framework_robots_txt_pre` and `the_seo_framework_robots_txt_pro` are deprecated.
* `the_seo_framework_get_excerpt` is now available. It's used to get an excerpt, used before parsing the entire post content, for description generation.
* `the_seo_framework_get_excerpt` is now available. It's used to get an excerpt, right before parsing the entire post content, used by the description generator.
* There's also `the_seo_framework_description_excerpt`, but that is solely for the description generation.
* Actually, TODO: Revert this? Description\Excerpt is a helper class. This new filter adds nothing new, albeit it's at a lower level, which perhaps is better for future-proofing...
* **Deprecated:**
* `the_seo_framework_robots_disallow_queries`, use `the_seo_framework_robots` instead.
* `the_seo_framework_robots_txt_pre`, use `the_seo_framework_robots` instead.
Expand Down

0 comments on commit 3b522e2

Please sign in to comment.