| @@ -84,8 +84,11 @@ | ||
| 84 | 84 | |
| 85 | 85 | // Enqueue Category CSS. |
| 86 | 86 | wp_enqueue_style( 'convertkit-category', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/category.css', array(), CONVERTKIT_PLUGIN_VERSION ); |
| 87 | 87 | |
| 88 | + // Enqueue Refresh Resources CSS. | |
| 89 | + wp_enqueue_style( 'convertkit-admin-refresh-resources', CONVERTKIT_PLUGIN_URL . 'resources/backend/css/refresh-resources.css', array(), CONVERTKIT_PLUGIN_VERSION ); | |
| 90 | + | |
| 88 | 91 | /** |
| 89 | 92 | * Enqueue CSS when editing a Category that outputs |
| 90 | 93 | * ConvertKit Plugin settings. |
| 91 | 94 | * |
| @@ -110,20 +113,15 @@ | ||
| 110 | 113 | return false; |
| 111 | 114 | } |
| 112 | 115 | |
| 113 | 116 | // Bail if we are not editing a Category. |
| 114 | - if ( ! function_exists( 'get_current_screen' ) ) { | |
| 117 | + if ( convertkit_get_current_screen( 'id' ) !== 'edit-category' ) { | |
| 115 | 118 | return false; |
| 116 | 119 | } |
| 117 | - $screen = get_current_screen(); | |
| 118 | 120 | |
| 119 | - if ( $screen->id !== 'edit-category' ) { | |
| 120 | - return false; | |
| 121 | - } | |
| 122 | - | |
| 123 | 121 | // Bail if the API hasn't been configured. |
| 124 | 122 | $settings = new ConvertKit_Settings(); |
| 125 | - if ( ! $settings->has_api_key_and_secret() ) { | |
| 123 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 126 | 124 | return false; |
| 127 | 125 | } |
| 128 | 126 | |
| 129 | 127 | return true; |
| @@ -137,9 +135,9 @@ | ||
| 137 | 135 | public function add_category_form_fields() { |
| 138 | 136 | |
| 139 | 137 | // Don't show the form fields if the API hasn't been configured. |
| 140 | 138 | $settings = new ConvertKit_Settings(); |
| 141 | - if ( ! $settings->has_api_key_and_secret() ) { | |
| 139 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 142 | 140 | return; |
| 143 | 141 | } |
| 144 | 142 | |
| 145 | 143 | // Fetch Forms. |
| @@ -160,9 +158,9 @@ | ||
| 160 | 158 | public function edit_category_form_fields( $term ) { |
| 161 | 159 | |
| 162 | 160 | // Don't show the form fields if the API hasn't been configured. |
| 163 | 161 | $settings = new ConvertKit_Settings(); |
| 164 | - if ( ! $settings->has_api_key_and_secret() ) { | |
| 162 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 165 | 163 | return; |
| 166 | 164 | } |
| 167 | 165 | |
| 168 | 166 | // Fetch Category Settings and Forms. |
| @@ -198,9 +196,12 @@ | ||
| 198 | 196 | return; |
| 199 | 197 | } |
| 200 | 198 | |
| 201 | 199 | // Build metadata. |
| 202 | - $meta = ( isset( $_POST['wp-convertkit']['form'] ) ? intval( $_POST['wp-convertkit']['form'] ) : '' ); | |
| 200 | + $meta = array( | |
| 201 | + 'form' => ( isset( $_POST['wp-convertkit']['form'] ) ? intval( $_POST['wp-convertkit']['form'] ) : '' ), | |
| 202 | + 'form_position' => ( isset( $_POST['wp-convertkit']['form_position'] ) ? sanitize_text_field( wp_unslash( $_POST['wp-convertkit']['form_position'] ) ) : '' ), | |
| 203 | + ); | |
| 203 | 204 | |
| 204 | 205 | // Save metadata. |
| 205 | 206 | $convertkit_term = new ConvertKit_Term( $term_id ); |
| 206 | 207 | return $convertkit_term->save( $meta ); |