← All changes
|
includes/class-convertkit-settings-broadcasts.php
+10
-106
3.4.2
→
2.8.6
View file →
| @@ -190,110 +190,35 @@ | ||
| 190 | 190 | |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | - * Returns this settings group's programmatic name. | |
| 194 | + * Returns whether imported Broadcasts should have their Restrict Content | |
| 195 | + * setting defined, if the Broadcast is marked as paid. | |
| 195 | 196 | * |
| 196 | - * @since 3.4.0 | |
| 197 | + * @since 2.2.9 | |
| 197 | 198 | * |
| 198 | - * @return string | |
| 199 | + * @return bool | |
| 199 | 200 | */ |
| 200 | - public function get_name() { | |
| 201 | + public function restrict_content_enabled() { | |
| 201 | 202 | |
| 202 | - return 'broadcasts'; | |
| 203 | + return ! empty( $this->settings['restrict_content'] ); | |
| 203 | 204 | |
| 204 | 205 | } |
| 205 | 206 | |
| 206 | 207 | /** |
| 207 | - * Returns the title of this settings group. | |
| 208 | + * Returns the Restrict Content setting to assign to imported Broadcasts | |
| 208 | 209 | * |
| 209 | - * @since 3.4.0 | |
| 210 | + * @since 2.2.9 | |
| 210 | 211 | * |
| 211 | 212 | * @return string |
| 212 | 213 | */ |
| 213 | - public function get_title() { | |
| 214 | + public function restrict_content() { | |
| 214 | 215 | |
| 215 | - return __( 'Broadcasts Settings', 'convertkit' ); | |
| 216 | + return $this->settings['restrict_content']; | |
| 216 | 217 | |
| 217 | 218 | } |
| 218 | 219 | |
| 219 | 220 | /** |
| 220 | - * Returns the keys in this settings group that hold credentials or other | |
| 221 | - * sensitive values. | |
| 222 | - * | |
| 223 | - * @since 3.4.0 | |
| 224 | - * | |
| 225 | - * @return string[] | |
| 226 | - */ | |
| 227 | - public function get_secret_keys() { | |
| 228 | - | |
| 229 | - return array(); | |
| 230 | - | |
| 231 | - } | |
| 232 | - | |
| 233 | - /** | |
| 234 | - * Returns the JSON Schema describing this settings group, in the shape | |
| 235 | - * stored by save() / returned by get(), excluding secret keys. | |
| 236 | - * | |
| 237 | - * @since 3.4.0 | |
| 238 | - * | |
| 239 | - * @return array | |
| 240 | - */ | |
| 241 | - public function get_schema() { | |
| 242 | - | |
| 243 | - return array( | |
| 244 | - 'type' => 'object', | |
| 245 | - 'additionalProperties' => false, | |
| 246 | - 'properties' => array( | |
| 247 | - 'enabled' => array( | |
| 248 | - 'type' => 'string', | |
| 249 | - 'enum' => array( '', 'on' ), | |
| 250 | - 'description' => __( 'Whether importing Broadcasts from Kit to WordPress Posts is enabled.', 'convertkit' ), | |
| 251 | - ), | |
| 252 | - 'author_id' => array( | |
| 253 | - 'type' => 'integer', | |
| 254 | - 'minimum' => 1, | |
| 255 | - 'description' => __( 'WordPress User ID to assign as the Post author when importing Broadcasts.', 'convertkit' ), | |
| 256 | - ), | |
| 257 | - 'post_status' => array( | |
| 258 | - 'type' => 'string', | |
| 259 | - 'description' => __( 'WordPress Post status to assign to Posts created from imported Broadcasts (e.g. publish, draft).', 'convertkit' ), | |
| 260 | - ), | |
| 261 | - 'category_id' => array( | |
| 262 | - 'type' => array( 'integer', 'string' ), | |
| 263 | - 'description' => __( 'WordPress Category ID to assign to Posts created from imported Broadcasts. Blank for none.', 'convertkit' ), | |
| 264 | - ), | |
| 265 | - 'import_thumbnail' => array( | |
| 266 | - 'type' => 'string', | |
| 267 | - 'enum' => array( '', 'on' ), | |
| 268 | - 'description' => __( 'Whether to import the Broadcast thumbnail as the Post\'s Featured Image.', 'convertkit' ), | |
| 269 | - ), | |
| 270 | - 'import_images' => array( | |
| 271 | - 'type' => 'string', | |
| 272 | - 'enum' => array( '', 'on' ), | |
| 273 | - 'description' => __( 'Whether to import images referenced in the Broadcast\'s content into the WordPress Media Library.', 'convertkit' ), | |
| 274 | - ), | |
| 275 | - 'published_at_min_date' => array( | |
| 276 | - 'type' => 'string', | |
| 277 | - 'format' => 'date', | |
| 278 | - 'description' => __( 'Earliest published_at date (YYYY-MM-DD) of Broadcasts to import.', 'convertkit' ), | |
| 279 | - ), | |
| 280 | - 'enabled_export' => array( | |
| 281 | - 'type' => 'string', | |
| 282 | - 'enum' => array( '', 'on' ), | |
| 283 | - 'description' => __( 'Whether exporting WordPress Posts to Kit Broadcasts is enabled.', 'convertkit' ), | |
| 284 | - ), | |
| 285 | - 'no_styles' => array( | |
| 286 | - 'type' => 'string', | |
| 287 | - 'enum' => array( '', 'on' ), | |
| 288 | - 'description' => __( 'Whether inline styles on imported Broadcast content should be stripped.', 'convertkit' ), | |
| 289 | - ), | |
| 290 | - ), | |
| 291 | - ); | |
| 292 | - | |
| 293 | - } | |
| 294 | - | |
| 295 | - /** | |
| 296 | 221 | * The default settings, used when the ConvertKit Broadcasts Settings haven't been saved |
| 297 | 222 | * e.g. on a new installation. |
| 298 | 223 | * |
| 299 | 224 | * @since 2.2.9 |
| @@ -340,29 +265,8 @@ | ||
| 340 | 265 | */ |
| 341 | 266 | public function save( $settings ) { |
| 342 | 267 | |
| 343 | 268 | update_option( self::SETTINGS_NAME, array_merge( $this->get(), $settings ) ); |
| 344 | - | |
| 345 | - // Reload settings in class, to reflect changes. | |
| 346 | - $this->refresh_settings(); | |
| 347 | - | |
| 348 | - } | |
| 349 | - | |
| 350 | - /** | |
| 351 | - * Reloads settings from the options table so this instance has the latest values. | |
| 352 | - * | |
| 353 | - * @since 3.3.4 | |
| 354 | - */ | |
| 355 | - private function refresh_settings() { | |
| 356 | - | |
| 357 | - $settings = get_option( self::SETTINGS_NAME ); | |
| 358 | - | |
| 359 | - if ( ! $settings ) { | |
| 360 | - $this->settings = $this->get_defaults(); | |
| 361 | - return; | |
| 362 | - } | |
| 363 | - | |
| 364 | - $this->settings = array_merge( $this->get_defaults(), $settings ); | |
| 365 | 269 | |
| 366 | 270 | } |
| 367 | 271 | |
| 368 | 272 | } |