| @@ -1,11 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc\Modules\MenuEditor; | |
| 3 | +namespace WPAdminify\Inc\Modules\MenuEditor; | |
| 4 | 4 | |
| 5 | -use PXLBSAdminify\Inc\Utils; | |
| 6 | -use PXLBSAdminify\Inc\Admin\AdminSettings; | |
| 7 | -use PXLBSAdminify\Inc\Modules\MenuEditor\MenuEditorAssets; | |
| 5 | +use WPAdminify\Inc\Utils; | |
| 6 | +use WPAdminify\Inc\Admin\AdminSettings; | |
| 7 | +use WPAdminify\Inc\Modules\MenuEditor\MenuEditorAssets; | |
| 8 | +use WPAdminify\Inc\Admin\AdminSettingsModel; | |
| 8 | 9 | use enshrined\svgSanitize\Sanitizer; |
| 9 | 10 | // no direct access allowed |
| 10 | 11 | if ( !defined( 'ABSPATH' ) ) { |
| 11 | 12 | exit; |
| @@ -46,23 +47,23 @@ | ||
| 46 | 47 | $this->menu_settings = ( new MenuEditorOptions() )->get(); |
| 47 | 48 | $this->options = (array) AdminSettings::get_instance()->get(); |
| 48 | 49 | add_filter( 'upload_mimes', [$this, 'custom_icon_mime_types'] ); |
| 49 | 50 | add_filter( 'wp_handle_upload_prefilter', [$this, 'sanitize_svg_file'] ); |
| 50 | - add_filter( 'admin_body_class', [$this, 'menu_editor_body_class'] ); | |
| 51 | + add_filter( 'admin_body_class', [$this, 'jltwp_adminify_menu_editor_body_class'] ); | |
| 51 | 52 | // add_filter('parent_file', [$this, 'set_menu'], 800); |
| 52 | 53 | // add_filter('parent_file', [$this, 'apply_menu'], 900); |
| 53 | - // add_action('modules_menu_editor_render', [$this, 'modules_menu_editor_render']); | |
| 54 | - if ( apply_filters( 'pxlbsadminify_enable_menu_editor_render', true ) ) { | |
| 54 | + // add_action('jltwp_adminify_modules_menu_editor_render', [$this, 'jltwp_adminify_modules_menu_editor_render']); | |
| 55 | + if ( apply_filters( 'enable_jltwp_adminify_menu_editor_render', true ) ) { | |
| 55 | 56 | add_filter( 'parent_file', [$this, 'set_menu'], 800 ); |
| 56 | 57 | add_filter( 'parent_file', [$this, 'apply_menu'], 900 ); |
| 57 | 58 | } |
| 58 | - add_action( 'wp_ajax_pxlbsadminify_save_menu_settings', [$this, 'save_menu_settings'] ); | |
| 59 | - add_action( 'wp_ajax_pxlbsadminify_reset_menu_settings', [$this, 'reset_menu_settings'] ); | |
| 60 | - add_action( 'wp_ajax_pxlbsadminify_export_menu_settings', [$this, 'export_menu_settings'] ); | |
| 61 | - add_action( 'wp_ajax_pxlbsadminify_import_menu_settings', [$this, 'import_menu_settings'] ); | |
| 62 | - add_action( 'wp_ajax_pxlbsadminify_file_upload', [$this, 'file_upload_callback'] ); | |
| 63 | - add_action( 'wp_ajax_pxlbsadminify_load_custom_icons', [$this, 'load_custom_icons_callback'] ); | |
| 64 | - add_action( 'wp_ajax_pxlbsadminify_search_users', [$this, 'search_users_callback'] ); | |
| 59 | + add_action( 'wp_ajax_adminify_save_menu_settings', [$this, 'adminify_save_menu_settings'] ); | |
| 60 | + add_action( 'wp_ajax_adminify_reset_menu_settings', [$this, 'adminify_reset_menu_settings'] ); | |
| 61 | + add_action( 'wp_ajax_adminify_export_menu_settings', [$this, 'adminify_export_menu_settings'] ); | |
| 62 | + add_action( 'wp_ajax_adminify_import_menu_settings', [$this, 'adminify_import_menu_settings'] ); | |
| 63 | + add_action( 'wp_ajax_adminify_file_upload', [$this, 'adminify_file_upload_callback'] ); | |
| 64 | + add_action( 'wp_ajax_adminify_load_custom_icons', [$this, 'adminify_load_custom_icons_callback'] ); | |
| 65 | + add_action( 'wp_ajax_adminify_search_users', [$this, 'adminify_search_users_callback'] ); | |
| 65 | 66 | new MenuEditorAssets(); |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | 69 | public function custom_icon_mime_types( $mimes ) { |
| @@ -102,11 +103,11 @@ | ||
| 102 | 103 | // return $value->post_title == 'adminify-custom-icon'; |
| 103 | 104 | return strpos( $value->guid, 'adminify-custom-icon' ) !== false; |
| 104 | 105 | } |
| 105 | 106 | |
| 106 | - public function load_custom_icons_callback() { | |
| 107 | + public function adminify_load_custom_icons_callback() { | |
| 107 | 108 | // Security check - verify nonce and capability |
| 108 | - check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ); | |
| 109 | + check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ); | |
| 109 | 110 | if ( !current_user_can( 'manage_options' ) ) { |
| 110 | 111 | wp_send_json_error( array( |
| 111 | 112 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| 112 | 113 | ) ); |
| @@ -123,11 +124,11 @@ | ||
| 123 | 124 | echo wp_json_encode( $result ); |
| 124 | 125 | die; |
| 125 | 126 | } |
| 126 | 127 | |
| 127 | - public function file_upload_callback() { | |
| 128 | + public function adminify_file_upload_callback() { | |
| 128 | 129 | $result['status'] = false; |
| 129 | - check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ); | |
| 130 | + check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ); | |
| 130 | 131 | if ( !current_user_can( 'manage_options' ) ) { |
| 131 | 132 | wp_send_json_error( array( |
| 132 | 133 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| 133 | 134 | ) ); |
| @@ -136,15 +137,9 @@ | ||
| 136 | 137 | $targeted_dir = $upload_dir['basedir'] . '/adminify-custom-icons'; |
| 137 | 138 | if ( !is_dir( $targeted_dir ) ) { |
| 138 | 139 | wp_mkdir_p( $targeted_dir ); |
| 139 | 140 | } |
| 140 | - add_filter( 'upload_dir', [$this, 'icon_custom_upload_dir'] ); | |
| 141 | - if ( !isset( $_FILES['my_file_upload'] ) ) { | |
| 142 | - wp_send_json_error( array( | |
| 143 | - 'message' => __( 'No file was uploaded.', 'adminify' ), | |
| 144 | - ) ); | |
| 145 | - } | |
| 146 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- $_FILES is sanitized by the WP upload handler. | |
| 141 | + add_filter( 'upload_dir', [$this, 'adminify_icon_custom_upload_dir'] ); | |
| 147 | 142 | $files = wp_kses_post_deep( wp_unslash( $_FILES['my_file_upload'] ) ); |
| 148 | 143 | foreach ( $files['name'] as $key => $value ) { |
| 149 | 144 | if ( $files['name'][$key] ) { |
| 150 | 145 | $file = [ |
| @@ -169,14 +164,14 @@ | ||
| 169 | 164 | $result['images'][$attachment_id] = wp_get_attachment_url( $attachment_id ); |
| 170 | 165 | } |
| 171 | 166 | } |
| 172 | 167 | } |
| 173 | - remove_filter( 'upload_dir', [$this, 'icon_custom_upload_dir'] ); | |
| 168 | + remove_filter( 'upload_dir', [$this, 'adminify_icon_custom_upload_dir'] ); | |
| 174 | 169 | echo wp_json_encode( $result ); |
| 175 | 170 | wp_die(); |
| 176 | 171 | } |
| 177 | 172 | |
| 178 | - public function icon_custom_upload_dir( $dir_data ) { | |
| 173 | + public function adminify_icon_custom_upload_dir( $dir_data ) { | |
| 179 | 174 | // $dir_data already you might want to use |
| 180 | 175 | $custom_dir = 'adminify-custom-icons'; |
| 181 | 176 | return [ |
| 182 | 177 | 'path' => $dir_data['basedir'] . '/' . $custom_dir, |
| @@ -191,10 +186,10 @@ | ||
| 191 | 186 | /** |
| 192 | 187 | * AJAX callback to search users for Select2 |
| 193 | 188 | * Uses 'fields' parameter for optimized database query performance |
| 194 | 189 | */ |
| 195 | - public function search_users_callback() { | |
| 196 | - check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ); | |
| 190 | + public function adminify_search_users_callback() { | |
| 191 | + check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ); | |
| 197 | 192 | if ( !current_user_can( 'manage_options' ) ) { |
| 198 | 193 | wp_send_json_error( array( |
| 199 | 194 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| 200 | 195 | ) ); |
| @@ -253,9 +248,9 @@ | ||
| 253 | 248 | ) ); |
| 254 | 249 | } |
| 255 | 250 | |
| 256 | 251 | // Menu Editor Body Class |
| 257 | - public function menu_editor_body_class( $classes ) { | |
| 252 | + public function jltwp_adminify_menu_editor_body_class( $classes ) { | |
| 258 | 253 | $classes .= ' adminify_menu_editor '; |
| 259 | 254 | return $classes; |
| 260 | 255 | } |
| 261 | 256 | |
| @@ -270,13 +265,13 @@ | ||
| 270 | 265 | foreach ( $values as $index => $in ) { |
| 271 | 266 | if ( is_array( $in ) ) { |
| 272 | 267 | $values[$index] = $this->clean_ajax_input( $in ); |
| 273 | 268 | } else { |
| 274 | - $values[$index] = wp_strip_all_tags( $in ); | |
| 269 | + $values[$index] = strip_tags( $in ); | |
| 275 | 270 | } |
| 276 | 271 | } |
| 277 | 272 | } else { |
| 278 | - $values = wp_strip_all_tags( $values ); | |
| 273 | + $values = strip_tags( $values ); | |
| 279 | 274 | } |
| 280 | 275 | return $values; |
| 281 | 276 | } |
| 282 | 277 | |
| @@ -289,25 +284,23 @@ | ||
| 289 | 284 | public function ajax_error_message( $message ) { |
| 290 | 285 | $returndata = []; |
| 291 | 286 | $returndata['error'] = true; |
| 292 | 287 | $returndata['error_message'] = $message; |
| 293 | - return wp_json_encode( $returndata ); | |
| 288 | + return json_encode( $returndata ); | |
| 294 | 289 | } |
| 295 | 290 | |
| 296 | - public function save_menu_settings() { | |
| 297 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ) > 0 ) { | |
| 291 | + public function adminify_save_menu_settings() { | |
| 292 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ) > 0 ) { | |
| 298 | 293 | if ( !current_user_can( 'manage_options' ) ) { |
| 299 | 294 | wp_send_json_error( array( |
| 300 | 295 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| 301 | 296 | ) ); |
| 302 | 297 | } |
| 303 | - $options = ( isset( $_POST['options'] ) ? wp_kses_post_deep( wp_unslash( $_POST['options'] ) ) : '' ); | |
| 304 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized via wp_kses_post_deep() and clean_ajax_input() below. | |
| 298 | + $options = wp_kses_post_deep( wp_unslash( $_POST['options'] ) ); | |
| 305 | 299 | $options = $this->clean_ajax_input( $options ); |
| 306 | 300 | if ( $options == '' || !is_array( $options ) ) { |
| 307 | 301 | $message = __( 'No options supplied to save', 'adminify' ); |
| 308 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped. | |
| 309 | - echo Utils::kses_custom( $this->ajax_error_message( $message ) ); | |
| 302 | + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) ); | |
| 310 | 303 | die; |
| 311 | 304 | } |
| 312 | 305 | if ( is_array( $options ) ) { |
| 313 | 306 | update_option( $this->prefix, $options ); |
| @@ -313,14 +306,13 @@ | ||
| 313 | 306 | update_option( $this->prefix, $options ); |
| 314 | 307 | $returndata = []; |
| 315 | 308 | $returndata['success'] = true; |
| 316 | 309 | $returndata['message'] = __( 'Settings saved', 'adminify' ); |
| 317 | - echo wp_json_encode( $returndata ); | |
| 310 | + echo json_encode( $returndata ); | |
| 318 | 311 | die; |
| 319 | 312 | } else { |
| 320 | 313 | $message = __( 'Something went wrong', 'adminify' ); |
| 321 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped. | |
| 322 | - echo Utils::kses_custom( $this->ajax_error_message( $message ) ); | |
| 314 | + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) ); | |
| 323 | 315 | die; |
| 324 | 316 | } |
| 325 | 317 | } |
| 326 | 318 | die; |
| @@ -330,10 +322,10 @@ | ||
| 330 | 322 | * Menu Editor Settings Reset |
| 331 | 323 | * |
| 332 | 324 | * @return void |
| 333 | 325 | */ |
| 334 | - public function reset_menu_settings() { | |
| 335 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ) > 0 ) { | |
| 326 | + public function adminify_reset_menu_settings() { | |
| 327 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ) > 0 ) { | |
| 336 | 328 | if ( !current_user_can( 'manage_options' ) ) { |
| 337 | 329 | wp_send_json_error( array( |
| 338 | 330 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| 339 | 331 | ) ); |
| @@ -343,14 +335,13 @@ | ||
| 343 | 335 | if ( !$menu_editor_options ) { |
| 344 | 336 | $returndata = []; |
| 345 | 337 | $returndata['success'] = true; |
| 346 | 338 | $returndata['message'] = __( 'Settings reset', 'adminify' ); |
| 347 | - echo wp_json_encode( $returndata ); | |
| 339 | + echo json_encode( $returndata ); | |
| 348 | 340 | die; |
| 349 | 341 | } else { |
| 350 | 342 | $message = __( 'Something went wrong', 'adminify' ); |
| 351 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped. | |
| 352 | - echo Utils::kses_custom( $this->ajax_error_message( $message ) ); | |
| 343 | + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) ); | |
| 353 | 344 | die; |
| 354 | 345 | } |
| 355 | 346 | } |
| 356 | 347 | die; |
| @@ -360,10 +351,10 @@ | ||
| 360 | 351 | * Export Menu Editor Settings |
| 361 | 352 | * |
| 362 | 353 | * @return void |
| 363 | 354 | */ |
| 364 | - public function export_menu_settings() { | |
| 365 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ) > 0 ) { | |
| 355 | + public function adminify_export_menu_settings() { | |
| 356 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ) > 0 ) { | |
| 366 | 357 | if ( !current_user_can( 'manage_options' ) ) { |
| 367 | 358 | wp_send_json_error( array( |
| 368 | 359 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| 369 | 360 | ) ); |
| @@ -368,9 +359,9 @@ | ||
| 368 | 359 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| 369 | 360 | ) ); |
| 370 | 361 | } |
| 371 | 362 | $menu_editor_options = get_option( $this->prefix ); |
| 372 | - echo wp_json_encode( $menu_editor_options ); | |
| 363 | + echo json_encode( $menu_editor_options ); | |
| 373 | 364 | } |
| 374 | 365 | die; |
| 375 | 366 | } |
| 376 | 367 | |
| @@ -378,21 +369,19 @@ | ||
| 378 | 369 | * Import Menu Editor Settings |
| 379 | 370 | * |
| 380 | 371 | * @since 1.0.0 |
| 381 | 372 | */ |
| 382 | - public function import_menu_settings() { | |
| 383 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'pxlbsadminify-menu-editor-security-nonce', 'security' ) > 0 ) { | |
| 373 | + public function adminify_import_menu_settings() { | |
| 374 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-menu-editor-security-nonce', 'security' ) > 0 ) { | |
| 384 | 375 | if ( !current_user_can( 'manage_options' ) ) { |
| 385 | 376 | wp_send_json_error( array( |
| 386 | 377 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| 387 | 378 | ) ); |
| 388 | 379 | } |
| 389 | - $new_options = ( isset( $_POST['settings'] ) ? wp_kses_post_deep( wp_unslash( $_POST['settings'] ) ) : '' ); | |
| 390 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized via wp_kses_post_deep(). | |
| 380 | + $new_options = wp_kses_post_deep( $_POST['settings'] ); | |
| 391 | 381 | if ( $new_options == '' || !is_array( $new_options ) ) { |
| 392 | 382 | $message = __( 'No options supplied to save', 'adminify' ); |
| 393 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped. | |
| 394 | - echo Utils::kses_custom( $this->ajax_error_message( $message ) ); | |
| 383 | + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) ); | |
| 395 | 384 | die; |
| 396 | 385 | } |
| 397 | 386 | if ( is_array( $new_options ) ) { |
| 398 | 387 | update_option( $this->prefix, $new_options ); |
| @@ -398,14 +387,13 @@ | ||
| 398 | 387 | update_option( $this->prefix, $new_options ); |
| 399 | 388 | $returndata = []; |
| 400 | 389 | $returndata['success'] = true; |
| 401 | 390 | $returndata['message'] = __( 'Menu Imported', 'adminify' ); |
| 402 | - echo wp_json_encode( $returndata ); | |
| 391 | + echo json_encode( $returndata ); | |
| 403 | 392 | die; |
| 404 | 393 | } else { |
| 405 | 394 | $message = __( 'Something went wrong', 'adminify' ); |
| 406 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped. | |
| 407 | - echo Utils::kses_custom( $this->ajax_error_message( $message ) ); | |
| 395 | + echo Utils::wp_kses_custom( $this->ajax_error_message( $message ) ); | |
| 408 | 396 | die; |
| 409 | 397 | } |
| 410 | 398 | } |
| 411 | 399 | die; |
| @@ -411,37 +399,8 @@ | ||
| 411 | 399 | die; |
| 412 | 400 | } |
| 413 | 401 | |
| 414 | 402 | /** |
| 415 | - * Find menu settings for a given slug. | |
| 416 | - * Some plugins (e.g. Yoast SEO) register different top-level menu slugs | |
| 417 | - * depending on user capabilities. The admin sees slug 'wpseo_dashboard' | |
| 418 | - * but the editor sees 'wpseo_tools'. This method handles that mismatch | |
| 419 | - * by falling back to checking if the slug appears as a submenu key. | |
| 420 | - * | |
| 421 | - * @param string $slug The menu slug to look up. | |
| 422 | - * @return array|null The matching settings array, or null if not found. | |
| 423 | - */ | |
| 424 | - public function find_menu_settings_by_slug( $slug ) { | |
| 425 | - // Direct match | |
| 426 | - if ( isset( $this->menu_settings[$slug] ) ) { | |
| 427 | - return $this->menu_settings[$slug]; | |
| 428 | - } | |
| 429 | - // Fallback: check if this slug is a submenu of any saved parent menu | |
| 430 | - if ( is_array( $this->menu_settings ) ) { | |
| 431 | - foreach ( $this->menu_settings as $parent_slug => $parent_settings ) { | |
| 432 | - if ( !is_array( $parent_settings ) || !isset( $parent_settings['submenu'] ) || !is_array( $parent_settings['submenu'] ) ) { | |
| 433 | - continue; | |
| 434 | - } | |
| 435 | - if ( isset( $parent_settings['submenu'][$slug] ) ) { | |
| 436 | - return $parent_settings; | |
| 437 | - } | |
| 438 | - } | |
| 439 | - } | |
| 440 | - return null; | |
| 441 | - } | |
| 442 | - | |
| 443 | - /** | |
| 444 | 403 | * Get menu items |
| 445 | 404 | * |
| 446 | 405 | * @param [type] $parent_file |
| 447 | 406 | * |
| @@ -479,18 +438,10 @@ | ||
| 479 | 438 | if ( !empty( $next_menu_item ) && strpos( $next_menu_item[2], 'separator' ) !== false ) { |
| 480 | 439 | $separator = 1; |
| 481 | 440 | } |
| 482 | 441 | if ( is_array( $menu_settings ) ) { |
| 483 | - // Direct slug match first, then fallback for dynamic-slug plugins (e.g. Yoast SEO) | |
| 484 | 442 | if ( isset( $menu_settings[$current_menu_item[2]] ) ) { |
| 485 | 443 | $optiongroup = $menu_settings[$current_menu_item[2]]; |
| 486 | - } else { | |
| 487 | - $fallback = $this->find_menu_settings_by_slug( $current_menu_item[2] ); | |
| 488 | - if ( $fallback !== null ) { | |
| 489 | - $optiongroup = $fallback; | |
| 490 | - } | |
| 491 | - } | |
| 492 | - if ( !empty( $optiongroup ) ) { | |
| 493 | 444 | if ( isset( $optiongroup['order'] ) ) { |
| 494 | 445 | $order = $optiongroup['order']; |
| 495 | 446 | } |
| 496 | 447 | if ( isset( $optiongroup['separator'] ) ) { |
| @@ -568,9 +519,9 @@ | ||
| 568 | 519 | $menu_icon = str_replace( 'dashicons ', '', $menu_s['icon'] ); |
| 569 | 520 | } else { |
| 570 | 521 | if ( empty( $menu_s['icon'] ) || strpos( $menu_s['icon'], ',' ) !== false ) { |
| 571 | 522 | if ( empty( $menu_s['icon'] ) ) { |
| 572 | - $menu_icon = PXLBSADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg'; | |
| 523 | + $menu_icon = WP_ADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg'; | |
| 573 | 524 | } else { |
| 574 | 525 | $menu_icon = explode( ',', $menu_s['icon'] )[1]; |
| 575 | 526 | } |
| 576 | 527 | } else { |
| @@ -717,9 +668,9 @@ | ||
| 717 | 668 | $separator_order = $this->menu[$key]['order']; |
| 718 | 669 | $empty_separator = array( |
| 719 | 670 | 0 => '', |
| 720 | 671 | 1 => 'read', |
| 721 | - 2 => 'separator_' . wp_rand( 200, 1000 ) * 1000, | |
| 672 | + 2 => 'separator_' . rand( 200, 1000 ) * 1000, | |
| 722 | 673 | 3 => '', |
| 723 | 674 | 4 => 'wp-menu-separator', |
| 724 | 675 | 'order' => $separator_order + 0.5, |
| 725 | 676 | ); |
| @@ -760,9 +711,9 @@ | ||
| 760 | 711 | } |
| 761 | 712 | $submenu_settings = $this->menu_settings[$parentname]['submenu']; |
| 762 | 713 | $tempsub = []; |
| 763 | 714 | foreach ( $subitems as $current_menu_item ) { |
| 764 | - $sub_level = apply_filters( 'pxlbsadminify/menu_editor', [ | |
| 715 | + $sub_level = apply_filters( 'adminify/menu_editor', [ | |
| 765 | 716 | 'sub_level' => false, |
| 766 | 717 | ] ); |
| 767 | 718 | if ( !empty( $sub_level['sub_level'] ) ) { |
| 768 | 719 | if ( empty( $current_menu_item[0] ) || $current_menu_item[2] === 'wp-adminify-settings-pricing' ) { |
| @@ -834,18 +785,10 @@ | ||
| 834 | 785 | $disabled_for = []; |
| 835 | 786 | $optiongroup = []; |
| 836 | 787 | $order = $key; |
| 837 | 788 | if ( is_array( $this->menu_settings ) ) { |
| 838 | - // Direct slug match first, then fallback for dynamic-slug plugins (e.g. Yoast SEO) | |
| 839 | 789 | if ( isset( $this->menu_settings[$current_menu_item[2]] ) ) { |
| 840 | 790 | $optiongroup = $this->menu_settings[$current_menu_item[2]]; |
| 841 | - } else { | |
| 842 | - $fallback = $this->find_menu_settings_by_slug( $current_menu_item[2] ); | |
| 843 | - if ( $fallback !== null ) { | |
| 844 | - $optiongroup = $fallback; | |
| 845 | - } | |
| 846 | - } | |
| 847 | - if ( !empty( $optiongroup ) ) { | |
| 848 | 791 | if ( isset( $optiongroup['name'] ) ) { |
| 849 | 792 | $name = $optiongroup['name']; |
| 850 | 793 | if ( $name != '' ) { |
| 851 | 794 | $current_menu_item[0] = $name; |
| @@ -892,19 +835,14 @@ | ||
| 892 | 835 | } |
| 893 | 836 | } |
| 894 | 837 | } |
| 895 | 838 | $current_menu_item['order'] = $order; |
| 896 | - // Check hidden_for: boolean true means hide, array means check via is_hidden | |
| 897 | 839 | if ( isset( $current_menu_item['hidden_for'] ) ) { |
| 898 | 840 | if ( $current_menu_item['hidden_for'] === true ) { |
| 899 | 841 | return false; |
| 900 | - } elseif ( is_array( $current_menu_item['hidden_for'] ) && !empty( $current_menu_item['hidden_for'] ) ) { | |
| 901 | - // Fallback: hidden_for is still an array (settings lookup may have missed it) | |
| 902 | - if ( $this->is_hidden( $current_menu_item['hidden_for'] ) ) { | |
| 903 | - return false; | |
| 904 | - } | |
| 842 | + } else { | |
| 843 | + return $current_menu_item; | |
| 905 | 844 | } |
| 906 | - return $current_menu_item; | |
| 907 | 845 | } else { |
| 908 | 846 | return $current_menu_item; |
| 909 | 847 | } |
| 910 | 848 | } |
| @@ -930,11 +868,11 @@ | ||
| 930 | 868 | } |
| 931 | 869 | // Normalize disabled_for array |
| 932 | 870 | $disabled_for_arr = []; |
| 933 | 871 | foreach ( $disabled_for as $v ) { |
| 934 | - $disabled_for_arr[] = Utils::sluggify_with_underscores( $v ); | |
| 872 | + $disabled_for_arr[] = jlt_adminify_sluggify_with_underscores( $v ); | |
| 935 | 873 | } |
| 936 | - $slugify_user_login = Utils::sluggify_with_underscores( $current_user->user_login ); | |
| 874 | + $slugify_user_login = jlt_adminify_sluggify_with_underscores( $current_user->user_login ); | |
| 937 | 875 | // Check Username |
| 938 | 876 | if ( in_array( $current_user->user_login, $disabled_for_arr ) || in_array( $slugify_user_login, $disabled_for_arr ) ) { |
| 939 | 877 | return true; |
| 940 | 878 | } |
| @@ -1334,9 +1272,8 @@ | ||
| 1334 | 1272 | |
| 1335 | 1273 | <div class="select is-small"> |
| 1336 | 1274 | |
| 1337 | 1275 | <?php |
| 1338 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- generate_user_rules_select_field() returns a trusted <select> template with form inputs that wp_kses_post() would strip; values inside are escaped. | |
| 1339 | 1276 | echo $this->generate_user_rules_select_field( $menu_id, $disabled_for ); |
| 1340 | 1277 | ?> |
| 1341 | 1278 | |
| 1342 | 1279 | </div> |
| @@ -1471,9 +1408,9 @@ | ||
| 1471 | 1408 | ?>"></i> |
| 1472 | 1409 | <?php |
| 1473 | 1410 | } |
| 1474 | 1411 | } else { |
| 1475 | - $adminify_icon = PXLBSADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg'; | |
| 1412 | + $adminify_icon = WP_ADMINIFY_ASSETS_IMAGE . 'logos/menu-icon.svg'; | |
| 1476 | 1413 | if ( empty( $icons[$default_icons] ) ) { |
| 1477 | 1414 | echo '<i class=""><img width="24" height="24" src=' . esc_url( $adminify_icon ) . ' ></i>'; |
| 1478 | 1415 | } else { |
| 1479 | 1416 | ?> |
| @@ -1497,9 +1434,9 @@ | ||
| 1497 | 1434 | <?php |
| 1498 | 1435 | $upgrade_pro = ''; |
| 1499 | 1436 | $separator_name_attr = ''; |
| 1500 | 1437 | $upgrade_pro = 'upgrade-pro'; |
| 1501 | - $separator_name_attr = Utils::upgrade_pro_notice( 'Add Separator' ); | |
| 1438 | + $separator_name_attr = Utils::adminify_upgrade_pro( 'Add Separator' ); | |
| 1502 | 1439 | ?> |
| 1503 | 1440 | |
| 1504 | 1441 | <div class='column <?php |
| 1505 | 1442 | echo esc_attr( $upgrade_pro ); |
| @@ -1507,11 +1444,11 @@ | ||
| 1507 | 1444 | <label for="seperator-<?php |
| 1508 | 1445 | echo esc_attr( $name_attr ); |
| 1509 | 1446 | ?>"> |
| 1510 | 1447 | <?php |
| 1511 | - $separator_content = apply_filters( 'pxlbsadminify/menu_editor/add_separator', $separator_name_attr, $separator ); | |
| 1448 | + $separator_content = apply_filters( 'adminify/menu_editor/add_separator', $separator_name_attr, $separator ); | |
| 1512 | 1449 | // Apply the filter |
| 1513 | - echo wp_kses_post( $separator_content || "" ); | |
| 1450 | + echo $separator_content; | |
| 1514 | 1451 | ?> |
| 1515 | 1452 | </label> |
| 1516 | 1453 | </div> |
| 1517 | 1454 | </div> |
| @@ -1619,9 +1556,8 @@ | ||
| 1619 | 1556 | ?></label> |
| 1620 | 1557 | |
| 1621 | 1558 | <div class="select is-small"> |
| 1622 | 1559 | <?php |
| 1623 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- generate_user_rules_select_field() returns a trusted <select> template with form inputs that wp_kses_post() would strip; values inside are escaped. | |
| 1624 | 1560 | echo $this->generate_user_rules_select_field( $menu_id, $disabled_for ); |
| 1625 | 1561 | ?> |
| 1626 | 1562 | </div> |
| 1627 | 1563 | </div> |
| @@ -1733,9 +1669,8 @@ | ||
| 1733 | 1669 | ?></label> |
| 1734 | 1670 | |
| 1735 | 1671 | <div class="select is-small"> |
| 1736 | 1672 | <?php |
| 1737 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- generate_user_rules_select_field() returns a trusted <select> template with form inputs that wp_kses_post() would strip; values inside are escaped. | |
| 1738 | 1673 | echo $this->generate_user_rules_select_field( $menu_id, $disabled_for, 'sub_menu' ); |
| 1739 | 1674 | ?> |
| 1740 | 1675 | </div> |
| 1741 | 1676 | </div> |
| @@ -1792,10 +1727,10 @@ | ||
| 1792 | 1727 | /** |
| 1793 | 1728 | * Add New Menu Item. |
| 1794 | 1729 | */ |
| 1795 | 1730 | public function render_add_new_menu_item( $submenu = false ) { |
| 1796 | - $add_item = apply_filters( 'pxlbsadminify/menu_editor', [ | |
| 1797 | - 'upgrade_pro' => Utils::upgrade_pro_notice( ' ' ), | |
| 1731 | + $add_item = apply_filters( 'adminify/menu_editor', [ | |
| 1732 | + 'upgrade_pro' => Utils::adminify_upgrade_pro( ' ' ), | |
| 1798 | 1733 | 'upgrade_class' => 'upgrade-pro', |
| 1799 | 1734 | ] ); |
| 1800 | 1735 | ?> |
| 1801 | 1736 | <div class="adminify-accordion adminify-add-new-menu-editor-item upgrade-pro adminify-field adminify-field-switcher adminify-depend-visible adminify-depend-on adminify-pro-notice <?php |
| @@ -1800,9 +1735,9 @@ | ||
| 1800 | 1735 | ?> |
| 1801 | 1736 | <div class="adminify-accordion adminify-add-new-menu-editor-item upgrade-pro adminify-field adminify-field-switcher adminify-depend-visible adminify-depend-on adminify-pro-notice <?php |
| 1802 | 1737 | echo esc_attr( ( $submenu ? 'submenu' : '' ) ); |
| 1803 | 1738 | ?> <?php |
| 1804 | - echo esc_attr( $add_item['upgrade_class'] ); | |
| 1739 | + echo Utils::wp_kses_custom( $add_item['upgrade_class'] ); | |
| 1805 | 1740 | ?>"> |
| 1806 | 1741 | <div class="inner-text"> |
| 1807 | 1742 | <i class="dashicons dashicons-plus-alt"></i> |
| 1808 | 1743 | <span class="title"><?php |
| @@ -1809,9 +1744,9 @@ | ||
| 1809 | 1744 | esc_html_e( 'Add Item', 'adminify' ); |
| 1810 | 1745 | ?></span> |
| 1811 | 1746 | </div> |
| 1812 | 1747 | <?php |
| 1813 | - echo wp_kses( $add_item['upgrade_pro'], Utils::kses_allowed_html() ); | |
| 1748 | + echo Utils::wp_kses_custom( $add_item['upgrade_pro'] ); | |
| 1814 | 1749 | ?> |
| 1815 | 1750 | </div> |
| 1816 | 1751 | <?php |
| 1817 | 1752 | } |
| @@ -1826,15 +1761,14 @@ | ||
| 1826 | 1761 | |
| 1827 | 1762 | <div class="adminify-flex adminify-flex-center adminify-justify-between"> |
| 1828 | 1763 | <div class="adminify-menu-editor-help-urls adminify-flex adminify-flex-center adminify-gap-2"> |
| 1829 | 1764 | <?php |
| 1830 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- help_urls() returns a trusted template containing inline SVG icons that wp_kses_post() would strip; URLs inside are passed through esc_url(). | |
| 1831 | - echo Utils::help_urls( | |
| 1765 | + echo Utils::adminfiy_help_urls( | |
| 1832 | 1766 | __( 'Menu Editor', 'adminify' ), |
| 1833 | 1767 | 'https://wpadminify.com/kb/wordpress-dashboard-menu-editor/', |
| 1834 | 1768 | 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 1835 | 1769 | 'https://www.facebook.com/groups/jeweltheme', |
| 1836 | - esc_url( \PXLBSAdminify\Inc\Admin\AdminSettings::support_url() ) | |
| 1770 | + \WPAdminify\Inc\Admin\AdminSettings::support_url() | |
| 1837 | 1771 | ); |
| 1838 | 1772 | ?> |
| 1839 | 1773 | </div> |
| 1840 | 1774 | |
| @@ -1890,9 +1824,9 @@ | ||
| 1890 | 1824 | <path fill-rule="evenodd" clip-rule="evenodd" d="M8.00065 1.33334C4.31865 1.33334 1.33398 4.31801 1.33398 8.00001C1.33398 11.682 4.31865 14.6667 8.00065 14.6667C11.6827 14.6667 14.6673 11.682 14.6673 8.00001C14.6673 4.31801 11.6827 1.33334 8.00065 1.33334ZM2.66732 8.00001C2.66732 9.4145 3.22922 10.7711 4.22942 11.7712C5.22961 12.7714 6.58616 13.3333 8.00065 13.3333C9.41514 13.3333 10.7717 12.7714 11.7719 11.7712C12.7721 10.7711 13.334 9.4145 13.334 8.00001C13.334 6.58552 12.7721 5.22897 11.7719 4.22877C10.7717 3.22858 9.41514 2.66668 8.00065 2.66668C6.58616 2.66668 5.22961 3.22858 4.22942 4.22877C3.22922 5.22897 2.66732 6.58552 2.66732 8.00001V8.00001Z" fill="#4E4B66" /> |
| 1891 | 1825 | </svg> |
| 1892 | 1826 | |
| 1893 | 1827 | <?php |
| 1894 | - esc_html_e( 'If you have Adminify Menu Module disabled, icons and label dividers won\'t change.', 'adminify' ); | |
| 1828 | + esc_html_e( 'If you have WP Adminify Menu Module disabled, icons and label dividers won\'t change.', 'adminify' ); | |
| 1895 | 1829 | ?> |
| 1896 | 1830 | |
| 1897 | 1831 | </p> |
| 1898 | 1832 | </div> |
| @@ -1900,9 +1834,9 @@ | ||
| 1900 | 1834 | |
| 1901 | 1835 | <?php |
| 1902 | 1836 | } |
| 1903 | 1837 | |
| 1904 | - public function menu_editor_contents() { | |
| 1838 | + public function jltwp_adminify_menu_editor_contents() { | |
| 1905 | 1839 | ?> |
| 1906 | 1840 | |
| 1907 | 1841 | <div class="wrap"> |
| 1908 | 1842 | <div class="wp-adminify--menu--editor--container"> |