Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings-link does not work in exopite simple options framework #19

Open
chaimiko opened this issue Apr 10, 2023 · 3 comments
Open

settings-link does not work in exopite simple options framework #19

chaimiko opened this issue Apr 10, 2023 · 3 comments

Comments

@chaimiko
Copy link

Hi, first of all great framework.

I was struggling with the settings-link in exopite-simple-options-framework.

  1. If i removed it from creating page i get an error Undefined array key "settings-link"
  2. When i enter the settings-link link admin.php?page=plugin-name it removes the question and = equal signs.
  3. Then i checked the exopite-simple-options-framework-class and see that the settings-link is escaped with sanitize_file_name $settings_link = sanitize_file_name( $this->config['settings-link'] ); this was causing the error so i removed the sanitize and works.

Is it safe to remove sanitize_file_name and can you advice how to improve it.
Thanks in advance

@JoeSz
Copy link
Owner

JoeSz commented Apr 10, 2023

I think, it is safe to remove. How your settings looks like?

@chaimiko
Copy link
Author

thanks for the quick reply, do you mean the code?
`function create_menu() {
$icon = '<style>.cls-1{fill:#ffd102;}</style>';
// Get the URL for the settings page

	$config_submenu = [
		'type'              => 'menu',
		'id'                => $this->plugin_name . '-options',
		'menu_title'		=> 'Gold Expert',
		'settings-link'		=> 'admin.php?page=gold-expert-options',
		'position'			=> 4,
		'plugin_basename'   => plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' ),
		'title'             => esc_html__( 'Gold Expert Settings', 'gold-expert' ),
		'capability'        => 'manage_options',
		'tabbed'            => false,
		'icon'				=> 'data:image/svg+xml;base64,' . base64_encode( $icon ),
	];

	$fields[] = [
		'name'   => 'ge_settings_section',
		'title'  => esc_html__( 'Setup', 'gold-expert' ),
		'icon'   => 'dashicons-portfolio',
		'fields' => [
			[
				'id'          => 'gold_expert_tabs',
				'type'        => 'tab',
				'options'     => [
					'equal_width' => true,
				],
				'tabs' => [
					[
						'id'     => 'gold_tab',
						'title'	 => esc_html__( 'Gold', 'gold-expert' ),
						'fields' => [
							[
								'id'         => 'shortcode_gold_table',
								'title'	     => esc_html__( 'Shortcode gold table', 'gold-expert' ),
								'type'       => 'textarea',
								'default'    => '[gold-expert-prices-table symbol="gc=f"]',
								'after'		 => '<span class="input-append"><i class="fa fa fa-clone copy-link-button" aria-hidden="true"></i></span>',
								'class'       => 'copy-link-input',
								'attributes' => [
									'rows'         => 1,
									   'cols'      => 50,
									'readonly' 	   => 'readonly',
								],
							],
							[
								'type'    => 'group',
								'id'      => 'gold_group',
								'options' => [
									'repeater'          => true,
									'accordion'         => false,
									'button_title'      => esc_html__( 'Add new', 'gold-expert' ),
									'group_title'       => esc_html__( 'Gold', 'gold-expert' ),
									'limit'             => 10,
									'sortable'          => true,
									'mode'              => 'compact',
								],									
								'fields'  => [
									[
										'id'         => 'karat',
										'title'	     => esc_html__( 'Karat', 'gold-expert' ),
										'type'       => 'text',
										'class'		 => 'purity-value',
										'attributes' => [
											'placeholder' => esc_html__( 'Set karat', 'gold-expert' ),
											'required'  =>  'required'
										],
									],
									[
										'id'         => 'purity',
										'title'	     => esc_html__( 'Purity', 'gold-expert' ),
										'type'       => 'text',
										'attributes' => [
											'placeholder' => esc_html__( 'Set Purity', 'gold-expert' ),
											'required'  =>  'required',
										],
									],
									[
										'id'         => 'price',
										'title'	     => esc_html__( 'Price', 'gold-expert' ),
										'type'       => 'text',
										'append'  	 => '%',
										'attributes' => [
											'placeholder' => esc_html__( 'Set Price', 'gold-expert' ),
											'required'  =>  'required'
										],
									],
									[
										'id'         => 'shortcode',
										'title'	     => esc_html__( 'Shortcode', 'gold-expert' ),
										'type'       => 'textarea',
										'append'     => 'fa-clone copy-link-button',
										'class'      => 'copy-link-input',
										'attributes' => [
											'rows'         => 1,
                   							'cols'         => 50,
											'data-my-data' => 'gold',
											'readonly' 	   => 'readonly',
										],
									],
								],
							],
						],
					],
					[
						'id'     => 'silver_tab',
						'title'	 => esc_html__( 'Siver' ),
						'fields' => [
							[
								'id'         => 'shortcode_silver_table',
								'title'	     => esc_html__( 'Shortcode Sivler table', 'gold-expert' ),
								'type'       => 'textarea',
								'default'    => '[gold-expert-prices-table symbol="si=f"]',
								'after'		 => '<span class="input-append"><i class="fa fa fa-clone copy-link-button" aria-hidden="true"></i></span>',
								'class'       => 'copy-link-input',
								'attributes' => [
									'rows'         => 1,
									'cols'         => 50,
									'readonly' 	   => 'readonly',
								],
							],
							[
								'type'    => 'group',
								'id'      => 'silver_group',
								'options' => [
									'repeater'          => true,
									'accordion'         => false,
									'button_title'      => esc_html__( 'Add new', 'gold-expert' ),
									'group_title'       => esc_html__( 'Silver', 'gold-expert' ),
									'limit'             => 10,
									'sortable'          => true,
									'mode'              => 'compact',
								],
								'fields'  => [
									[
										'id'         => 'purity',
										'title'	     => esc_html__( 'Purity', 'gold-expert' ),
										'type'       => 'text',
										'class'		 => 'purity-value',
										'attributes' => [
											'placeholder' => esc_html__( 'Set Purity', 'gold-expert' ),
											'required'  =>  'required'
										],
									],
									[
									'id'         => 'price',
									'title'	     => esc_html__( 'Price', 'gold-expert' ),
									'type'       => 'text',
									'append'  	 => '%',
									'attributes' => [
										'placeholder' => esc_html__( 'Set Price', 'gold-expert' ),
										'required'  =>  'required'
										],
									],
									[
										'id'         => 'shortcode',
										'title'	     => esc_html__( 'Shortcode', 'gold-expert' ),
										'type'       => 'textarea',
										'after'		 => '<span class="input-append"><i class="fa fa fa-clone copy-link-button" aria-hidden="true"></i></span>',
										'class'       => 'copy-link-input',
										'attributes' => [
											'rows'         => 1,
                   							'cols'         => 50,
											'data-my-data' => 'silver',
											'readonly' 	   => 'readonly',
										],
									],

								],
							],
						],
					],
					[
						'id'     => 'platinum_tab',
						'title'	 => esc_html__( 'Platinum' ),
						'fields' => [
							[
								'id'         => 'shortcode_platinum_table',
								'title'	     => esc_html__( 'Shortcode Platinum table', 'gold-expert' ),
								'type'       => 'textarea',
								'default'    => '[gold-expert-prices-table symbol="pl=f"]',
								'after'		 => '<span class="input-append"><i class="fa fa fa-clone copy-link-button" aria-hidden="true"></i></span>',
								'class'       => 'copy-link-input',
								'attributes' => [
									'rows'         => 1,
									'cols'         => 50,
									'readonly' 	   => 'readonly',
								],
							],
							[
								'type'    => 'group',
								'id'      => 'platinum_group',
								'options' => [
									'repeater'          => true,
									'accordion'         => false,
									'button_title'      => esc_html__( 'Add new', 'gold-expert' ),
									'group_title'       => esc_html__( 'Platinum', 'gold-expert' ),
									'limit'             => 10,
									'sortable'          => true,
									'mode'              => 'compact',
								],
								'fields'  => [
									[
										'id'         => 'purity',
										'title'	     => esc_html__( 'Purity', 'gold-expert' ),
										'type'       => 'text',
										'class'		 => 'purity-value',
										'attributes' => [
											'placeholder' => esc_html__( 'Set Purity', 'gold-expert' ),
											'required'  =>  'required'
										],
									],
									[
									'id'         => 'price',
									'title'	     => esc_html__( 'Price', 'gold-expert' ),
									'type'       => 'text',
									'append'  	 => '%',
									'attributes' => [
										'placeholder' => esc_html__( 'Set Price', 'gold-expert' ),
										'required'  =>  'required'
										],
									],
									[
										'id'         => 'shortcode',
										'title'	     => esc_html__( 'Shortcode', 'gold-expert' ),
										'type'       => 'textarea',
										'after'		 => '<span class="input-append"><i class="fa fa fa-clone copy-link-button" aria-hidden="true"></i></span>',
										'class'       => 'copy-link-input',
										'attributes' => [
											'rows'         => 1,
                   							'cols'         => 50,
											'data-my-data' => 'platinum',
											'readonly' 	   => 'readonly',
										],
									],

								],
							],
						],
					],
					[
						'id'     => 'palladium_tab',
						'title'	 => esc_html__( 'Palladium', 'gold-expert' ),
						'fields' => [
							[
								'id'         => 'shortcode_palladium_table',
								'title'	     => esc_html__( 'Shortcode Palladium table', 'gold-expert' ),
								'type'       => 'textarea',
								'default'    => '[gold-expert-prices-table symbol="pa=f"]',
								'after'		 => '<span class="input-append"><i class="fa fa fa-clone copy-link-button" aria-hidden="true"></i></span>',
								'class'       => 'copy-link-input',
								'attributes' => [
									'rows'         => 1,
									'cols'         => 50,
									'readonly' 	   => 'readonly',
								],
							],
							[
								'type'    => 'group',
								'id'      => 'palladium_group',
								'options' => [
									'repeater'          => true,
									'accordion'         => false,
									'button_title'      => esc_html__( 'Add new', 'gold-expert' ),
									'group_title'       => esc_html__( 'Palladium', 'gold-expert' ),
									'limit'             => 10,
									'sortable'          => true,
									'mode'              => 'compact',
								],
								'fields'  => [
									[
										'id'         => 'purity',
										'title'	     => esc_html__( 'Purity', 'gold-expert' ),
										'type'       => 'text',
										'class'		 => 'purity-value',
										'attributes' => [
											'placeholder' => esc_html__( 'Set Purity', 'gold-expert' ),
											'required'  =>  'required'
										],
									],
									[
									'id'         => 'price',
									'title'	     => esc_html__( 'Price', 'gold-expert' ),
									'type'       => 'text',
									'append'  	 => '%',
									'attributes' => [
										'placeholder' => esc_html__( 'Set Price', 'gold-expert' ),
										'required'  =>  'required'
										],
									],
									[
										'id'         => 'shortcode',
										'title'	     => esc_html__( 'Shortcode', 'gold-expert' ),
										'type'       => 'textarea',
										'after'		 => '<span class="input-append"><i class="fa fa fa-clone copy-link-button" aria-hidden="true"></i></span>',
										'class'       => 'copy-link-input',
										'attributes' => [
											'rows'         => 1,
                   							'cols'         => 50,
											'data-my-data' => 'palladium',
											'readonly' 	   => 'readonly',
										],
									],
								],
							],
						],
					],
				],
			 ],
		],
	];
	
	$menu_panel = new Exopite_Simple_Options_Framework( $config_submenu, $fields );
}`

@chaimiko
Copy link
Author

Also want to mention that i made a small tweak on textarea so i could preserve the shortcode that i'm creating dynamically because in the text field it was also removing all the = and " marks, if you like i can send you the plugin that i created it is nothing to fancy i needed it for my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants