balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

manager.php (1458B)


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