fix(2meet-data-optimizer-hivepress-addon): register enabled social links as hp_{name}
- hivepress-social-links stores each link as hp_{name} (hp_facebook, not
hp_facebook_url) and lets admins enable links separately for listings
and vendors; the hardcoded 7 *_url vendor keys never matched real meta
- Read hp_listing_social_links / hp_vendor_social_links and register each
enabled link on its own post type, so custom links (e.g. line_oa) work
- dev34 check: meta holds hp_instagram / hp_website, and zero *_url keys
Verify: vendor/bin/phpunit --filter HivePressSocialLinksAdapterTest;
addon unit 156 OK, integration 57 OK
PR: PR-010
This commit is contained in:
@@ -18,6 +18,8 @@ class HivePressSocialLinksAdapterTest extends TestCase {
|
||||
$prop->setAccessible( true );
|
||||
$prop->setValue( null, null );
|
||||
|
||||
unset( $GLOBALS['_wp_options']['hp_vendor_social_links'], $GLOBALS['_wp_options']['hp_listing_social_links'] );
|
||||
|
||||
$this->adapter = new WPDO_HivePress_Social_Links_Adapter();
|
||||
}
|
||||
|
||||
@@ -30,25 +32,39 @@ class HivePressSocialLinksAdapterTest extends TestCase {
|
||||
$this->assertSame( 'HivePress\\SocialLinks\\Plugin', $this->adapter->detection_class() );
|
||||
}
|
||||
|
||||
public function test_on_register_fields_registers_seven_cold_fields(): void {
|
||||
public function test_registers_enabled_links_per_model(): void {
|
||||
// hivepress-social-links stores each enabled link as the attribute hp_{name},
|
||||
// with separate admin selections for listings and vendors.
|
||||
update_option( 'hp_vendor_social_links', array( 'facebook', 'website' ) );
|
||||
update_option( 'hp_listing_social_links', array( 'instagram' ) );
|
||||
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
// All seven social URL fields should land in cold zone on hp_vendor.
|
||||
$facebook = $registry->get_field( 'hp_vendor', 'hp_facebook_url' );
|
||||
$this->assertSame( 'cold', $facebook['zone'] );
|
||||
$this->assertSame( 'cold', $registry->get_field( 'hp_vendor', 'hp_facebook' )['zone'] );
|
||||
$this->assertSame( 'cold', $registry->get_field( 'hp_vendor', 'hp_website' )['zone'] );
|
||||
$this->assertSame( 'cold', $registry->get_field( 'hp_listing', 'hp_instagram' )['zone'] );
|
||||
|
||||
$instagram = $registry->get_field( 'hp_vendor', 'hp_instagram_url' );
|
||||
$this->assertSame( 'cold', $instagram['zone'] );
|
||||
|
||||
$whatsapp = $registry->get_field( 'hp_vendor', 'hp_whatsapp_url' );
|
||||
$this->assertSame( 'cold', $whatsapp['zone'] );
|
||||
$this->assertNull( $registry->get_field( 'hp_vendor', 'hp_instagram' ) );
|
||||
$this->assertNull( $registry->get_field( 'hp_vendor', 'hp_facebook_url' ) );
|
||||
}
|
||||
|
||||
public function test_doctor_check_reports_field_count(): void {
|
||||
public function test_registers_nothing_when_no_links_enabled(): void {
|
||||
$registry = WPDO_Schema_Registry::instance();
|
||||
$this->adapter->on_register_fields( $registry );
|
||||
|
||||
$this->assertNull( $registry->get_field( 'hp_vendor', 'hp_facebook' ) );
|
||||
$this->assertNull( $registry->get_field( 'hp_listing', 'hp_facebook' ) );
|
||||
}
|
||||
|
||||
public function test_doctor_check_reports_registered_count(): void {
|
||||
update_option( 'hp_vendor_social_links', array( 'facebook', 'website' ) );
|
||||
update_option( 'hp_listing_social_links', array( 'instagram' ) );
|
||||
|
||||
$result = $this->adapter->doctor_check();
|
||||
|
||||
$this->assertTrue( $result['ok'] );
|
||||
$this->assertStringContainsString( '7 cold fields', $result['message'] );
|
||||
$this->assertStringContainsString( '3 cold fields', $result['message'] );
|
||||
}
|
||||
|
||||
public function test_score_aggregates_to_perfect_ten(): void {
|
||||
|
||||
Reference in New Issue
Block a user