Hey there,
This guide will allow anyone to find anything inside Chevereto code (in any code actually).
I wrote this because when someone ask me where is something I actually do a code search and just return the results of that search. I believe that everybody figures that because I don't know exactly where everything is located in Chevereto, is too big to have a mental map of everything.
I will describe two methods that I use everyday and later I will elaborate on the most important thing: The search string.
Method 1: GitHub search (lazy)
Method 2: Actual code search (best)
Search string and real examples
The most important thing to keep in mind is to determine a good search string. For example, if you want to search for lets say the "Add image URLs" modal box:
You should figure out that good search strings should be:
Note that I got an exact match because I searched to match case (lowercase and uppercase are not the same). Look what I get if I don't match case:
As you may notice two results are for links and one for the actual text being used in the modal. Always narrow down your search for stuff like match case, .php files, directory where to look for, etc. There are words present in almost every file so the best you narrow down the search, the better results you will get.
Another example, lets say that you want to change where it reads "Followers":
Unfortunately "Followers" is a very common word, so in this case you should include HTML in your search string. Open your browser's console and inspect the "Followers" element. You will get something like this:
So your search should be for this:
But for that you won't get results. That's very common because this is an HTML section which is generated via PHP, you will need to remove some characters from your initial search string. Key point is to still preserve the "unique" element, in this case that element is data-text="followers-label".
The final search string looks like this:
And it narrows down to this section in the code:
Note that is impossible to get to this search result by just searching using generated HTML code. Please keep that in mind when performing code search.
Hope this guide helps.
Cheers,
Rodolfo.
This guide will allow anyone to find anything inside Chevereto code (in any code actually).
I wrote this because when someone ask me where is something I actually do a code search and just return the results of that search. I believe that everybody figures that because I don't know exactly where everything is located in Chevereto, is too big to have a mental map of everything.
I will describe two methods that I use everyday and later I will elaborate on the most important thing: The search string.
Method 1: GitHub search (lazy)
- Go to chevereto/chevereto at GitHub
- On top bar it reads "This repository" and next to it "Search"
- Enter the search string that you are looking for and submit the form
- Filter search results by language (PHP, JS)
Method 2: Actual code search (best)
- Get a working copy of your website (or a base release that matches your website)
- Get any text editor with search feature
- On your text editor, find "Search", put your search string, tweak search parameters (include folders, recursive search if possible)
- Submit the form, you should get results shortly.
Search string and real examples
The most important thing to keep in mind is to determine a good search string. For example, if you want to search for lets say the "Add image URLs" modal box:
You should figure out that good search strings should be:
- Add image URLs
- Add the image URLs here
Code:
Search "Add image URLs" (1 hit in 1 file)
Chevereto\app\themes\Peafowl\snippets\anywhere_upload.php (1 hit)
Line 306: <span class="modal-box-title"><?php _se('Add image URLs'); ?></span>
Note that I got an exact match because I searched to match case (lowercase and uppercase are not the same). Look what I get if I don't match case:
Code:
Search "Add image URLs" (3 hits in 1 file)
Chevereto\app\themes\Peafowl\snippets\anywhere_upload.php (3 hits)
Line 24: '%u' => '<a data-modal="form" data-target="anywhere-upload-paste-url">' . _s('add image URLs') . '</a>',
Line 28: '%u' => '<a data-modal="form" data-target="anywhere-upload-paste-url">' . _s('add image URLs') . '</a>',
Line 306: <span class="modal-box-title"><?php _se('Add image URLs'); ?></span>
As you may notice two results are for links and one for the actual text being used in the modal. Always narrow down your search for stuff like match case, .php files, directory where to look for, etc. There are words present in almost every file so the best you narrow down the search, the better results you will get.
Another example, lets say that you want to change where it reads "Followers":
Unfortunately "Followers" is a very common word, so in this case you should include HTML in your search string. Open your browser's console and inspect the "Followers" element. You will get something like this:
So your search should be for this:
Code:
<span data-text="followers-label" data-label-single="Follower" data-label-plural="Followers">Followers</span>
But for that you won't get results. That's very common because this is an HTML section which is generated via PHP, you will need to remove some characters from your initial search string. Key point is to still preserve the "unique" element, in this case that element is data-text="followers-label".
The final search string looks like this:
Code:
<span data-text="followers-label" data-label-single=
And it narrows down to this section in the code:
Code:
<span data-text="followers-label" data-label-single="<?php _ne('Follower', 'Followers', 1); ?>" data-label-plural="<?php _ne('Follower', 'Followers', 2); ?>"><?php _ne('Follower', 'Followers', get_user()['followers']); ?></span>
Note that is impossible to get to this search result by just searching using generated HTML code. Please keep that in mind when performing code search.
Hope this guide helps.
Cheers,
Rodolfo.
Last edited: