| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | * @author ConvertKit |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | - * Registers a screen at Settings > ConvertKit in the WordPress Administration | |
| 10 | + * Registers a screen at Settings > Kit in the WordPress Administration | |
| 11 | 11 | * interface, and handles saving its data. |
| 12 | 12 | * |
| 13 | 13 | * @package ConvertKit |
| 14 | 14 | * @author ConvertKit |
| @@ -59,9 +59,9 @@ | ||
| 59 | 59 | // Get active settings section / tab that has been requested. |
| 60 | 60 | $section = $this->get_active_section(); |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * Enqueue JavaScript for the Settings Screen at Settings > ConvertKit | |
| 63 | + * Enqueue JavaScript for the Settings Screen at Settings > Kit | |
| 64 | 64 | * |
| 65 | 65 | * @since 1.9.6 |
| 66 | 66 | * |
| 67 | 67 | * @param string $section Settings section / tab (general|tools|restrict-content). |
| @@ -70,9 +70,9 @@ | ||
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Enqueue CSS for the Settings Screens at Settings > ConvertKit | |
| 74 | + * Enqueue CSS for the Settings Screens at Settings > Kit | |
| 75 | 75 | * |
| 76 | 76 | * @since 1.9.6 |
| 77 | 77 | * |
| 78 | 78 | * @param string $hook Hook. |
| @@ -90,9 +90,9 @@ | ||
| 90 | 90 | // Always enqueue Settings CSS, as this is used for the UI across all settings sections. |
| 91 | 91 | wp_enqueue_style( 'convertkit-admin-settings', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/settings.css', array(), CONVERTKIT_PLUGIN_VERSION ); |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * Enqueue CSS for the Settings Screen at Settings > ConvertKit | |
| 94 | + * Enqueue CSS for the Settings Screen at Settings > Kit | |
| 95 | 95 | * |
| 96 | 96 | * @since 1.9.6 |
| 97 | 97 | * |
| 98 | 98 | * @param string $section Settings section / tab (general|tools|restrict-content). |
| @@ -108,10 +108,10 @@ | ||
| 108 | 108 | */ |
| 109 | 109 | public function add_settings_page() { |
| 110 | 110 | |
| 111 | 111 | add_options_page( |
| 112 | - __( 'ConvertKit', 'convertkit' ), | |
| 113 | - __( 'ConvertKit', 'convertkit' ), | |
| 112 | + __( 'Kit', 'convertkit' ), | |
| 113 | + __( 'Kit', 'convertkit' ), | |
| 114 | 114 | 'manage_options', |
| 115 | 115 | self::SETTINGS_PAGE_SLUG, |
| 116 | 116 | array( $this, 'display_settings_page' ) |
| 117 | 117 | ); |
| @@ -128,9 +128,21 @@ | ||
| 128 | 128 | $active_section = $this->get_active_section(); |
| 129 | 129 | ?> |
| 130 | 130 | |
| 131 | 131 | <header> |
| 132 | - <h1><?php esc_html_e( 'ConvertKit', 'convertkit' ); ?></h1> | |
| 132 | + <h1><?php esc_html_e( 'Kit', 'convertkit' ); ?></h1> | |
| 133 | + | |
| 134 | + <?php | |
| 135 | + // Output Help link tab, if it exists. | |
| 136 | + $documentation_url = $this->get_active_section_documentation_url( $active_section ); | |
| 137 | + if ( $documentation_url !== false ) { | |
| 138 | + printf( | |
| 139 | + '<a href="%s" class="convertkit-docs" target="_blank">%s</a>', | |
| 140 | + esc_attr( $documentation_url ), | |
| 141 | + esc_html__( 'Help', 'convertkit' ) | |
| 142 | + ); | |
| 143 | + } | |
| 144 | + ?> | |
| 133 | 145 | </header> |
| 134 | 146 | |
| 135 | 147 | <div class="wrap"> |
| 136 | 148 | <?php |
| @@ -149,9 +161,9 @@ | ||
| 149 | 161 | </form> |
| 150 | 162 | |
| 151 | 163 | <p class="description"> |
| 152 | 164 | <?php |
| 153 | - // Output Documentation link, if it exists. | |
| 165 | + // Output Help link, if it exists. | |
| 154 | 166 | $documentation_url = $this->get_active_section_documentation_url( $active_section ); |
| 155 | 167 | if ( $documentation_url !== false ) { |
| 156 | 168 | printf( |
| 157 | 169 | '%s <a href="%s" target="_blank">%s</a>', |
| @@ -240,18 +252,8 @@ | ||
| 240 | 252 | esc_html( $section->tab_text ), |
| 241 | 253 | $section->is_beta ? $this->get_beta_tab() : '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 242 | 254 | ); |
| 243 | 255 | } |
| 244 | - | |
| 245 | - // Output Documentation link tab, if it exists. | |
| 246 | - $documentation_url = $this->get_active_section_documentation_url( $active_section ); | |
| 247 | - if ( $documentation_url !== false ) { | |
| 248 | - printf( | |
| 249 | - '<li class="convertkit-docs"><a href="%s" class="convertkit-tab" target="_blank">%s <span class="dashicons dashicons-external"></span></a></li>', | |
| 250 | - esc_attr( $documentation_url ), | |
| 251 | - esc_html__( 'Documentation', 'convertkit' ) | |
| 252 | - ); | |
| 253 | - } | |
| 254 | 256 | ?> |
| 255 | 257 | </ul> |
| 256 | 258 | <?php |
| 257 | 259 | // WordPress' JS will automatically move any .notice elements to be immediately below .wp-header-end |
| @@ -285,9 +287,9 @@ | ||
| 285 | 287 | |
| 286 | 288 | } |
| 287 | 289 | |
| 288 | 290 | /** |
| 289 | - * Registers settings sections at Settings > ConvertKit. | |
| 291 | + * Registers settings sections at Settings > Kit. | |
| 290 | 292 | * |
| 291 | 293 | * Each section has its own tab. |
| 292 | 294 | * |
| 293 | 295 | * @since 1.9.6 |
| @@ -293,16 +295,31 @@ | ||
| 293 | 295 | * @since 1.9.6 |
| 294 | 296 | */ |
| 295 | 297 | public function register_sections() { |
| 296 | 298 | |
| 299 | + // If no Access Token exists, register a settings section that shows a button | |
| 300 | + // to start the OAuth authentication flow. | |
| 301 | + $settings = new ConvertKit_Settings(); | |
| 302 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 303 | + // Just register the OAuth screen. | |
| 304 | + $sections = array( | |
| 305 | + 'oauth' => new ConvertKit_Admin_Section_OAuth(), | |
| 306 | + ); | |
| 307 | + | |
| 308 | + // Assign them to this class. | |
| 309 | + $this->sections = $sections; | |
| 310 | + | |
| 311 | + return; | |
| 312 | + } | |
| 313 | + | |
| 297 | 314 | // Register the General and Tools settings sections. |
| 298 | 315 | $sections = array( |
| 299 | - 'general' => new ConvertKit_Settings_General(), | |
| 300 | - 'tools' => new ConvertKit_Settings_Tools(), | |
| 316 | + 'general' => new ConvertKit_Admin_Section_General(), | |
| 317 | + 'tools' => new ConvertKit_Admin_Section_Tools(), | |
| 301 | 318 | ); |
| 302 | 319 | |
| 303 | 320 | /** |
| 304 | - * Registers settings sections at Settings > ConvertKit. | |
| 321 | + * Registers settings sections at Settings > Kit. | |
| 305 | 322 | * |
| 306 | 323 | * @since 1.9.6 |
| 307 | 324 | * |
| 308 | 325 | * @param array $sections Array of settings classes that handle individual tabs e.g. General, Tools etc. |