| 1 |
<?php |
| 2 |
namespace Elementor\Core\Settings\EditorPreferences; |
| 3 |
|
| 4 |
use Elementor\Core\Settings\Base\Manager as BaseManager; |
| 5 |
use Elementor\Core\Settings\Base\Model as BaseModel; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
class Manager extends BaseManager { |
| 12 |
|
| 13 |
const META_KEY = 'elementor_preferences'; |
| 14 |
|
| 15 |
/** |
| 16 |
* Get model for config. |
| 17 |
* |
| 18 |
* Retrieve the model for settings configuration. |
| 19 |
* |
| 20 |
* @since 2.8.0 |
| 21 |
* @access public |
| 22 |
* |
| 23 |
* @return BaseModel The model object. |
| 24 |
*/ |
| 25 |
public function get_model_for_config() { |
| 26 |
return $this->get_model(); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Get manager name. |
| 31 |
* |
| 32 |
* Retrieve settings manager name. |
| 33 |
* |
| 34 |
* @since 2.8.0 |
| 35 |
* @access public |
| 36 |
*/ |
| 37 |
public function get_name() { |
| 38 |
return 'editorPreferences'; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Get saved settings. |
| 43 |
* |
| 44 |
* Retrieve the saved settings from the database. |
| 45 |
* |
| 46 |
* @since 2.8.0 |
| 47 |
* @access protected |
| 48 |
* |
| 49 |
* @param int $id |
| 50 |
* @return array |
| 51 |
*/ |
| 52 |
protected function get_saved_settings( $id ) { |
| 53 |
$settings = get_user_meta( get_current_user_id(), self::META_KEY, true ); |
| 54 |
|
| 55 |
if ( ! $settings ) { |
| 56 |
$settings = []; |
| 57 |
} |
| 58 |
|
| 59 |
return $settings; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Save settings to DB. |
| 64 |
* |
| 65 |
* Save settings to the database. |
| 66 |
* |
| 67 |
* @param array $settings Settings. |
| 68 |
* @param int $id Post ID. |
| 69 |
* @since 2.8.0 |
| 70 |
* @access protected |
| 71 |
*/ |
| 72 |
protected function save_settings_to_db( array $settings, $id ) { |
| 73 |
update_user_meta( get_current_user_id(), self::META_KEY, $settings ); |
| 74 |
} |
| 75 |
} |
| 76 |
|