has_access_and_refresh_token() ) { $this->api = new ConvertKit_API_V4( CONVERTKIT_OAUTH_CLIENT_ID, CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI, $settings->get_access_token(), $settings->get_refresh_token(), $settings->debug_enabled(), $context ); } // Call parent initialization function. parent::init(); } /** * Returns all non-inline forms based on the sort order. * * @since 2.2.4 * * @return bool|array */ public function get_non_inline() { // If the ConvertKit WordPress Libraries are < 1.3.6 (e.g. loaded by an outdated // addon), or a WordPress site updates this Plugin before other ConvertKit Plugins, // get_by() won't be available and will cause an E_ERROR, crashing the site. // @see https://wordpress.org/support/topic/error-1795/. if ( ! method_exists( $this, 'get_by' ) ) { return false; } return $this->get_by( 'format', array( 'modal', 'slide in', 'sticky bar' ) ); } /** * Returns whether any non-inline forms exist in the options table. * * @since 2.2.4 * * @return bool */ public function non_inline_exist() { if ( ! $this->get_non_inline() ) { return false; } return true; } /** * Determines if the given Form ID is a legacy Form or Landing Page. * * @since 2.5.0 * * @param int $id Form or Landing Page ID. */ public function is_legacy( $id ) { // Get Form. $form = $this->get_by_id( (int) $id ); // Return false if no Form exists. if ( ! $form ) { return false; } // If the `format` key exists, this is not a legacy Form. if ( array_key_exists( 'format', $form ) ) { return false; } return true; } /** * Returns a CSS class(es). * @param string $selected_option ', esc_attr( $value ), selected( $selected_option, $value, false ), esc_attr( $label ) ); } } // Iterate through resources, if they exist, building ', esc_attr( $form['id'] ), selected( $selected_option, $form['id'], false ), esc_attr( $form['name'] ), ( ! empty( $form['format'] ) ? esc_attr( $form['format'] ) : 'inline' ) ); } } // Close select. $html .= ''; // If no description is provided, return the select field now. if ( ! $description ) { return $html; } // Append description before returning field. if ( ! is_array( $description ) ) { return $html . '

' . $description . '

'; } // Return description lines in a paragraph, using breaklines for each description entry in the array. return $html . '

' . implode( '
', $description ) . '

'; } /** * Returns the HTML/JS markup for the given Form ID. * * Legacy Forms will return HTML. * Current Forms will return a '; // Return script output. return $output; } }