| @@ -64,55 +64,51 @@ | ||
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * Returns Broadcasts settings value for the given key. | |
| 68 | + * Returns whether Broadcasts are enabled in the Plugin settings. | |
| 69 | 69 | * |
| 70 | 70 | * @since 2.2.9 |
| 71 | 71 | * |
| 72 | - * @param string $key Setting Key. | |
| 73 | - * @return string Value | |
| 72 | + * @return bool | |
| 74 | 73 | */ |
| 75 | - public function get_by_key( $key ) { | |
| 74 | + public function enabled() { | |
| 76 | 75 | |
| 77 | - // If the setting doesn't exist, bail. | |
| 78 | - if ( ! array_key_exists( $key, $this->settings ) ) { | |
| 79 | - return ''; | |
| 76 | + // Check if DOMDocument is installed. | |
| 77 | + // It should be installed as mosts hosts include php-dom and php-xml modules. | |
| 78 | + // If not, disable Broadcast to Posts import functionality as we can't parse | |
| 79 | + // imported Broadcasts. | |
| 80 | + if ( ! class_exists( 'DOMDocument' ) ) { | |
| 81 | + return false; | |
| 80 | 82 | } |
| 81 | 83 | |
| 82 | - // If the setting is empty, fallback to the default. | |
| 83 | - if ( empty( $this->settings[ $key ] ) ) { | |
| 84 | - $defaults = $this->get_defaults(); | |
| 85 | - return $defaults[ $key ]; | |
| 86 | - } | |
| 84 | + return ( $this->settings['enabled'] === 'on' ? true : false ); | |
| 87 | 85 | |
| 88 | - return $this->settings[ $key ]; | |
| 89 | - | |
| 90 | 86 | } |
| 91 | 87 | |
| 92 | 88 | /** |
| 93 | - * Returns whether Broadcasts are enabled in the Plugin settings. | |
| 89 | + * Returns the WordPress Author ID to assign imported Broadcasts to. | |
| 94 | 90 | * |
| 95 | 91 | * @since 2.2.9 |
| 96 | 92 | * |
| 97 | - * @return bool | |
| 93 | + * @return int | |
| 98 | 94 | */ |
| 99 | - public function enabled() { | |
| 95 | + public function author_id() { | |
| 100 | 96 | |
| 101 | - return ( $this->settings['enabled'] === 'on' ? true : false ); | |
| 97 | + return $this->settings['author_id']; | |
| 102 | 98 | |
| 103 | 99 | } |
| 104 | 100 | |
| 105 | 101 | /** |
| 106 | - * Returns the WordPress Author ID to assign imported Broadcasts to. | |
| 102 | + * Returns the WordPress Post Status to assign to Posts created from imported Broadcasts. | |
| 107 | 103 | * |
| 108 | - * @since 2.2.9 | |
| 104 | + * @since 2.3.4 | |
| 109 | 105 | * |
| 110 | - * @return int | |
| 106 | + * @return string | |
| 111 | 107 | */ |
| 112 | - public function author_id() { | |
| 108 | + public function post_status() { | |
| 113 | 109 | |
| 114 | - return $this->settings['author_id']; | |
| 110 | + return $this->settings['post_status']; | |
| 115 | 111 | |
| 116 | 112 | } |
| 117 | 113 | |
| 118 | 114 | /** |
| @@ -128,8 +124,34 @@ | ||
| 128 | 124 | |
| 129 | 125 | } |
| 130 | 126 | |
| 131 | 127 | /** |
| 128 | + * Returns whether to import the thumbnail to the Featured Image. | |
| 129 | + * | |
| 130 | + * @since 2.4.1 | |
| 131 | + * | |
| 132 | + * @return bool | |
| 133 | + */ | |
| 134 | + public function import_thumbnail() { | |
| 135 | + | |
| 136 | + return ( $this->settings['import_thumbnail'] === 'on' ? true : false ); | |
| 137 | + | |
| 138 | + } | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * Returns whether to import the thumbnail to the Featured Image. | |
| 142 | + * | |
| 143 | + * @since 2.6.3 | |
| 144 | + * | |
| 145 | + * @return bool | |
| 146 | + */ | |
| 147 | + public function import_images() { | |
| 148 | + | |
| 149 | + return ( $this->settings['import_images'] === 'on' ? true : false ); | |
| 150 | + | |
| 151 | + } | |
| 152 | + | |
| 153 | + /** | |
| 132 | 154 | * Returns the earliest date that Broadcasts should be imported, |
| 133 | 155 | * based on their published_at date. |
| 134 | 156 | * |
| 135 | 157 | * @since 2.2.9 |
| @@ -142,8 +164,21 @@ | ||
| 142 | 164 | |
| 143 | 165 | } |
| 144 | 166 | |
| 145 | 167 | /** |
| 168 | + * Returns whether exporting Posts to Broadcasts is enabled in the Plugin settings. | |
| 169 | + * | |
| 170 | + * @since 2.4.0 | |
| 171 | + * | |
| 172 | + * @return bool | |
| 173 | + */ | |
| 174 | + public function enabled_export() { | |
| 175 | + | |
| 176 | + return ( $this->settings['enabled_export'] === 'on' ? true : false ); | |
| 177 | + | |
| 178 | + } | |
| 179 | + | |
| 180 | + /** | |
| 146 | 181 | * Returns whether Broadcasts should have their styles imported. |
| 147 | 182 | * |
| 148 | 183 | * @since 2.2.9 |
| 149 | 184 | * |
| @@ -194,14 +229,17 @@ | ||
| 194 | 229 | |
| 195 | 230 | $defaults = array( |
| 196 | 231 | 'enabled' => '', |
| 197 | 232 | 'author_id' => get_current_user_id(), |
| 233 | + 'post_status' => 'publish', | |
| 198 | 234 | 'category_id' => '', |
| 235 | + 'import_thumbnail' => 'on', | |
| 236 | + 'import_images' => '', | |
| 199 | 237 | |
| 200 | 238 | // By default, only import Broadcasts as Posts for the last 30 days. |
| 201 | 239 | 'published_at_min_date' => gmdate( 'Y-m-d', strtotime( '-30 days' ) ), |
| 202 | 240 | |
| 203 | - 'restrict_content' => '', | |
| 241 | + 'enabled_export' => '', | |
| 204 | 242 | 'no_styles' => '', |
| 205 | 243 | ); |
| 206 | 244 | |
| 207 | 245 | /** |
| @@ -209,9 +247,9 @@ | ||
| 209 | 247 | * e.g. on a new installation. |
| 210 | 248 | * |
| 211 | 249 | * @since 2.2.9 |
| 212 | 250 | * |
| 213 | - * @param array $defaults | |
| 251 | + * @param array $defaults Default settings. | |
| 214 | 252 | */ |
| 215 | 253 | $defaults = apply_filters( 'convertkit_settings_broadcasts_get_defaults', $defaults ); |
| 216 | 254 | |
| 217 | 255 | return $defaults; |