key ) ) { return ''; } return $license->key; } /** * Check if license is currently active and valid * * @return bool True if active */ public function is_active() { $status = self::get_data(); if ( ! $status ) { return false; } if ( ! isset( $status->license ) ) { return false; } if ( 'valid' !== $status->license ) { return false; } return true; } /** * Get a setting value * * @param string $key Setting key * * @return mixed Setting value or null */ public function get_setting( $key ) { $data = self::get_data(); if ( false === $data ) { return null; } if ( 'plugin_id' === $key ) { return $data->download_id ?? null; } return null; } /** * Toggle license. * * @param string $action License action. * @param string $key License Key. * * @return array|\WP_Error Response. */ public function toggle_license( $action, $key ) { if ( 'deactivate' === $action ) { $key = apply_filters( 'product_woody_license_key', 'free' ); } $response = apply_filters( 'themeisle_sdk_license_process_woody', $key, $action ); if ( is_wp_error( $response ) ) { return $response; } return [ 'success' => true, 'message' => 'activate' === $action ? __( 'Activated', 'insert-php' ) : __( 'Deactivated', 'insert-php' ), 'license' => [ 'key' => apply_filters( 'product_woody_license_key', 'free' ), 'status' => apply_filters( 'product_woody_license_status', false ), ], ]; } }