← All changes
|
freemius/includes/managers/class-fs-plugin-manager.php
+20
-7
1.4.5
→
3.6.0
View file →
| @@ -82,14 +82,14 @@ | ||
| 82 | 82 | protected function get_all_modules( $module_type = false ) { |
| 83 | 83 | $option_manager = $this->get_option_manager(); |
| 84 | 84 | |
| 85 | 85 | if ( false !== $module_type ) { |
| 86 | - return $option_manager->get_option( $module_type . 's', array() ); | |
| 86 | + return fs_get_entities( $option_manager->get_option( $module_type . 's', array() ), FS_Plugin::get_class_name() ); | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | return array( |
| 90 | - self::OPTION_NAME_PLUGINS => $option_manager->get_option( self::OPTION_NAME_PLUGINS, array() ), | |
| 91 | - self::OPTION_NAME_THEMES => $option_manager->get_option( self::OPTION_NAME_THEMES, array() ), | |
| 90 | + self::OPTION_NAME_PLUGINS => fs_get_entities( $option_manager->get_option( self::OPTION_NAME_PLUGINS, array() ), FS_Plugin::get_class_name() ), | |
| 91 | + self::OPTION_NAME_THEMES => fs_get_entities( $option_manager->get_option( self::OPTION_NAME_THEMES, array() ), FS_Plugin::get_class_name() ), | |
| 92 | 92 | ); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| @@ -210,11 +210,24 @@ | ||
| 210 | 210 | * |
| 211 | 211 | * @return bool|\FS_Plugin |
| 212 | 212 | */ |
| 213 | 213 | function get() { |
| 214 | - return isset( $this->_module ) ? | |
| 215 | - $this->_module : | |
| 216 | - false; | |
| 217 | - } | |
| 214 | + if ( isset( $this->_module ) ) { | |
| 215 | + return $this->_module; | |
| 216 | + } | |
| 218 | 217 | |
| 218 | + if ( empty( $this->_module_id ) ) { | |
| 219 | + return false; | |
| 220 | + } | |
| 219 | 221 | |
| 222 | + /** | |
| 223 | + * Return an FS_Plugin entity that has its `id` and `is_live` properties set (`is_live` is initialized in the FS_Plugin constructor) to avoid triggering an error that is relevant to these properties when the FS_Plugin entity is used before the `parse_settings()` method is called. This can happen when creating a regular WordPress site by cloning a subsite of a multisite network and the data that is stored in the network-level storage is not cloned. | |
| 224 | + * | |
| 225 | + * @author Leo Fajardo (@leorw) | |
| 226 | + * @since 2.5.0 | |
| 227 | + */ | |
| 228 | + $plugin = new FS_Plugin(); | |
| 229 | + $plugin->id = $this->_module_id; | |
| 230 | + | |
| 231 | + return $plugin; | |
| 232 | + } | |
| 220 | 233 | } |