Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
== Changelog ==

= 2.6.0 =
-

= 2.4.9 - JUN 2 2025 =
- Fixed: Potential vulnerability patched: Report by Patchstack from MAY 26th 2025. Shoutout and a thanks to the Patchstack team for patch test and confirmation.

Expand Down
27 changes: 15 additions & 12 deletions includes/schema/class-oceanwp-schema-cache-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct() {
* Output cached Schema.
*/
public function output_cached_schema() {
if ( is_preview() || is_admin() || wp_doing_ajax() ) {
if ( is_preview() || is_customize_preview() || is_admin() || wp_doing_ajax() ) {
return;
}

Expand All @@ -71,7 +71,7 @@ public function output_cached_schema() {

$schema = OceanWP_JsonLD_Schema::instance();
if ( ! $schema ) {
error_log( '[Schema Cache] Schema instance is null, skipping output.' );
//error_log( '[Schema Cache] Schema instance is null, skipping output.' );
return;
}
$cache_key = apply_filters( 'oceanwp_schema_cache_key', $this->get_cache_key() );
Expand All @@ -80,34 +80,33 @@ public function output_cached_schema() {

if ( false === $json || ! is_string( $json ) || empty( $json ) ) {
$data = $schema->generate_schema();
error_log( '[Schema Cache] Transient not found, generating...' );

// Apply filters for developers to include their own schema before caching.
$data = apply_filters( 'oceanwp_schema_cache_data', $data, $cache_key );

if ( empty( $data ) ) {
error_log( '[Schema Cache] Schema generated but empty.' );
//error_log( '[Schema Cache] Schema generated but empty.' );
return;
}

$expiration = $this->get_cache_duration();

$json = wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
set_transient( $cache_key, $json, $expiration );
error_log( '[Schema Cache] Cached schema with key: ' . $cache_key );
//error_log( '[Schema Cache] Cached schema with key: ' . $cache_key );
}

echo "\n<script type=\"application/ld+json\">\n$json\n</script>\n";

error_log( '[Schema Cache] Checking key: ' . $cache_key );
//error_log( '[Schema Cache] Checking key: ' . $cache_key );
}

/**
* Schema caching expiration.
*/
protected function get_cache_duration() {
if ( ! get_theme_mod( 'ocean_schema_cache_enable', false ) ) {
return 2 * DAY_IN_SECONDS;
return;
}

$duration = get_theme_mod( 'ocean_schema_cache_duration', '2' );
Expand Down Expand Up @@ -239,15 +238,15 @@ public function register_customize_options( $options ) {
'section' => 'ocean_seo_settings',
'after' => 'ocean_divider_before_schema_caching',
'class' => 'section-site-layout',
'priority' => 10,
'priority' => 15,
'options' => [
'ocean_schema_cache_enable' => [
'type' => 'ocean-switch',
'label' => esc_html__( 'Enable Schema Caching', 'ocean-extra' ),
'section' => 'oe_schema_caching',
'default' => false,
'transport' => 'postMessage',
'priority' => 10,
'priority' => 16,
'hideLabel' => false,
'active_callback' => function() {
return function_exists( 'oceanwp_cac_is_schema_manager_enabled' )
Expand All @@ -263,7 +262,7 @@ public function register_customize_options( $options ) {
'section' => 'oe_schema_caching',
'transport' => 'postMessage',
'default' => '2',
'priority' => 10,
'priority' => 17,
'hideLabel' => false,
'multiple' => false,
'active_callback' => function() {
Expand All @@ -286,7 +285,7 @@ public function register_customize_options( $options ) {
'section' => 'oe_schema_caching',
'default' => false,
'transport' => 'postMessage',
'priority' => 10,
'priority' => 18,
'hideLabel' => false,
'active_callback' => function() {
return function_exists( 'oceanwp_cac_is_schema_manager_enabled' )
Expand All @@ -307,6 +306,10 @@ public function register_customize_options( $options ) {
* @param WP_Admin_Bar $wp_admin_bar The admin bar instance.
*/
public function add_clear_schema_admin_bar_button( $wp_admin_bar ) {
if ( ! get_theme_mod( 'ocean_schema_cache_enable', false ) ) {
return;
}

if ( ! is_admin_bar_showing() ) {
return;
}
Expand Down Expand Up @@ -425,7 +428,7 @@ public function enqueue_admin_bar_script() {
true
);

error_log( plugins_url( 'assets/js/schema-cache-bar.js', __FILE__ ) );
//error_log( plugins_url( 'assets/js/schema-cache-bar.js', __FILE__ ) );

wp_localize_script( 'oceanwp-schema-cache-bar', 'OceanSchemaCacheBar', [
'confirm_message' => esc_html__( "⚠️ You are about to clear all cached JSON Schema data.\n\nThis may affect structured data visibility in search engines temporarily.\n\nWe recommend taking a full website backup before continuing.\n\nDo you want to proceed?", 'ocean-extra' ),
Expand Down
16 changes: 12 additions & 4 deletions includes/schema/class-oceanwp-woocommerce-schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,15 @@ public static function get_product_taxonomy_schema() {
*/
public function register_customize_options($options) {

$options['ocean_seo_settings']['options'] = [

$new_options = [
'ocean_schema_woocommerce_enable' => [
'type' => 'ocean-switch',
'label' => esc_html__( 'Enable WooCommerce Schema', 'ocean-extra' ),
'section' => 'ocean_seo_settings',
'after' => 'oe_schema_caching',
'after' => 'ocean_configure_breadcrumb_link',
'default' => false,
'transport' => 'postMessage',
'priority' => 10,
'priority' => 11,
'hideLabel' => false,
'active_callback' => function() {
return function_exists( 'oceanwp_cac_is_schema_manager_enabled' )
Expand All @@ -153,6 +152,15 @@ public function register_customize_options($options) {
],
];

if ( isset( $options['ocean_seo_settings']['options'] ) && is_array( $options['ocean_seo_settings']['options'] ) ) {
$options['ocean_seo_settings']['options'] = array_merge(
$options['ocean_seo_settings']['options'],
$new_options
);
} else {
$options['ocean_seo_settings']['options'] = $new_options;
}

return $options;
}
}
Expand Down
6 changes: 3 additions & 3 deletions ocean-extra.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,10 +775,10 @@ class_exists( 'OceanWP_JsonLD_Schema' ) &&
get_theme_mod( 'ocean_schema_markup', true ) &&
get_theme_mod( 'ocean_schema_manager', false )
) {
require_once OE_PATH . 'includes/schema/class-oceanwp-schema-cache-handler.php';
require_once OE_PATH . '/includes/schema/class-oceanwp-schema-cache-handler.php';
new OceanWP_Schema_Cache_Handler();

}

}

/**
Expand All @@ -792,7 +792,7 @@ class_exists( 'OceanWP_JsonLD_Schema' ) &&
get_theme_mod( 'ocean_schema_markup', true ) &&
get_theme_mod( 'ocean_schema_manager', false )
) {
require_once OE_PATH . 'includes/schema/class-oceanwp-woocommerce-schema.php';
require_once OE_PATH . '/includes/schema/class-oceanwp-woocommerce-schema.php';
new OceanWP_WooCommerce_Schema();
}

Expand Down