WordPress.org

Ready to get started?Download WordPress

Forums

Code Snippets
[resolved] Suggestion - Sort by Snippet Name (11 posts)

  1. WebEndev
    Member
    Posted 1 year ago #

    The snippets currently sort by date/time of entry in the Manage Snippets screen.

    It would be great if they sorted alphabetically as an option.

    Again, great plugin!
    Thanks

    http://wordpress.org/extend/plugins/code-snippets/

  2. togur
    Member
    Posted 1 year ago #

    Also I vote for this feature.

    Thanks for Code Mirror - is much better than previous editor!

  3. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    I'm working on adding a few new features to the Manage Snippets page; sorting by name will be one of them.

  4. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    With version 1.5 comes the ability to sort snippets by name by clicking on the column header.

    To sort by ID again, click on the 'Screen Options' tab in the top-right corner, check the 'ID' checkbox and then click on the header of the ID column. You can also sort descending by clicking on the column header again.

  5. bmc38119
    Member
    Posted 1 year ago #

    great plugin! just discovered the other day. do you plan to further enhance the sorting functionality? currently, if you sort by the name column, select a snippet, and then go back to the list, your previous sort is gone. given the number of snippets i have on my site (and i am basically prefixing the name with a "category"), i would love to have a sorting option that is more persistent.

  6. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    Persistent sorting isn't a usual feature of WordPress admin tables. I suppose that it may be possible to save your sorting preferences to your user profile in the WordPress database, just like the snippets per page option. But, as I said, doing this wouldn't be consistent with other WordPress administration areas.

    Something else to keep in mind is that I may be introducing "tags" or "categories" for snippets sometime in the future.

  7. bmc38119
    Member
    Posted 1 year ago #

    i guess i was thinking more of adding an option to the plugin to sort by ID or sort by snippet name. tags and categories would be very helpful as well. thank you.

  8. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    You can sort by name by clicking on the 'Name' column label. It is the same for the ID column.

    If the ID column is not visible, you can show it by clicking on the 'Screen Options' tab in the top-right corner and checking the checking the 'ID' checkbox.

  9. Tom Braider
    Member
    Posted 1 year ago #

    simply change class-list-table.php line 351 to
    $orderby = ( ! empty($_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'name';
    to order by 'name' by default ;)

  10. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    With Code Snippets 1.6 and later, you can alter the default order by value using the code_snippets_default_orderby filter hook. This means that there is no need to use Tom Braider's solution anymore.

    Here is a code snippet that will set the default snippet order to name instead of id:

    function my_default_snippets_order( $orderby ) {
    	return 'name';
    }
    add_filter( 'code_snippets_default_orderby', 'my_default_snippets_order' );

    You can add the above snippet to a custom plugin, your functions.php file, or as a code snippet through the Snippets admin menu.

  11. Shea Bunge
    Member
    Plugin Author

    Posted 9 months ago #

    In Code Snippets 1.8 the hook name has changed for setting the default snippet orderby. The above solution will no longer work.

    Instead see http://code-snippets.bungeshea.com/docs/snippets-default-orderby/ for details on how to make snippets order by name by default

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.