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
1 change: 1 addition & 0 deletions includes/class-newspack.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ private function includes() {
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-teams-for-memberships.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-newspack-elections.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-yoast.php';
include_once NEWSPACK_ABSPATH . 'includes/plugins/class-parsely.php';
include_once NEWSPACK_ABSPATH . 'includes/class-primary-category.php';

include_once NEWSPACK_ABSPATH . 'includes/class-patches.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function configure() {
'track_page_types' => [ 'page' ],
'disable_javascript' => false,
'disable_amp' => false,
'meta_type' => 'json_ld',
'meta_type' => 'repeated_metas',
'logo' => '',
'metadata_secret' => '',
'parsely_wipe_metadata_cache' => false,
Expand Down
53 changes: 53 additions & 0 deletions includes/plugins/class-parsely.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Parse.ly integration class.
*
* @package Newspack
*/

namespace Newspack;

defined( 'ABSPATH' ) || exit;

/**
* Main class.
*/
class Parsely {
/**
* Option to track whether the meta_type migration has run.
*
* @var string
*/
const META_TYPE_MIGRATION_OPTION = 'newspack_parsely_meta_type_migrated';

/**
* Initialize hooks and filters.
*/
public static function init() {
add_action( 'admin_init', [ __CLASS__, 'migrate_meta_type' ] );
}

/**
* Migrate existing Parse.ly installs from the legacy `json_ld` meta_type
* default to `repeated_metas`, which avoids conflicts with Yoast SEO's
* own JSON-LD output. Runs once per site.
*/
public static function migrate_meta_type() {
if ( get_option( self::META_TYPE_MIGRATION_OPTION ) ) {
return;
}

if ( ! is_plugin_active( 'wp-parsely/wp-parsely.php' ) ) {
return;
}

$parsely_settings = get_option( 'parsely', [] );
if ( is_array( $parsely_settings ) && isset( $parsely_settings['meta_type'] ) && 'json_ld' === $parsely_settings['meta_type'] ) {
$parsely_settings['meta_type'] = 'repeated_metas';
update_option( 'parsely', $parsely_settings );
}

update_option( self::META_TYPE_MIGRATION_OPTION, 'v1' );
}
}
Parsely::init();
Loading