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