| @@ -47,8 +47,15 @@ | ||
| 47 | 47 | */ |
| 48 | 48 | const SETTINGS_SLUG = 'gutslider-settings'; |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | + * Page slug for the Free vs Pro comparison. | |
| 52 | + * | |
| 53 | + * @var string | |
| 54 | + */ | |
| 55 | + const COMPARE_SLUG = 'gutslider-free-vs-pro'; | |
| 56 | + | |
| 57 | + /** | |
| 51 | 58 | * Transient holding the cached content-usage scan. |
| 52 | 59 | * |
| 53 | 60 | * @var string |
| 54 | 61 | */ |
| @@ -241,11 +248,36 @@ | ||
| 241 | 248 | 'manage_options', |
| 242 | 249 | self::SETTINGS_SLUG, |
| 243 | 250 | array( $this, 'render_settings_page' ) |
| 244 | 251 | ); |
| 252 | + | |
| 253 | + if ( self::show_compare() ) { | |
| 254 | + add_submenu_page( | |
| 255 | + self::MENU_SLUG, | |
| 256 | + __( 'Free vs Pro', 'slider-blocks' ), | |
| 257 | + __( 'Free vs Pro', 'slider-blocks' ), | |
| 258 | + 'manage_options', | |
| 259 | + self::COMPARE_SLUG, | |
| 260 | + array( $this, 'render_compare_page' ) | |
| 261 | + ); | |
| 262 | + } | |
| 245 | 263 | } |
| 246 | 264 | |
| 247 | 265 | /** |
| 266 | + * Whether the Free vs Pro page is offered. | |
| 267 | + * | |
| 268 | + * @return bool True while GutSlider Pro isn't active. | |
| 269 | + */ | |
| 270 | + public static function show_compare() { | |
| 271 | + /** | |
| 272 | + * Whether the dashboard offers the Free vs Pro comparison. | |
| 273 | + * | |
| 274 | + * @param bool $show True while GutSlider Pro isn't active. | |
| 275 | + */ | |
| 276 | + return (bool) apply_filters( 'gutslider_show_pro_compare', ! defined( 'GUTSLIDER_PRO_VERSION' ) ); | |
| 277 | + } | |
| 278 | + | |
| 279 | + /** | |
| 248 | 280 | * Screen IDs that should receive the dashboard assets. |
| 249 | 281 | * |
| 250 | 282 | * @return array<int, string> Screen IDs. |
| 251 | 283 | */ |
| @@ -253,8 +285,9 @@ | ||
| 253 | 285 | return array( |
| 254 | 286 | 'toplevel_page_' . self::MENU_SLUG, |
| 255 | 287 | 'gutslider_page_' . self::BLOCKS_SLUG, |
| 256 | 288 | 'gutslider_page_' . self::SETTINGS_SLUG, |
| 289 | + 'gutslider_page_' . self::COMPARE_SLUG, | |
| 257 | 290 | 'gutslider_page_gutslider-license', |
| 258 | 291 | ); |
| 259 | 292 | } |
| 260 | 293 | |
| @@ -842,8 +875,23 @@ | ||
| 842 | 875 | 'blocks' => $blocks, |
| 843 | 876 | 'total' => count( $blocks ), |
| 844 | 877 | 'enabled' => self::count_enabled( $blocks ), |
| 845 | 878 | 'current' => self::BLOCKS_SLUG, |
| 879 | + ) | |
| 880 | + ); | |
| 881 | + } | |
| 882 | + | |
| 883 | + /** | |
| 884 | + * Render the Free vs Pro screen. | |
| 885 | + * | |
| 886 | + * @return void | |
| 887 | + */ | |
| 888 | + public function render_compare_page() { | |
| 889 | + $this->view( | |
| 890 | + 'compare-page', | |
| 891 | + array( | |
| 892 | + 'blocks' => $this->get_blocks_with_state(), | |
| 893 | + 'current' => self::COMPARE_SLUG, | |
| 846 | 894 | ) |
| 847 | 895 | ); |
| 848 | 896 | } |
| 849 | 897 | |