| 1 |
<?php |
| 2 |
|
| 3 |
use Elementor\Controls_Manager; |
| 4 |
use Elementor\Group_Control_Typography; |
| 5 |
use Elementor\Widget_Base; |
| 6 |
|
| 7 |
if (!defined('ABSPATH')) { |
| 8 |
exit; // Exit if accessed directly |
| 9 |
} |
| 10 |
|
| 11 |
class BetterDocs_Elementor_Navigation extends Widget_Base { |
| 12 |
|
| 13 |
public function get_name () { |
| 14 |
return 'betterdocs-navigation'; |
| 15 |
} |
| 16 |
|
| 17 |
public function get_title () { |
| 18 |
return __('Doc Navigation', 'betterdocs'); |
| 19 |
} |
| 20 |
|
| 21 |
public function get_icon () { |
| 22 |
return 'betterdocs-icon-Navigation'; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_categories () { |
| 26 |
return ['betterdocs-elements']; |
| 27 |
} |
| 28 |
|
| 29 |
public function get_keywords () { |
| 30 |
return ['betterdocs-elements', 'navigation', 'betterdocs', 'docs']; |
| 31 |
} |
| 32 |
|
| 33 |
public function get_custom_help_url() { |
| 34 |
return 'https://betterdocs.co/docs/single-doc-in-elementor'; |
| 35 |
} |
| 36 |
|
| 37 |
protected function _register_controls () { |
| 38 |
|
| 39 |
$this->start_controls_section( |
| 40 |
'section_column_settings', |
| 41 |
[ |
| 42 |
'label' => __('Style', 'betterdocs'), |
| 43 |
'tab' => Controls_Manager::TAB_STYLE, |
| 44 |
] |
| 45 |
); |
| 46 |
|
| 47 |
$this->add_control( |
| 48 |
'navigation_text_color', |
| 49 |
[ |
| 50 |
'label' => esc_html__('Color', 'betterdocs'), |
| 51 |
'type' => Controls_Manager::COLOR, |
| 52 |
'selectors' => [ |
| 53 |
'{{WRAPPER}} .docs-navigation a' => 'color: {{VALUE}};', |
| 54 |
] |
| 55 |
] |
| 56 |
); |
| 57 |
|
| 58 |
$this->add_group_control( |
| 59 |
Group_Control_Typography::get_type(), |
| 60 |
[ |
| 61 |
'name' => 'navigation_text_typography', |
| 62 |
'selector' => '{{WRAPPER}} .docs-navigation a' |
| 63 |
] |
| 64 |
); |
| 65 |
|
| 66 |
$this->add_control( |
| 67 |
'navigation_arrow_size', |
| 68 |
[ |
| 69 |
'label' => __('Size', 'betterdocs'), |
| 70 |
'type' => Controls_Manager::SLIDER, |
| 71 |
'default' => [ |
| 72 |
'unit' => 'px', |
| 73 |
'size' => 35, |
| 74 |
], |
| 75 |
'size_units' => ['px'], |
| 76 |
'range' => [ |
| 77 |
'px' => [ |
| 78 |
'max' => 500, |
| 79 |
'step' => 1, |
| 80 |
], |
| 81 |
], |
| 82 |
'selectors' => [ |
| 83 |
'{{WRAPPER}} .docs-navigation svg' => 'width: {{SIZE}}px;height: {{SIZE}}px;', |
| 84 |
], |
| 85 |
] |
| 86 |
); |
| 87 |
|
| 88 |
$this->add_control( |
| 89 |
'navigation_arrow_color', |
| 90 |
[ |
| 91 |
'label' => esc_html__('Arrow Color', 'betterdocs'), |
| 92 |
'type' => Controls_Manager::COLOR, |
| 93 |
'selectors' => [ |
| 94 |
'{{WRAPPER}} .docs-navigation svg' => 'fill: {{VALUE}};', |
| 95 |
] |
| 96 |
] |
| 97 |
); |
| 98 |
|
| 99 |
$this->end_controls_section(); |
| 100 |
} |
| 101 |
|
| 102 |
protected function render () { |
| 103 |
$enable_navigation = BetterDocs_DB::get_settings('enable_navigation'); |
| 104 |
if ($enable_navigation == 1) { |
| 105 |
echo '<div class="docs-navigation betterdocs-el-single-navigation">'; |
| 106 |
$nav = get_previous_post_link( '%link', '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="42px" viewBox="0 0 50 50" version="1.1"><g id="surface1"><path style=" " d="M 11.957031 13.988281 C 11.699219 14.003906 11.457031 14.117188 11.28125 14.308594 L 1.015625 25 L 11.28125 35.691406 C 11.527344 35.953125 11.894531 36.0625 12.242188 35.976563 C 12.589844 35.890625 12.867188 35.625 12.964844 35.28125 C 13.066406 34.933594 12.972656 34.5625 12.71875 34.308594 L 4.746094 26 L 48 26 C 48.359375 26.003906 48.695313 25.816406 48.878906 25.503906 C 49.058594 25.191406 49.058594 24.808594 48.878906 24.496094 C 48.695313 24.183594 48.359375 23.996094 48 24 L 4.746094 24 L 12.71875 15.691406 C 13.011719 15.398438 13.09375 14.957031 12.921875 14.582031 C 12.753906 14.203125 12.371094 13.96875 11.957031 13.988281 Z "></path></g></svg> %title', TRUE, ' ', 'doc_category' ); |
| 107 |
$nav .= get_next_post_link( '%link', '%title <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="42px" viewBox="0 0 50 50" version="1.1"><g id="surface1"><path style=" " d="M 38.035156 13.988281 C 37.628906 13.980469 37.257813 14.222656 37.09375 14.59375 C 36.933594 14.96875 37.015625 15.402344 37.300781 15.691406 L 45.277344 24 L 2.023438 24 C 1.664063 23.996094 1.328125 24.183594 1.148438 24.496094 C 0.964844 24.808594 0.964844 25.191406 1.148438 25.503906 C 1.328125 25.816406 1.664063 26.003906 2.023438 26 L 45.277344 26 L 37.300781 34.308594 C 36.917969 34.707031 36.933594 35.339844 37.332031 35.722656 C 37.730469 36.105469 38.363281 36.09375 38.746094 35.691406 L 49.011719 25 L 38.746094 14.308594 C 38.5625 14.109375 38.304688 13.996094 38.035156 13.988281 Z "></path></g></svg>', TRUE, ' ', 'doc_category' ); |
| 108 |
echo apply_filters( 'betterdocs_single_post_nav', $nav ); |
| 109 |
echo '</div>'; |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
|