| @@ -1,36 +1,33 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace WPIDE\App\Services\View\Adapters; |
| 4 | 4 | |
| 5 | -use WPIDE\App\App ; | |
| 6 | -use WPIDE\App\Classes\Freemius ; | |
| 7 | -use WPIDE\App\Classes\Notices ; | |
| 8 | -use WPIDE\App\Config\Config ; | |
| 9 | -use WPIDE\App\Services\Service ; | |
| 10 | -use WPIDE\App\Services\View\ViewInterface ; | |
| 11 | -use WPIDE\WPIDE ; | |
| 12 | -use const WPIDE\Constants\ASSETS_URL ; | |
| 13 | -use const WPIDE\Constants\CONTENT_DIR ; | |
| 14 | -use const WPIDE\Constants\IS_DEV ; | |
| 15 | -use const WPIDE\Constants\NAME ; | |
| 16 | -use const WPIDE\Constants\SLUG ; | |
| 17 | -use const WPIDE\Constants\VERSION ; | |
| 18 | -class Vuejs implements Service, ViewInterface | |
| 19 | -{ | |
| 20 | - private $config ; | |
| 21 | - public function __construct( Config $config ) | |
| 22 | - { | |
| 5 | +use WPIDE\App\App; | |
| 6 | +use WPIDE\App\Classes\Freemius; | |
| 7 | +use WPIDE\App\Classes\Notices; | |
| 8 | +use WPIDE\App\Config\Config; | |
| 9 | +use WPIDE\App\Services\Service; | |
| 10 | +use WPIDE\App\Services\View\ViewInterface; | |
| 11 | +use WPIDE\WPIDE; | |
| 12 | +use const WPIDE\Constants\ASSETS_URL; | |
| 13 | +use const WPIDE\Constants\IS_DEV; | |
| 14 | +use const WPIDE\Constants\NAME; | |
| 15 | +use const WPIDE\Constants\SLUG; | |
| 16 | +use const WPIDE\Constants\VERSION; | |
| 17 | +use const WPIDE\Constants\WP_PATH; | |
| 18 | +class Vuejs implements Service, ViewInterface { | |
| 19 | + private $config; | |
| 20 | + | |
| 21 | + public function __construct( Config $config ) { | |
| 23 | 22 | $this->config = $config; |
| 24 | 23 | } |
| 25 | - | |
| 26 | - public function init( array $config = array() ) | |
| 27 | - { | |
| 28 | - $assets_url = ( !IS_DEV ? ASSETS_URL : WPIDE_DEV_ASSETS_URL ); | |
| 24 | + | |
| 25 | + public function init( array $config = [] ) { | |
| 26 | + $assets_url = ( !IS_DEV ? ASSETS_URL : WPIDE_DEV_URL ); | |
| 29 | 27 | $prod_assets_url = ASSETS_URL; |
| 30 | 28 | $skins_url = $prod_assets_url . 'css/skins/'; |
| 31 | 29 | $skin = $this->config->get( 'general.skin' ); |
| 32 | - | |
| 33 | 30 | if ( !IS_DEV ) { |
| 34 | 31 | wp_enqueue_style( |
| 35 | 32 | SLUG . '-vendors', |
| 36 | 33 | $assets_url . 'css/chunk-vendors.css', |
| @@ -43,9 +40,8 @@ | ||
| 43 | 40 | [], |
| 44 | 41 | VERSION |
| 45 | 42 | ); |
| 46 | 43 | } |
| 47 | - | |
| 48 | 44 | if ( $skin !== 'default' ) { |
| 49 | 45 | wp_enqueue_style( |
| 50 | 46 | SLUG . '-skin', |
| 51 | 47 | $skins_url . 'theme-' . $skin . '.css', |
| @@ -62,90 +58,111 @@ | ||
| 62 | 58 | ); |
| 63 | 59 | wp_enqueue_script( |
| 64 | 60 | SLUG, |
| 65 | 61 | $assets_url . 'js/app.js', |
| 66 | - [ 'jquery' ], | |
| 62 | + ['jquery'], | |
| 67 | 63 | VERSION, |
| 68 | 64 | true |
| 69 | 65 | ); |
| 70 | 66 | wp_localize_script( SLUG, 'WPIDE', [ |
| 71 | - 'premium' => Freemius::sdk()->can_use_premium_code__premium_only(), | |
| 72 | - 'plugin' => [ | |
| 73 | - 'name' => NAME, | |
| 74 | - 'slug' => SLUG, | |
| 75 | - ], | |
| 76 | - 'ajax_url' => App::instance()->getAjaxUrl(), | |
| 77 | - 'admin_url' => App::instance()->getAdminUrl(), | |
| 78 | - 'assets_url' => $assets_url, | |
| 79 | - 'prod_assets_url' => $prod_assets_url, | |
| 80 | - 'images_url' => $prod_assets_url . 'img/', | |
| 81 | - 'skins_url' => $skins_url, | |
| 82 | - 'is_dev' => IS_DEV, | |
| 83 | - 'config_fields' => $this->config->getConfigFields(), | |
| 84 | - 'filter_entries' => [ | |
| 85 | - SLUG . '/', | |
| 86 | - '/wp-admin/', | |
| 87 | - '/wp-includes/', | |
| 88 | - CONTENT_DIR . '/fatal-error-handler.php' | |
| 89 | - ], | |
| 90 | - 'notices' => Notices::all(), | |
| 91 | - 'account_links' => self::getAccountLinks(), | |
| 67 | + 'premium' => Freemius::sdk()->can_use_premium_code__premium_only(), | |
| 68 | + 'is_premium_version' => Freemius::sdk()->is__premium_only(), | |
| 69 | + 'is_license_active' => Freemius::sdk()->is__premium_only() && Freemius::sdk()->can_use_premium_code(), | |
| 70 | + 'show_freemius_menus' => Freemius::showSubmenus(), | |
| 71 | + 'plugin' => [ | |
| 72 | + 'name' => NAME, | |
| 73 | + 'slug' => SLUG, | |
| 74 | + 'version' => VERSION, | |
| 75 | + ], | |
| 76 | + 'ajax_url' => App::instance()->getAjaxUrl(), | |
| 77 | + 'admin_url' => App::instance()->getAdminUrl(), | |
| 78 | + 'assets_url' => $assets_url, | |
| 79 | + 'prod_assets_url' => $prod_assets_url, | |
| 80 | + 'images_url' => $prod_assets_url . 'img/', | |
| 81 | + 'skins_url' => $skins_url, | |
| 82 | + 'is_dev' => IS_DEV, | |
| 83 | + 'config_fields' => $this->config->getConfigFields(), | |
| 84 | + 'fm_wp_dir' => basename( WP_PATH ), | |
| 85 | + 'notices' => Notices::all(), | |
| 86 | + 'account_links' => self::getAccountLinks(), | |
| 92 | 87 | ] ); |
| 93 | 88 | $inline_scripts = apply_filters( 'wpide_inline_scripts', '' ); |
| 94 | - if ( !empty($inline_scripts) ) { | |
| 89 | + if ( !empty( $inline_scripts ) ) { | |
| 95 | 90 | wp_add_inline_script( SLUG, $inline_scripts ); |
| 96 | 91 | } |
| 92 | + if ( Freemius::showSubmenus() && Freemius::sdk()->is__premium_only() && !wp_doing_ajax() ) { | |
| 93 | + Freemius::addLicenseActivationDialogBox(); | |
| 94 | + } | |
| 97 | 95 | } |
| 98 | - | |
| 99 | - public function getAccountLinks() : array | |
| 100 | - { | |
| 96 | + | |
| 97 | + public function getAccountLinks() : array { | |
| 101 | 98 | $links = []; |
| 102 | - if ( Freemius::sdk()->is_pricing_page_visible() && Freemius::sdk()->is_submenu_item_visible( 'pricing' ) ) { | |
| 103 | - $links[] = array( | |
| 104 | - 'id' => '_pricing', | |
| 105 | - 'title' => esc_html__( 'Upgrade', 'wpide' ), | |
| 106 | - 'url' => Freemius::sdk()->get_upgrade_url(), | |
| 107 | - 'icon' => 'ni-arrow-up', | |
| 108 | - ); | |
| 109 | - } | |
| 110 | - | |
| 111 | - if ( Freemius::sdk()->is_registered() ) { | |
| 112 | - $links[] = array( | |
| 113 | - 'id' => 'account', | |
| 114 | - 'title' => esc_html__( 'Account', 'wpide' ), | |
| 115 | - 'url' => Freemius::sdk()->get_account_url(), | |
| 116 | - 'icon' => 'ni-user-alt', | |
| 117 | - ); | |
| 118 | - } else { | |
| 119 | - if ( Freemius::sdk()->is_tracking_prohibited() ) { | |
| 99 | + if ( Freemius::showSubmenus() ) { | |
| 100 | + if ( Freemius::showUpgradeLink() ) { | |
| 120 | 101 | $links[] = array( |
| 121 | - 'id' => 'optin', | |
| 122 | - 'title' => esc_html__( 'Opt In', 'wpide' ), | |
| 123 | - 'url' => Freemius::sdk()->get_reconnect_url(), | |
| 124 | - 'icon' => 'ni-user-check', | |
| 102 | + 'id' => '_pricing', | |
| 103 | + 'title' => esc_html__( 'Upgrade', 'wpide' ), | |
| 104 | + 'url' => Freemius::sdk()->get_upgrade_url(), | |
| 105 | + 'icon' => 'ni-arrow-up', | |
| 125 | 106 | ); |
| 107 | + if ( Freemius::showTrialLink() && !is_network_admin() ) { | |
| 108 | + $links[] = array( | |
| 109 | + 'id' => '_trial', | |
| 110 | + 'title' => esc_html__( 'Free Trial', 'wpide' ), | |
| 111 | + 'url' => Freemius::sdk()->get_trial_url(), | |
| 112 | + 'icon' => 'ni-clock', | |
| 113 | + ); | |
| 114 | + } | |
| 126 | 115 | } |
| 127 | - } | |
| 128 | - | |
| 129 | - if ( Freemius::sdk()->has_affiliate_program() ) { | |
| 116 | + if ( Freemius::sdk()->is_registered() ) { | |
| 117 | + $links[] = array( | |
| 118 | + 'id' => 'account', | |
| 119 | + 'title' => esc_html__( 'Account', 'wpide' ), | |
| 120 | + 'url' => Freemius::sdk()->get_account_url(), | |
| 121 | + 'icon' => 'ni-user-alt', | |
| 122 | + ); | |
| 123 | + } else { | |
| 124 | + if ( Freemius::sdk()->is_tracking_prohibited() ) { | |
| 125 | + $links[] = array( | |
| 126 | + 'id' => 'optin', | |
| 127 | + 'title' => esc_html__( 'Opt In', 'wpide' ), | |
| 128 | + 'url' => Freemius::sdk()->get_reconnect_url(), | |
| 129 | + 'icon' => 'ni-user-check', | |
| 130 | + ); | |
| 131 | + } | |
| 132 | + } | |
| 133 | + if ( Freemius::sdk()->has_affiliate_program() ) { | |
| 134 | + $links[] = array( | |
| 135 | + 'id' => 'affiliates', | |
| 136 | + 'title' => esc_html__( 'Affiliates', 'wpide' ), | |
| 137 | + 'url' => Freemius::sdk()->_get_admin_page_url( 'affiliation' ), | |
| 138 | + 'icon' => 'ni-money', | |
| 139 | + ); | |
| 140 | + } | |
| 130 | 141 | $links[] = array( |
| 131 | - 'id' => 'affiliates', | |
| 132 | - 'title' => esc_html__( 'Affiliates', 'wpide' ), | |
| 133 | - 'url' => Freemius::sdk()->_get_admin_page_url( 'affiliation' ), | |
| 134 | - 'icon' => 'ni-money', | |
| 142 | + 'id' => 'contact', | |
| 143 | + 'title' => esc_html__( 'Support', 'wpide' ), | |
| 144 | + 'url' => Freemius::sdk()->contact_url(), | |
| 145 | + 'icon' => 'ni-help', | |
| 135 | 146 | ); |
| 136 | 147 | } |
| 137 | 148 | $links[] = array( |
| 138 | - 'id' => 'contact', | |
| 139 | - 'title' => esc_html__( 'Support', 'wpide' ), | |
| 140 | - 'url' => Freemius::sdk()->contact_url(), | |
| 141 | - 'icon' => 'ni-help', | |
| 149 | + 'id' => 'changelog', | |
| 150 | + 'title' => esc_html__( 'Change Log', 'wpide' ), | |
| 151 | + 'url' => App::instance()->getAdminUrl( 'changelog' ), | |
| 152 | + 'icon' => 'ni-notes-alt', | |
| 142 | 153 | ); |
| 154 | + $links[] = array( | |
| 155 | + 'id' => 'site', | |
| 156 | + 'title' => esc_html__( 'Other Plugins', 'wpide' ), | |
| 157 | + 'url' => 'https://xplodedthemes.com', | |
| 158 | + 'icon' => 'ni-link', | |
| 159 | + 'external' => true, | |
| 160 | + ); | |
| 143 | 161 | return $links; |
| 144 | 162 | } |
| 145 | - | |
| 146 | - public function getIndexPage() : string | |
| 147 | - { | |
| 163 | + | |
| 164 | + public function getIndexPage() : string { | |
| 148 | 165 | $output = ' |
| 149 | 166 | <noscript><strong>Please enable JavaScript to continue.</strong></noscript> |
| 150 | 167 | <div id="' . SLUG . '-app"></div> |
| 151 | 168 | '; |
| @@ -151,5 +168,5 @@ | ||
| 151 | 168 | '; |
| 152 | 169 | return $output; |
| 153 | 170 | } |
| 154 | 171 | |
| 155 | -} | |
| 172 | +} | |