Skip to content

Conversation

@mikemastercorp
Copy link

Just found your tiny CMS and liked the performance so decided to look under the hood and thought I can pay back my 5 cents on a few code improvements to remove unnecessary counter variables and provide some code improvements.

@mikemastercorp
Copy link
Author

Having that said, the original code would definitely work as is, it is just as small improvement in terms of readability and habits of PHP Devs to use $key => $value in for() loops. Besides that, I've added a few checks to prevent unnecessary loops where a break was needed where an if() criteria is not met... Like I said, Share-ing is Care-ing ;)

@danpros
Copy link
Owner

danpros commented May 27, 2025

Hello,

Thanks for the PR. Yes, it is quite old code indeed, and there are many functions that need to be refactored. Let's try to improve it in the future.

I already reviewed it. There is one problem, so when the contents of views.json are empty or the file does not exist, it takes some of the latest posts. It should display: <ul><li>No popular posts found</li></ul>

@mikemastercorp
Copy link
Author

I will have a look, maybe I overdid some parts as I am not 100% sure how to test all functions and it might have slipped through. If you have any idea on the method responsible for it, it will speed the things up as I've touched a few and have to dig a bit deeper now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants