| @@ -110,20 +110,15 @@ | ||
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Bail if we are not editing a Category. |
| 114 | - if ( ! function_exists( 'get_current_screen' ) ) { | |
| 114 | + if ( convertkit_get_current_screen( 'id' ) !== 'edit-category' ) { | |
| 115 | 115 | return false; |
| 116 | 116 | } |
| 117 | - $screen = get_current_screen(); | |
| 118 | 117 | |
| 119 | - if ( $screen->id !== 'edit-category' ) { | |
| 120 | - return false; | |
| 121 | - } | |
| 122 | - | |
| 123 | 118 | // Bail if the API hasn't been configured. |
| 124 | 119 | $settings = new ConvertKit_Settings(); |
| 125 | - if ( ! $settings->has_api_key_and_secret() ) { | |
| 120 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 126 | 121 | return false; |
| 127 | 122 | } |
| 128 | 123 | |
| 129 | 124 | return true; |
| @@ -137,9 +132,9 @@ | ||
| 137 | 132 | public function add_category_form_fields() { |
| 138 | 133 | |
| 139 | 134 | // Don't show the form fields if the API hasn't been configured. |
| 140 | 135 | $settings = new ConvertKit_Settings(); |
| 141 | - if ( ! $settings->has_api_key_and_secret() ) { | |
| 136 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 142 | 137 | return; |
| 143 | 138 | } |
| 144 | 139 | |
| 145 | 140 | // Fetch Forms. |
| @@ -160,9 +155,9 @@ | ||
| 160 | 155 | public function edit_category_form_fields( $term ) { |
| 161 | 156 | |
| 162 | 157 | // Don't show the form fields if the API hasn't been configured. |
| 163 | 158 | $settings = new ConvertKit_Settings(); |
| 164 | - if ( ! $settings->has_api_key_and_secret() ) { | |
| 159 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 165 | 160 | return; |
| 166 | 161 | } |
| 167 | 162 | |
| 168 | 163 | // Fetch Category Settings and Forms. |
| @@ -198,9 +193,12 @@ | ||
| 198 | 193 | return; |
| 199 | 194 | } |
| 200 | 195 | |
| 201 | 196 | // Build metadata. |
| 202 | - $meta = ( isset( $_POST['wp-convertkit']['form'] ) ? intval( $_POST['wp-convertkit']['form'] ) : '' ); | |
| 197 | + $meta = array( | |
| 198 | + 'form' => ( isset( $_POST['wp-convertkit']['form'] ) ? intval( $_POST['wp-convertkit']['form'] ) : '' ), | |
| 199 | + 'form_position' => ( isset( $_POST['wp-convertkit']['form_position'] ) ? $_POST['wp-convertkit']['form_position'] : '' ), | |
| 200 | + ); | |
| 203 | 201 | |
| 204 | 202 | // Save metadata. |
| 205 | 203 | $convertkit_term = new ConvertKit_Term( $term_id ); |
| 206 | 204 | return $convertkit_term->save( $meta ); |