Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/jet-menu   php

Repository URL to install this package:

Version: 2.0.9 

/ class-jet-menu-options-page.php

<?php
/**
 * Option page Class
 */

// If class `Popups_Options_Page` doesn't exists yet.
if ( ! class_exists( 'Jet_Menu_Options_Page' ) ) {

	/**
	 * Jet_Menu_Options_Page class.
	 */
	class Jet_Menu_Options_Page {

		/**
		 * A reference to an instance of this class.
		 *
		 * @since 1.0.0
		 * @var object
		 */
		private static $instance = null;

		/**
		 * Fonts loader instance
		 *
		 * @var object
		 */
		public $fonts_loader = null;

		/**
		 * [$customizer description]
		 * @var null
		 */
		protected $customizer = null;

		/**
		 * [$current_options description]
		 * @var array
		 */
		public $current_options = array();

		/**
		 * Default options
		 *
		 * @var array
		 */
		public $default_options = array(
			'jet-menu-animation'             => 'fade',
			'jet-menu-mega-bg-type'          => 'fill-color',
			'jet-menu-mega-bg-color'         => '#fff',
			'jet-menu-mega-bg-color-opacity' => 100,
			'jet-menu-mega-bg-image'         => '',
			'jet-menu-mega-padding'          => array(
				'units'     => 'px',
				'is_linked' => true,
				'size'      => array(
					'top'       => '10',
					'right'     => '10',
					'bottom'    => '10',
					'left'      => '10',
				),
			),
		);

		/**
		 * Options cache
		 *
		 * @var boolean
		 */
		private $options = false;

		/**
		 * Slug DB option field.
		 *
		 * @since 1.0.0
		 * @var object
		 */
		private $options_slug = 'jet_menu_options';

		/**
		 * Class constructor.
		 *
		 * @since 1.0.0
		 * @access public
		 * @return void
		 */
		public function __construct() {

			$module_data = jet_menu()->module_loader->get_included_module_data( 'cherry-x-customizer.php' );

			$this->customizer = new CX_Customizer(
				array(
					'prefix'     => 'jet-menu',
					'options'    => array(),
					'path'       => $module_data['path'],
					'just_fonts' => true,
				)
			);

			$this->fonts_loader = new CX_Fonts_Manager(
				array(
					'prefix'    => $this->options_slug(),
					'type'      => 'option',
					'single'    => true,
					'get_fonts' => function() {
						return $fonts = $this->customizer->get_fonts();
					},
					'options'   => array(
						'main' => array(
							'family'  => 'jet-top-menu-font-family',
							'style'   => 'jet-top-menu-font-style',
							'weight'  => 'jet-top-menu-font-weight',
							'charset' => 'jet-top-menu-subset',
						),
						'main-desc' => array(
							'family'  => 'jet-top-menu-desc-font-family',
							'style'   => 'jet-top-menu-desc-font-style',
							'weight'  => 'jet-top-menu-desc-font-weight',
							'charset' => 'jet-top-menu-desc-subset',
						),
						'sub' => array(
							'family'  => 'jet-sub-menu-font-family',
							'style'   => 'jet-sub-menu-font-style',
							'weight'  => 'jet-sub-menu-font-weight',
							'charset' => 'jet-sub-menu-subset',
						),
						'sub-desc' => array(
							'family'  => 'jet-sub-menu-desc-font-family',
							'style'   => 'jet-sub-menu-desc-font-style',
							'weight'  => 'jet-sub-menu-desc-font-weight',
							'charset' => 'jet-sub-menu-desc-subset',
						),
						'top-badge' => array(
							'family'  => 'jet-menu-top-badge-font-family',
							'style'   => 'jet-menu-top-badge-font-style',
							'weight'  => 'jet-menu-top-badge-font-weight',
							'charset' => 'jet-menu-top-badge-subset',
						),
						'sub-badge' => array(
							'family'  => 'jet-menu-sub-badge-font-family',
							'style'   => 'jet-menu-sub-badge-font-style',
							'weight'  => 'jet-menu-sub-badge-font-weight',
							'charset' => 'jet-menu-sub-badge-subset',
						),
						'mobile-toggle-typo' => array(
							'family'  => 'jet-menu-mobile-toggle-text-font-family',
							'style'   => 'jet-menu-mobile-toggle-text-font-style',
							'weight'  => 'jet-menu-mobile-toggle-text-font-weight',
							'charset' => 'jet-menu-mobile-toggle-text-subset',
						),
						'mobile-back-typo' => array(
							'family'  => 'jet-menu-mobile-back-text-font-family',
							'style'   => 'jet-menu-mobile-back-text-font-style',
							'weight'  => 'jet-menu-mobile-back-text-font-weight',
							'charset' => 'jet-menu-mobile-back-text-subset',
						),
						'mobile-breadcrumbs-typo' => array(
							'family'  => 'jet-menu-mobile-breadcrumbs-text-font-family',
							'style'   => 'jet-menu-mobile-breadcrumbs-text-font-style',
							'weight'  => 'jet-menu-mobile-breadcrumbs-text-font-weight',
							'charset' => 'jet-menu-mobile-breadcrumbs-text-subset',
						),
						'mobile-label-typo' => array(
							'family'  => 'jet-mobile-items-label-font-family',
							'style'   => 'jet-mobile-items-label-font-style',
							'weight'  => 'jet-mobile-items-label-font-weight',
							'charset' => 'jet-mobile-items-label-subset',
						),
						'mobile-items-desc' => array(
							'family'  => 'jet-mobile-items-desc-font-family',
							'style'   => 'jet-mobile-items-desc-font-style',
							'weight'  => 'jet-mobile-items-desc-font-weight',
							'charset' => 'jet-mobile-items-desc-subset',
						),
						'mobile-badge-typo' => array(
							'family'  => 'jet-mobile-items-badge-font-family',
							'style'   => 'jet-mobile-items-badge-font-style',
							'weight'  => 'jet-mobile-items-badge-font-weight',
							'charset' => 'jet-mobile-items-badge-subset',
						),

					),
				)
			);

			if ( is_admin() ) {
				add_action( 'admin_init', array( $this, 'process_export' ) );
				add_action( 'admin_init', array( $this, 'process_reset' ) );
			}

			// Load the admin menu.
			add_action( 'wp_ajax_jet_menu_import_options', array( $this, 'process_import' ) );

			add_filter( 'jet-data-importer/export/options-to-export', array( $this, 'export_menu_options' ) );
		}

		/**
		 * Return options db key.
		 *
		 * @return string
		 */

		public function options_slug() {
			return $this->options_slug;
		}

		/**
		 * Pass menu options key into exported options array
		 *
		 * @param  [type] $options [description]
		 * @return [type]          [description]
		 */
		public function export_menu_options( $options ) {
			$options[] = $this->options_slug;

			return $options;
		}

		/**
		 * [get_options_page_config description]
		 * @return [type] [description]
		 */
		public function get_options_page_config() {

			$rest_api_url = apply_filters( 'jet-menu/rest/admin/url', get_rest_url() );

			return array(
				'optionsApiUrl'    => $rest_api_url . 'jet-menu-api/v1/plugin-settings',
				'rawOptionsData'   => $this->get_option(),
				'optionPresetList' => jet_menu_options_presets()->get_presets_select_options(),
				'importUrl'        => add_query_arg( array( 'jet-action' => 'import-options' ), esc_url( admin_url( 'admin.php' ) ) ),
				'exportUrl'        => add_query_arg( array( 'jet-action' => 'export-options' ), esc_url( admin_url( 'admin.php' ) ) ),
				'resetUrl'         => add_query_arg( array( 'jet-action' => 'reset-options' ), esc_url( admin_url( 'admin.php' ) ) ),
				'optionsPageUrl'   => add_query_arg( array( 'page' => 'jet-dashboard-settings-page', 'subpage' => 'jet-menu-general-settings' ), esc_url( admin_url( 'admin.php' ) ) ),
				'optionsData'      => $this->get_options_data(),
				'arrowsIcons'      => jet_menu_tools()->get_arrows_icons(),
				'iconsFetchJson'   => jet_menu()->plugin_url( 'assets/public/lib/font-awesome/js/solid.js' ),
				'templateList'     => jet_menu_tools()->get_elementor_templates_select_options(),
			);
		}

		/**
		 * [get_options_data description]
		 * @return [type] [description]
		 */
		public function get_options_data() {

			$default_dimensions = array(
				'top'       => '',
				'right'     => '',
				'bottom'    => '',
				'left'      => '',
				'is_linked' => true,
				'units'     => 'px',
			);

			$this->add_option( 'svg-uploads', array(
				'value' => $this->get_option( 'svg-uploads', 'enabled' ),
			) );

			$this->add_option( 'use-template-cache', array(
				'value' => $this->get_option( 'use-template-cache', 'true' ),
			) );

			// General
			$this->add_option( 'jet-menu-animation', array(
				'value'   => $this->get_option( 'jet-menu-animation', 'fade' ),
				'options' => array(
					array(
						'label' => esc_html__( 'None', 'jet-menu' ),
						'value' => 'none',
					),
					array(
						'label' => esc_html__( 'Fade', 'jet-menu' ),
						'value' => 'fade',
					),
					array(
						'label' => esc_html__( 'Move Up', 'jet-menu' ),
						'value' => 'move-up',
					),
					array(
						'label' => esc_html__( 'Move Down', 'jet-menu' ),
						'value' => 'move-down',
					)
				),
			) );

			$this->add_option( 'jet-menu-roll-up', array(
				'value' => $this->get_option( 'jet-menu-roll-up', 'true' ),
			) );

			$this->add_option( 'jet-menu-show-for-device', array(
				'value'   => $this->get_option( 'jet-menu-show-for-device', 'both' ),
				'options' => array(
					array(
						'label' => esc_html__( 'Desktop and mobile view', 'jet-menu' ),
						'value' => 'both',
					),
					array(
						'label' => esc_html__( 'Desktop view on all devices', 'jet-menu' ),
						'value' => 'desktop',
					),
					array(
						'label' => esc_html__( 'Mobile view on all devices', 'jet-menu' ),
						'value' => 'mobile',
					),
				),
			) );

			$this->add_option( 'jet-menu-mega-ajax-loading', array(
				'value' => $this->get_option( 'jet-menu-mega-ajax-loading', false ),
			) );

			$this->add_option( 'jet-menu-mouseleave-delay', array(
				'value' => $this->get_option( 'jet-menu-mouseleave-delay', 500 ),
			) );

			$this->add_option( 'jet-mega-menu-width-type', array(
				'value'   => $this->get_option( 'jet-mega-menu-width-type', 'container' ),
				'options' => array(
					array(
						'label' => esc_html__( 'Width same as main container width', 'jet-menu' ),
						'value' => 'container',
					),
					array(
						'label' => esc_html__( 'Width same as total items width', 'jet-menu' ),
						'value' => 'items',
					),
					array(
						'label' => esc_html__( 'Width same as Custom css selector width', 'jet-menu' ),
						'value' => 'selector',
					)
				),
			) );

			$this->add_option( 'jet-mega-menu-selector-width-type', array(
				'value' => $this->get_option( 'jet-mega-menu-selector-width-type', '' ),
			) );

			$this->add_option( 'jet-menu-open-sub-type', array(
				'value' => $this->get_option( 'jet-menu-open-sub-type', 'hover' ),
				'options' => array(
					array(
						'label' => esc_html__( 'Hover', 'jet-menu' ),
						'value' => 'hover',
					),
Loading ...