| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Yoast\WP\SEO\Helpers; |
| 4 | 4 | |
| 5 | -use WPSEO_Options; | |
| 6 | -use Yoast\WP\SEO\Conditionals\Wincher_Conditional; | |
| 5 | +use WPSEO_Shortlinker; | |
| 6 | +use Yoast\WP\SEO\Conditionals\Non_Multisite_Conditional; | |
| 7 | 7 | use Yoast\WP\SEO\Config\Wincher_Client; |
| 8 | 8 | use Yoast\WP\SEO\Exceptions\OAuth\Authentication_Failed_Exception; |
| 9 | 9 | use Yoast\WP\SEO\Exceptions\OAuth\Tokens\Empty_Property_Exception; |
| 10 | 10 | use Yoast\WP\SEO\Exceptions\OAuth\Tokens\Empty_Token_Exception; |
| @@ -14,15 +14,31 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | class Wincher_Helper { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Checks if the integration is active for the current user. | |
| 18 | + * Holds the Options Page helper instance. | |
| 19 | 19 | * |
| 20 | - * @return bool Whether or not the integration is active. | |
| 20 | + * @var Options_Helper | |
| 21 | 21 | */ |
| 22 | + protected $options; | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * Options_Helper constructor. | |
| 26 | + * | |
| 27 | + * @param Options_Helper $options The options helper. | |
| 28 | + */ | |
| 29 | + public function __construct( Options_Helper $options ) { | |
| 30 | + $this->options = $options; | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * Checks if the integration should be active for the current user. | |
| 35 | + * | |
| 36 | + * @return bool Whether the integration is active. | |
| 37 | + */ | |
| 22 | 38 | public function is_active() { |
| 23 | - // If the integration is disabled, Wincher should not be active. | |
| 24 | - $conditional = new Wincher_Conditional(); | |
| 39 | + $conditional = new Non_Multisite_Conditional(); | |
| 40 | + | |
| 25 | 41 | if ( ! $conditional->is_met() ) { |
| 26 | 42 | return false; |
| 27 | 43 | } |
| 28 | 44 | |
| @@ -29,9 +45,9 @@ | ||
| 29 | 45 | if ( ! \current_user_can( 'publish_posts' ) && ! \current_user_can( 'publish_pages' ) ) { |
| 30 | 46 | return false; |
| 31 | 47 | } |
| 32 | 48 | |
| 33 | - return ! ! WPSEO_Options::get( 'wincher_integration_active', true ); | |
| 49 | + return (bool) $this->options->get( 'wincher_integration_active', true ); | |
| 34 | 50 | } |
| 35 | 51 | |
| 36 | 52 | /** |
| 37 | 53 | * Checks if the user is logged in to Wincher. |
| @@ -39,9 +55,9 @@ | ||
| 39 | 55 | * @return bool The Wincher login status. |
| 40 | 56 | */ |
| 41 | 57 | public function login_status() { |
| 42 | 58 | try { |
| 43 | - $wincher = YoastSEO()->classes->get( Wincher_Client::class ); | |
| 59 | + $wincher = \YoastSEO()->classes->get( Wincher_Client::class ); | |
| 44 | 60 | } catch ( Empty_Property_Exception $e ) { |
| 45 | 61 | // Return false if token is malformed (empty property). |
| 46 | 62 | return false; |
| 47 | 63 | } |
| @@ -66,10 +82,12 @@ | ||
| 66 | 82 | * @return string[] |
| 67 | 83 | */ |
| 68 | 84 | public function get_admin_global_links() { |
| 69 | 85 | return [ |
| 70 | - 'links.wincher.website' => 'https://www.wincher.com?utm_medium=plugin&utm_source=yoast&referer=yoast&partner=yoast', | |
| 71 | - 'links.wincher.pricing' => 'https://www.wincher.com/pricing?utm_medium=plugin&utm_source=yoast&referer=yoast&partner=yoast', | |
| 72 | - 'links.wincher.login' => 'https://app.wincher.com/login?utm_medium=plugin&utm_source=yoast&referer=yoast&partner=yoast', | |
| 86 | + 'links.wincher.login' => 'https://app.wincher.com/login?utm_medium=plugin&utm_source=yoast&referer=yoast&partner=yoast', | |
| 87 | + 'links.wincher.about' => WPSEO_Shortlinker::get( 'https://yoa.st/dashboard-about-wincher' ), | |
| 88 | + 'links.wincher.pricing' => WPSEO_Shortlinker::get( 'https://yoa.st/wincher-popup-pricing' ), | |
| 89 | + 'links.wincher.website' => WPSEO_Shortlinker::get( 'https://yoa.st/wincher-popup' ), | |
| 90 | + 'links.wincher.upgrade' => WPSEO_Shortlinker::get( 'https://yoa.st/wincher-upgrade' ), | |
| 73 | 91 | ]; |
| 74 | 92 | } |
| 75 | 93 | } |