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

Request : Make the possibility to put the toggle logo that opens the toolbar in the menu #97

Open
Lxow opened this issue Oct 9, 2023 · 0 comments

Comments

@Lxow
Copy link

Lxow commented Oct 9, 2023

I would love the possibility for the user to choose the options menu-left or menu-right that changes the positions of the toggle that oppens the toolbar and add it directly in the WP menu

For example you can add 2 new positions in the accessibility section of wordpress (appareance/customize/accessibilty (menu-left and menu-right)
I tried to code but only did that im stuck and i was wondering if you have any idea of how to continue ?

File : pojo-a11y-customizer.php

class Pojo_A11y_Customizer {
	private $css_rules = array();
	private $css_code = '';

	public function get_customizer_fields() {
		$fields = array();

		$fields[] = array(
			'id' => 'a11y_toolbar_icon',
			'title' => __( 'Toolbar Icon', 'pojo-accessibility' ),
			'type' => 'select',
			'choices' => array(
				'one-click' => __( 'One Click', 'pojo-accessibility' ),
				'wheelchair' => __( 'Wheelchair', 'pojo-accessibility' ),
				'accessibility' => __( 'Accessibility', 'pojo-accessibility' ),
			),
			'std' => 'one-click',
			'description' => __( 'Set Toolbar Icon', 'pojo-accessibility' ),
		);

		$fields[] = array(
			'id' => 'a11y_toolbar_position',
			'title' => __( 'Toolbar Position', 'pojo-accessibility' ),
			'type' => 'select',
			'choices' => array(
				'left' => __( 'Left', 'pojo-accessibility' ),
				'right' => __( 'Right', 'pojo-accessibility' ),
				'menu-left' => __( 'Menu Left', 'pojo-accessibility' ), //New option to add toolbar in the menu to the left
				'menu-right' => __( 'Menu Right', 'pojo-accessibility' ), // Same but for the right
			),
			'std' => is_rtl() ? 'right' : 'left',
			'description' => __( 'Set Toolbar Position', 'pojo-accessibility' ),
		);
// The rest of the code 

The file : pojo-a11y-frontend.php

public function print_toolbar()
	{
		if (!$this->is_toolbar_active()) {
			return;
		}

		$customizer_options = get_option(POJO_A11Y_CUSTOMIZER_OPTIONS);

		$toolbar_position = $customizer_options['a11y_toolbar_position'];
		if (empty($toolbar_position) || !in_array($toolbar_position, array('right', 'left', 'menu-left', 'menu-right'))) {
		  $toolbar_position = 'left';
		}

		$toolbar_title = Pojo_Accessibility::$instance->settings->get_default_title_text('pojo_a11y_toolbar_title');
		$toolbar_visibility = get_option('pojo_a11y_toolbar');

		$wrapper_classes = array(
			'pojo-a11y-toolbar-' . $toolbar_position,
		);

		if ('enable' !== $toolbar_visibility) {
			$wrapper_classes[] = 'pojo-a11y-' . $toolbar_visibility;
		}
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

1 participant