Plugin Directory

Changeset 3344141


Ignore:
Timestamp:
08/13/2025 06:59:42 PM (8 months ago)
Author:
apos37
Message:

1.4.1

  • Update: Added support for enqueuing frontend stylesheets in the backend, option to enable it in settings
  • Update: Added support for Gutenberg editor, option to enable it in settings (props @derek for suggestion)
Location:
admin-help-docs
Files:
65 added
8 edited

Legend:

Unmodified
Added
Removed
  • admin-help-docs/trunk/admin-help-docs.php

    r3305205 r3344141  
    44 * Plugin URI:          https://pluginrx.com/plugin/admin-help-docs/
    55 * Description:         Site developers and operators can easily create help documentation for the admin area
    6  * Version:             1.4.0
     6 * Version:             1.4.1
    77 * Requires at least:   5.9
    88 * Tested up to:        6.8
  • admin-help-docs/trunk/includes/admin/admin-area.php

    r3305205 r3344141  
    9595            $row_meta = [];
    9696            foreach ( $our_links as $key => $link ) {
    97             // translators: %1$s is the link label, %2$s is the plugin name.
    98             $aria_label = sprintf( __( '%1$s for %2$s', 'admin-help-docs' ), $link[ 'label' ], $plugin_name );
    99             $row_meta[ $key ] = '<a href="' . esc_url( $link[ 'url' ] ) . '" target="_blank" aria-label="' . esc_attr( $aria_label ) . '">' . esc_html( $link[ 'label' ] ) . '</a>';
    100         }
     97                // translators: %1$s is the link label, %2$s is the plugin name.
     98                $aria_label = sprintf( __( '%1$s for %2$s', 'admin-help-docs' ), $link[ 'label' ], $plugin_name );
     99                $row_meta[ $key ] = '<a href="' . esc_url( $link[ 'url' ] ) . '" target="_blank" aria-label="' . esc_attr( $aria_label ) . '">' . esc_html( $link[ 'label' ] ) . '</a>';
     100            }
    101101
    102102            // Add the links
  • admin-help-docs/trunk/includes/admin/css/style.php

    r3059362 r3344141  
    8989            padding-top: 0 !important;
    9090        }
     91
     92        #doc-viewer h3,
     93        #doc-viewer .wrap h3 {
     94            margin-top: revert !important;
     95            border-top: revert !important;
     96            padding-top: revert !important;
     97        }
     98
    9199        .wrap {
    92100            padding: 0 !important;
     
    315323    </style>
    316324
    317 <?php }
     325<?php } ?>
  • admin-help-docs/trunk/includes/admin/global-options.php

    r3273773 r3344141  
    5555            'admin_bar',
    5656            'dashboard_toc',
     57            'gutenberg_editor',
     58            'enqueue_frontend_styles',
    5759            'dashicon',
    5860            'logo',
  • admin-help-docs/trunk/includes/admin/option-about.php

    r3305205 r3344141  
    9696<br><br>
    9797<h3>Plugin Support</h3>
    98 
    99 <?php /* translators: 1: Text for the button (default: Join Our Support Server) */
     98<?php
    10099echo '<a class="button button-primary" href="'.esc_url( HELPDOCS_GUIDE_URL ).'" target="_blank">'.esc_html( __( 'How-To Guide', 'admin-help-docs' ) ).' »</a><br><br>';
    101100echo '<a class="button button-primary" href="'.esc_url( HELPDOCS_DOCS_URL ).'" target="_blank">'.esc_html( __( 'Developer Docs', 'admin-help-docs' ) ).' »</a><br><br>';
  • admin-help-docs/trunk/includes/admin/option-settings.php

    r3273773 r3344141  
    136136
    137137        <?php echo wp_kses( helpdocs_options_tr( 'dashboard_toc', 'Enable Dashboard TOC', 'checkbox', ' Adds a dashboard widget with a table of contents for the docs on the Main Documentation Page.' ), $allowed_html ); ?>
     138
     139        <?php echo wp_kses( helpdocs_options_tr( 'gutenberg_editor', 'Use Gutenberg Editor', 'checkbox', ' Adds support for the Gutenberg editor for the documentation. Default is the classic editor.' ), $allowed_html ); ?>
     140
     141        <?php echo wp_kses( helpdocs_options_tr( 'enqueue_frontend_styles', 'Use Frontend Styles', 'checkbox', ' Adds support for your frontend styles in the backend.' ), $allowed_html ); ?>
    138142
    139143        <?php $di = 'dashicons-';
  • admin-help-docs/trunk/includes/classes/class-documentation.php

    r3289964 r3344141  
    115115        $this->register_taxonomy();
    116116
    117         // Disable block editor
    118         add_filter( 'use_block_editor_for_post_type', [ $this, 'disable_gutenberg' ], 10, 2 );
     117        // Either enqueue block editor styles or disable block editor
     118        if ( ! get_option( 'helpdocs_gutenberg_editor' ) ) {
     119            add_filter( 'use_block_editor_for_post_type', [ $this, 'disable_gutenberg' ], 10, 2 );
     120        }
     121
     122        // Enqueue back-end styles
     123        add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_styles' ] );
    119124
    120125        // Add the header to the top of the admin list page
     
    242247
    243248    /**
     249     * Enqueue admin styles.
     250     */
     251    public function enqueue_admin_styles() {
     252        // Add block styles
     253        if ( get_option( 'helpdocs_gutenberg_editor' ) ) {
     254            wp_enqueue_style(
     255                'wp-block-library-frontend',
     256                includes_url( 'css/dist/block-library/style.css' ),
     257                [],
     258                false
     259            );
     260        }
     261
     262        // Enqueuing frontend styles
     263        if ( get_option( 'helpdocs_enqueue_frontend_styles' ) ) {
     264           
     265            // Add theme styles
     266            global $wp_styles;
     267
     268            do_action( 'wp_enqueue_scripts' );
     269
     270            $skip = [ 'wp-block-library', 'wp-admin', 'colors', 'dashicons' ];
     271
     272            foreach ( $wp_styles->queue as $handle ) {
     273                if ( in_array( $handle, $skip, true ) ) {
     274                    continue;
     275                }
     276
     277                $style = $wp_styles->registered[ $handle ] ?? null;
     278
     279                if ( $style && ! wp_style_is( $handle, 'enqueued' ) ) {
     280                    wp_enqueue_style(
     281                        $handle,
     282                        $style->src,
     283                        $style->deps,
     284                        $style->ver
     285                    );
     286                }
     287            }
     288
     289            // Add our own fixes
     290            wp_enqueue_style(
     291                'helpdocs-backend-styles',
     292                HELPDOCS_PLUGIN_CSS_PATH . 'style.css',
     293                [],
     294                false
     295            );
     296        }
     297    } // End enqueue_admin_styles()
     298
     299
     300    /**
    244301     * Disable Gutenberg while allowing rest
    245302     *
     
    252309        // Disabled post types
    253310        $disabled_post_types = [ $this->post_type ];
    254    
     311
    255312        // Change $can_edit to false for any post types in the disabled post types array
    256313        if ( in_array( $post_type, $disabled_post_types, true ) ) {
    257314            $current_status = false;
    258315        }
    259    
     316
    260317        return $current_status;
    261318    } // End disable_gutenberg()
     
    489546
    490547            // Skip separators
    491             if ( str_starts_with( $m[2], 'separator' ) ) {
     548            if ( str_starts_with( $m[2], 'separator' ) || $m[2] == 'hp_separator' || ( isset( $m[4] ) && strpos( $m[4], 'wp-menu-separator' ) !== false ) ) {
    492549                continue;
    493550            }
     
    511568
    512569            // Strip html
    513             $site_location_name = wp_strip_all_tags( $site_location_name );
     570            $site_location_name = $this->strip_admin_menu_counters( $site_location_name );
    514571
    515572            // Add the parent location
     
    545602
    546603                        // Strip html
    547                         $sublocation_name = wp_strip_all_tags( $sublocation_name );
     604                        $sublocation_name = $this->strip_admin_menu_counters( $sublocation_name );
    548605
    549606                        // Get the url
     
    921978   
    922979    } // End get_admin_menu_item_url()
     980
     981
     982    /**
     983     * Strip admin menu counters from a label
     984     *
     985     * @param string $label
     986     * @return string
     987     */
     988    private function strip_admin_menu_counters( $label ) {
     989        if ( !is_string( $label ) ) {
     990            return $label;
     991        }
     992
     993        // Remove update badges (nested spans included)
     994        $label = preg_replace( '/<span[^>]*class="[^"]*\b(update-plugins|awaiting-mod|count-[0-9]+|bubble)\b[^"]*"[^>]*>.*?<\/span>/i', '', $label );
     995
     996        // Remove any remaining HTML
     997        $label = wp_strip_all_tags( $label );
     998
     999        // Decode entities then trim
     1000        $label = trim( html_entity_decode( $label, ENT_QUOTES, 'UTF-8' ) );
     1001
     1002        // Remove trailing counts like "85", "(85)", "[85]", "{85}"
     1003        $label = preg_replace( '/(?:\s*[\(\[\{]\s*\d+\s*[\)\]\}])|\s*\d+\s*$/', '', $label );
     1004
     1005        return trim( $label );
     1006    } // End strip_admin_menu_counters()
    9231007
    9241008
     
    9791063
    9801064                    // Set the child default name that is not changed
    981                     $child_default_name = $s[0];
     1065                    $child_default_name = $this->strip_admin_menu_counters( $s[0] );
    9821066
    9831067                    // Set the child name
     
    10131097                        $parent = $site_location_names[ $m[2] ];
    10141098                    } else {
    1015                         $parent = $m[0];
     1099                        $parent = $this->strip_admin_menu_counters( $m[0] );
    10161100                    }
    10171101                }
     
    10351119                            $parent = $site_location_names[ base64_decode( $url ) ];
    10361120                        } else {
    1037                             $parent = $m[0];
     1121                            $parent = $this->strip_admin_menu_counters( $m[0] );
    10381122                        }
    10391123                    }
     
    10491133                            $parent = $site_location_names[ base64_decode( $url ) ];
    10501134                        } else {
    1051                             $parent = $m[0];
     1135                            $parent = $this->strip_admin_menu_counters( $m[0] );
    10521136                        }
    10531137                    }
  • admin-help-docs/trunk/readme.txt

    r3305247 r3344141  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.4.0
     7Stable tag: 1.4.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    7575
    7676== Changelog ==
     77= 1.4.1 =
     78* Update: Added support for enqueuing frontend stylesheets in the backend, option to enable it in settings
     79* Update: Added support for Gutenberg editor, option to enable it in settings (props @derek for suggestion)
     80
    7781= 1.4.0 =
    7882* Update: Removed feedback form since it's not being utilized
Note: See TracChangeset for help on using the changeset viewer.