| 1 |
<?php |
| 2 |
/** |
| 3 |
* Editor class. |
| 4 |
* This class is responsible for editor UI. |
| 5 |
* |
| 6 |
* @version 4.0.0 |
| 7 |
* @author Expresstech System |
| 8 |
* |
| 9 |
* @package responsive-menu |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace RMP\Features\Inc; |
| 13 |
|
| 14 |
use RMP\Features\Inc\Traits\Singleton; |
| 15 |
|
| 16 |
// Disable the direct access to this class. |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Class Editor |
| 23 |
*/ |
| 24 |
class Editor { |
| 25 |
|
| 26 |
use Singleton; |
| 27 |
|
| 28 |
/** |
| 29 |
* Construct method. |
| 30 |
*/ |
| 31 |
protected function __construct() { |
| 32 |
$this->setup_hooks(); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* To setup action/filter. |
| 37 |
* |
| 38 |
* @version 4.0.0 |
| 39 |
* |
| 40 |
* @return void |
| 41 |
*/ |
| 42 |
protected function setup_hooks() { |
| 43 |
add_action( 'admin_head', array( $this, 'render_menu_editor_page' ) ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Function to load the menu editor page when click on particular menu |
| 48 |
* customize option from menu list. |
| 49 |
* |
| 50 |
* @version 4.0.0 |
| 51 |
* |
| 52 |
* @return void |
| 53 |
*/ |
| 54 |
public function render_menu_editor_page() { |
| 55 |
$editor = filter_input( INPUT_GET, 'editor', FILTER_SANITIZE_URL ); |
| 56 |
if ( ! empty( $editor ) && 'rmp_menu' === get_post_type() && current_user_can( 'administrator' ) ) { |
| 57 |
set_current_screen(); |
| 58 |
include RMP_PLUGIN_PATH_V4 . '/templates/rmp-editor.php'; |
| 59 |
exit; |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Add hooter section in editor. |
| 65 |
* |
| 66 |
* @version 4.0.0 |
| 67 |
* |
| 68 |
* @param HTML. |
| 69 |
*/ |
| 70 |
public function header_section( $menu_name ) { |
| 71 |
?> |
| 72 |
<div id="rmp-editor-header" class="rmp-editor-header"> |
| 73 |
<!-- Plugin logo on editor header--> |
| 74 |
<div class="rmp-editor-header-logo"> |
| 75 |
<span class="dashicons dashicons-arrow-left-alt rmp-editor-header-back"></span> |
| 76 |
<img alt="logo" src="<?php echo esc_url( RMP_PLUGIN_URL_V4 . '/assets/images/rmp-logo.png' ); ?>" /> |
| 77 |
</div> |
| 78 |
<!-- Menu title on editor header--> |
| 79 |
<div class="rmp-editor-header-title"><?php echo esc_html( $menu_name ); ?></div> |
| 80 |
<input class="rmp-search-settings no-updates" type="search" placeholder="Search Settings.." /> |
| 81 |
<div class="rmp-search-settings-block"> |
| 82 |
<label class="rmp-search-settings-btn"><i class="fa fa-search"></i></label> |
| 83 |
<!-- Exit from editor button in header--> |
| 84 |
<a class="rmp-editor-header-close" href="<?php echo esc_url( admin_url() . '/edit.php?post_type=rmp_menu' ); ?>"> |
| 85 |
<span class="fas fa-times"></span> |
| 86 |
<span class="screen-reader-text"> |
| 87 |
<?php esc_html_e( 'Close the editor and go back to the previous page', 'responsive-menu' ); ?> |
| 88 |
</span> |
| 89 |
</a> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
<?php |
| 93 |
|
| 94 |
/** |
| 95 |
* Filters the editor header. |
| 96 |
* |
| 97 |
* @param string|HTML $html |
| 98 |
*/ |
| 99 |
echo apply_filters( 'rmp_editor_header_html', '' ); |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Add Footer section in editor. |
| 104 |
* |
| 105 |
* @param HTML. |
| 106 |
*/ |
| 107 |
public function footer_section() { |
| 108 |
global $wp_filesystem; |
| 109 |
if ( empty( $wp_filesystem ) ) { |
| 110 |
require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 111 |
} |
| 112 |
WP_Filesystem(); |
| 113 |
?> |
| 114 |
<div id="rmp-editor-footer" class="rmp-editor-footer"> |
| 115 |
|
| 116 |
<!-- Update the settings button in footer--> |
| 117 |
<button type="button" class="menu-save" id="rmp-save-menu-options"> |
| 118 |
<?php esc_html_e( 'Update', 'responsive-menu' ); ?> |
| 119 |
</button> |
| 120 |
|
| 121 |
<!-- Themes options when click on up arrow button in footer--> |
| 122 |
<button type="button" class="rmp-theme-settings" id="rmp-theme-action" > |
| 123 |
<span class="dashicons dashicons-arrow-up "></span> |
| 124 |
</button> |
| 125 |
|
| 126 |
<div class="rmp-footer-sub-menu-wrapper" id="rmp-footer-theme-options"> |
| 127 |
<ul class="rmp-footer-sub-menu"> |
| 128 |
<li> |
| 129 |
<a id="rmp-theme-save-button" class="rmp-theme-save-button"> |
| 130 |
<span class="fas fa-save"></span> |
| 131 |
<span> <?php esc_html_e( 'Save as theme', 'responsive-menu' ); ?></span> |
| 132 |
</a> |
| 133 |
</li> |
| 134 |
|
| 135 |
<li> |
| 136 |
<a id="rmp-theme-change-button" class="rmp-theme-change-button" > |
| 137 |
<span class="fas fa-folder-open "></span> |
| 138 |
<span><?php esc_html_e( 'Change theme', 'responsive-menu' ); ?></span> |
| 139 |
</a> |
| 140 |
</li> |
| 141 |
</ul> |
| 142 |
</div> |
| 143 |
|
| 144 |
<!-- Device options in footer--> |
| 145 |
<div class="rmp-preview-device-wrapper"> |
| 146 |
|
| 147 |
<button type="button" id="rmp-preview-mobile" class=" rmp-device-preview rmp-preview-mobile active" aria-pressed="1" data-device="mobile"> |
| 148 |
<?php |
| 149 |
$svg_mobile = $wp_filesystem->get_contents( RMP_PLUGIN_PATH_V4 . '/assets/admin/icons/svg/mobile.svg' ); |
| 150 |
if ( $svg_mobile ) { |
| 151 |
echo wp_kses( $svg_mobile, rmp_allow_svg_html_tags() ); |
| 152 |
} |
| 153 |
?> |
| 154 |
<span class="screen-reader-text"> |
| 155 |
<?php esc_html_e( 'Enter mobile preview mode', 'responsive-menu' ); ?> |
| 156 |
</span> |
| 157 |
</button> |
| 158 |
|
| 159 |
<button type="button" id="rmp-preview-tablet" class="rmp-preview-tablet rmp-device-preview" aria-pressed="" data-device="tablet"> |
| 160 |
<?php |
| 161 |
$svg_tablet = $wp_filesystem->get_contents( RMP_PLUGIN_PATH_V4 . '/assets/admin/icons/svg/tablet.svg' ); |
| 162 |
if ( $svg_tablet ) { |
| 163 |
echo wp_kses( $svg_tablet, rmp_allow_svg_html_tags() ); |
| 164 |
} |
| 165 |
?> |
| 166 |
<span class="screen-reader-text"> |
| 167 |
<?php esc_html_e( 'Enter tablet preview mode', 'responsive-menu' ); ?> |
| 168 |
</span> |
| 169 |
</button> |
| 170 |
|
| 171 |
<button type="button" id="rmp-preview-desktop" class="rmp-preview-desktop rmp-device-preview" aria-pressed="" data-device="desktop"> |
| 172 |
<?php |
| 173 |
$svg_desktop = $wp_filesystem->get_contents( RMP_PLUGIN_PATH_V4 . '/assets/admin/icons/svg/desktop.svg' ); |
| 174 |
if ( $svg_desktop ) { |
| 175 |
echo wp_kses( $svg_desktop, rmp_allow_svg_html_tags() ); |
| 176 |
} |
| 177 |
?> |
| 178 |
<span class="screen-reader-text"> |
| 179 |
<?php esc_html_e( 'Enter desktop preview mode', 'responsive-menu' ); ?> |
| 180 |
</span> |
| 181 |
</button> |
| 182 |
|
| 183 |
</div> |
| 184 |
|
| 185 |
</div> |
| 186 |
<?php |
| 187 |
|
| 188 |
/** |
| 189 |
* Filters the editor footer html. |
| 190 |
* |
| 191 |
* @param string|HTML $html |
| 192 |
*/ |
| 193 |
echo apply_filters( 'rmp_editor_footer_html', '' ); |
| 194 |
} |
| 195 |
|
| 196 |
/** |
| 197 |
* Function to return the markups for sidebar drawers. |
| 198 |
* |
| 199 |
* @return HTML|string |
| 200 |
*/ |
| 201 |
public function sidebar_drawer() { |
| 202 |
?> |
| 203 |
<button type="button" class="collapse-sidebar" aria-expanded="true" aria-label="Hide Controls"> |
| 204 |
<span class="collapse-sidebar-arrow"></span> |
| 205 |
</button> |
| 206 |
<?php |
| 207 |
} |
| 208 |
} |
| 209 |
|