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 @@ -17,7 +17,7 @@
"source": "https://github.com/Codeinwp/neve"
},
"require": {
"codeinwp/themeisle-sdk": "^3.3.65",
"codeinwp/themeisle-sdk": "^3.3.71",
"wptt/webfont-loader": "dev-master"
},
"repositories": [
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.

30 changes: 30 additions & 0 deletions inc/admin/dashboard/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function init() {
add_action( 'init', array( $this, 'register_settings' ) );
add_action( 'init', array( $this, 'register_about_page' ), 1 );
add_filter( 'neve_ai_connect_metadata', array( $this, 'get_ai_connect_metadata' ) );
add_filter( 'neve_support_hub_metadata', array( $this, 'get_support_hub_metadata' ) );

add_action( 'admin_notices', array( $this, 'render_custom_layout_header' ) );
}
Expand Down Expand Up @@ -136,6 +137,35 @@ public function get_ai_connect_metadata() {
];
}

/**
* Get the data for the SDK Support Hub: one Help button on the Neve dashboard
* and the feedback window on the Add Themes screen. The dashboard already fires
* `themeisle_internal_page`, so no `pages` list is needed.
*
* @return array<string, bool|array<int, array<string, string>>>
*/
public function get_support_hub_metadata() {
if ( apply_filters( 'neve_is_theme_whitelabeled', false ) || apply_filters( 'neve_is_plugin_whitelabeled', false ) ) {
return [];
}

return [
'is_pro' => defined( 'NEVE_PRO_VERSION' ) && 'valid' === apply_filters( 'product_neve_license_status', false ),
'links' => [
[
'icon' => 'book-alt',
'text' => __( 'Documentation', 'neve' ),
'url' => 'https://docs.themeisle.com/neve/neve-doc',
],
[
'icon' => 'groups',
'text' => __( 'Community Forum', 'neve' ),
'url' => 'https://wordpress.org/support/theme/neve/',
],
],
];
}

/**
* Add the about page with respect to the white label settings.
*
Expand Down
86 changes: 86 additions & 0 deletions tests/test-neve-support-hub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
* Tests for the metadata Neve hands to the Themeisle SDK Support Hub.
*
* @package neve
*/

/**
* Class TestNeveSupportHub
*/
class TestNeveSupportHub extends WP_UnitTestCase {

/**
* The filter returns the keys Neve opts into, and nothing else.
*/
public function test_metadata_has_the_agreed_keys() {
$data = apply_filters( 'neve_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 Neve's docs and wordpress.org forum.
*/
public function test_links_point_to_neve() {
$links = apply_filters( 'neve_support_hub_metadata', array() )['links'];

$this->assertSame(
array(
'https://docs.themeisle.com/neve/neve-doc',
'https://wordpress.org/support/theme/neve/',
),
wp_list_pluck( $links, 'url' )
);
foreach ( $links as $link ) {
$this->assertNotEmpty( $link['icon'] );
$this->assertNotEmpty( $link['text'] );
}
}

/**
* Messages are tagged as Pro only while Neve Pro is active with a valid license.
*/
public function test_is_pro_needs_a_valid_license() {
add_filter( 'product_neve_license_status', array( $this, 'expired_license' ) );
$this->assertFalse( apply_filters( 'neve_support_hub_metadata', array() )['is_pro'] );
remove_filter( 'product_neve_license_status', array( $this, 'expired_license' ) );

add_filter( 'product_neve_license_status', array( $this, 'valid_license' ) );
$this->assertSame( defined( 'NEVE_PRO_VERSION' ), apply_filters( 'neve_support_hub_metadata', array() )['is_pro'] );
remove_filter( 'product_neve_license_status', array( $this, 'valid_license' ) );
}

/**
* A white-labeled Neve shows no Themeisle Help button.
*/
public function test_white_label_hides_the_hub() {
add_filter( 'neve_is_theme_whitelabeled', '__return_true' );
$this->assertSame( array(), apply_filters( 'neve_support_hub_metadata', array() ) );
remove_filter( 'neve_is_theme_whitelabeled', '__return_true' );

add_filter( 'neve_is_plugin_whitelabeled', '__return_true' );
$this->assertSame( array(), apply_filters( 'neve_support_hub_metadata', array() ) );
remove_filter( 'neve_is_plugin_whitelabeled', '__return_true' );
}

/**
* 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