settings = $this->get_defaults(); } else { $this->settings = array_merge( $this->get_defaults(), $settings ); } } /** * Returns Plugin settings. * * @since 3.4.0 * * @return array */ public function get() { return $this->settings; } /** * Returns whether the user has access to MCP via a paid plan, * and if so whether the MCP server is enabled in the Plugin's settings. * * @since 3.4.0 * * @return bool */ public function enabled() { // Bail if the connected Kit account isn't on a paid plan. // This queries the cached account details, so no live API call is made. $account = new ConvertKit_Resource_Account(); if ( ! $account->is_paid_plan() ) { return false; } return ( $this->settings['enabled'] === 'on' ? true : false ); } /** * The default settings, used when the ConvertKit MCP Settings haven't been saved * e.g. on a new installation. * * @since 2.1.0 * * @return array */ public function get_defaults() { $defaults = array( 'enabled' => '', // blank|on. ); /** * The default settings, used when the ConvertKit MCP Settings haven't been saved * e.g. on a new installation. * * @since 3.4.0 * * @param array $defaults Default settings. */ $defaults = apply_filters( 'convertkit_settings_mcp_get_defaults', $defaults ); return $defaults; } /** * Saves the given array of settings to the WordPress options table. * * @since 3.4.0 * * @param array $settings Settings. */ public function save( $settings ) { update_option( self::SETTINGS_NAME, array_merge( $this->get(), $settings ) ); } }