Skip to content
Merged
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"source": "https://github.com/Codeinwp/feedzy-rss-feeds"
},
"require": {
"codeinwp/themeisle-sdk": "^3.3.65"
"codeinwp/themeisle-sdk": "^3.3.70"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions feedzy-rss-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,32 @@ function () {
}
);

/*
* Opts into the SDK Support Hub: one Help button on Feedzy's screens and the
* deactivation window. It replaces the float widget. Feedzy's screens already
* fire `themeisle_internal_page`, so no `pages` list is needed.
*/
add_filter(
'feedzy_rss_feeds_support_hub_metadata',
function () {
return array(
'is_pro' => feedzy_is_pro(),
'links' => array(
array(
'icon' => 'book-alt',
'text' => __( 'Documentation', 'feedzy-rss-feeds' ),
'url' => 'https://docs.themeisle.com/collection/1569-feedzy-rss-feeds',
),
array(
'icon' => 'groups',
'text' => __( 'Community Forum', 'feedzy-rss-feeds' ),
'url' => 'https://wordpress.org/support/plugin/feedzy-rss-feeds/',
),
),
);
}
);

add_filter(
'themeisle_sdk_labels',
function ( $labels ) {
Expand Down
70 changes: 70 additions & 0 deletions tests/test-support-hub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Tests for the metadata Feedzy hands to the Themeisle SDK Support Hub.
*
* @package feedzy-rss-feeds
*/
class Test_Support_Hub extends WP_UnitTestCase {

/**
* The filter returns the keys Feedzy opts into, and nothing else.
*/
public function test_metadata_has_the_agreed_keys() {
$data = apply_filters( 'feedzy_rss_feeds_support_hub_metadata', array() );

$this->assertIsArray( $data );
$this->assertSame( array( 'is_pro', 'links' ), array_keys( $data ) );
$this->assertArrayNotHasKey( 'setup_complete', $data, 'The setup nudge stays off for now.' );
}

/**
* The footer links point to Feedzy's docs and wordpress.org forum.
*/
public function test_links_point_to_feedzy() {
$links = apply_filters( 'feedzy_rss_feeds_support_hub_metadata', array() )['links'];

$this->assertSame(
array(
'https://docs.themeisle.com/collection/1569-feedzy-rss-feeds',
'https://wordpress.org/support/plugin/feedzy-rss-feeds/',
),
wp_list_pluck( $links, 'url' )
);
foreach ( $links as $link ) {
$this->assertNotEmpty( $link['icon'] );
$this->assertNotEmpty( $link['text'] );
}
}

/**
* Messages are tagged as Pro only while the Pro license is valid.
*/
public function test_is_pro_needs_a_valid_license() {
add_filter( 'product_feedzy_license_status', array( $this, 'expired_license' ) );
$this->assertFalse( apply_filters( 'feedzy_rss_feeds_support_hub_metadata', array() )['is_pro'] );
remove_filter( 'product_feedzy_license_status', array( $this, 'expired_license' ) );

add_filter( 'product_feedzy_license_status', array( $this, 'valid_license' ) );
// test-import.php defines FEEDZY_PRO_ABSPATH for the rest of the run, so Pro may or may not be "installed" here.
$this->assertSame( defined( 'FEEDZY_PRO_ABSPATH' ), apply_filters( 'feedzy_rss_feeds_support_hub_metadata', array() )['is_pro'] );
remove_filter( 'product_feedzy_license_status', array( $this, 'valid_license' ) );
}

/**
* Reports a valid license.
*
* @return string
*/
public function valid_license() {
return 'valid';
}

/**
* Reports an expired license.
*
* @return string
*/
public function expired_license() {
return 'expired';
}
}
Loading