Summary
Ross’s “template for code stuff”.
I’ll also try to document what plugins I’m using via examples in this.
TODOs
There are at least two “TODOs” I can think of on 25MAR2019MON:
- One
- Two
Code Editor
I have wasted much time trying to override WordPress’s stupid “change my code” in the “Visual Editor”.
The easy solution is to just use the “Code Editor” on pages that might need it like this one.
This is a huge kludge but I just created a user called “code” that I turned off the “Visual Editor” via “User Profile” like:
Visual Editor _X_ Disable the visual editor when writing
Displaying Source Code
You’re going to want to check out for all the cool details:
For displaying source code I use “SyntaxHighlighter Evolved” like:
<!--?php echo “Hello World”; ?-->
And the source for that looks like:
[[php] <!--?php echo “Hello World”; ?--> [/php]]
And that code actually in the “Code Editor” in WordPress is:
[[text] [[php] <!--?php echo “Hello World”; ?--> [/php]] [/text]]
And the above example was generated by wrapping in ‘[[code language=”text”]]’ and adding layers of ‘[[‘ and ‘]]’.
And to to get ‘[[code language=”text”]]’ you need to do:
'[[code language="text"]]'
Header 1
Header 1 body text.
Header 2
Header 2 body text.
Header 3
Header 3 body text.
Header 4
Header 4 body text.
Header 5
Header 5 body text.
Header 6
Header 6 body text.
<h1>Header 1</h1> Header 1 body text. <h2>Header 2</h2> Header 2 body text. <h3>Header 3</h3> Header 3 body text. <h4>Header 4</h4> Header 4 body text. <h5>Header 5</h5> Header 5 body text. <h6>Header 6</h6> Header 6 body text.
Table
Here’s a table using simple “html table tags” (I am not currently using a plugin for tables but that may change in the future):
| FIRST 1st COLUMN | SECOND 2nd COLUMN |
|---|---|
| 1st column 1st row | 2nd column 1st row |
| 1st column 2nd row | 2nd column 2nd row |
| 1st column 3rd row | 2nd column 3rd row |
<table>
<tbody>
<tr>
<th>FIRST 1st COLUMN</th>
<th>SECOND 2nd COLUMN</th>
</tr>
<tr>
<td>1st column 1st row</td>
<td>2nd column 1st row</td>
</tr>
<tr>
<td>1st column 2nd row</td>
<td>2nd column 2nd row</td>
</tr>
<tr>
<td>1st column 3rd row</td>
<td>2nd column 3rd row</td>
</tr>
</tbody>
</table>
Footnote
This is a footnote1 using “Easy Footnotes”.
This is a footnote[[efn_note]For footnotes I use plugin "Easy Footnotes".[/efn_note]] using "Easy Footnotes".
Commands And Output
Simple “<pre>” is all you need here:
<pre>$ ls ... </pre>
Which renders like:
$ ls ...
One incredibly annoying tidbit is the “Code Editor” in WordPress with “remove whitespace” and keeps putting the “ls” on the the same line as the “<pre>”.
This is very annoying but don’t waste too much time trying to fix as I think you’ll fail (or see people telling you to modify the actual “*.php” code which I’m not wanting to do right now).
I almost never set “auto yes” so I always have a chance to say “N” on an upgrade so it’s safe to use ‐‐disablerepo to see what the effects are like:
[root@snafu ~]# dnf upgrade Last metadata expiration check: 0:00:00 ago on Thu 14 Mar 2019 08:05:20 PM CDT. Dependencies resolved. =============================================================================== Package Arch Version Repository Size =============================================================================== Upgrading: ... pcre x86_64 8.43-1.fc28 fubar-local-repo 208 k Transaction Summary =============================================================================== Upgrade 6 Packages Total download size: 93 M Is this ok [y/N]: N Operation aborted.
If I need to make sure my custom repo isn’t hurting anything I can disable for just the one command like:
[root@snafu ~]# dnf --disablerepo=fubar-local-repo upgrade Last metadata expiration check: 0:11:32 ago on Thu 14 Mar 2019 07:51:29 PM CDT. Dependencies resolved. =============================================================================== Package Arch Version Repository Size =============================================================================== Upgrading: ... pcre x86_64 8.43-1.fc28 updates 208 k Transaction Summary =============================================================================== Upgrade 6 Packages Total download size: 93 M Is this ok [y/N]: N Operation aborted.
setopt
Above I had you set “priority” in the config file using a text editor, that could have been:
[root@snafu ~]# dnf config-manager --setopt priority=11 --save fubar-local-repo Main config did not have a priority attr. before setopt Main config did not have a priority attr. before setoptnext
Those “did not have” messages bother me but if you check out the master log file it did not change:
[root@snafu ~]# cat /etc/dnf/dnf.conf [main] gpgcheck=1 installonly_limit=3 clean_requirements_on_remove=True
And if you check the “repo file” for our repo “fubar-local-repo” you’ll see the “11” like:
[root@snafu ~]# cat /etc/yum.repos.d/fubar-local.repo
[fubar-local-repo]
name=Fubar Local Repository
#baseurl=file:///testrepo/
baseurl=ftp://fubar/pub/dnfrepo/
enabled=1
gpgcheck=0
priority = 11
The full list of “options” is easy to find like:
[root@snafu ~]# dnf config-manager --dump fubar-local-repo =========================== repo: fubar-local-repo ============================ [fubar-local-repo] ... priority = 11 ...
Notice you see our “priority” we just set. Also notice some stuff from the master dnf conf is not present like “clean_requirements_on_remove” is not seen. If you want to see “master” leave off the repo like:
[root@snafu ~]# dnf config-manager --dump ==================================== main ===================================== [main] ... clean_requirements_on_remove = True ...
And you do not see our “priority”.
I know of no built in way to see if an option is a default or from what config file. It’s not overly challenging to do some “grepp’ing” between files and have to do it so seldom I’ve never bothered to script it.
And finally if you set a “non existent option” like:
[root@snafu ~]# dnf config-manager --setopt foo=bar --save fubar-local-repo Main config did not have a foo attr. before setopt Main config did not have a foo attr. before setopt
You’ll see in the config like:
[fubar-local-repo]
name=Fubar Local Repository
#baseurl=file:///testrepo/
baseurl=ftp://fubar/pub/dnfrepo/
enabled=1
gpgcheck=0
priority = 11
foo = bar
“foo” is not a valid option so I’m not sure why it’s allowed but “dnf” won’t complain until you do something like (note I used “-v” for “verbose”):
[root@snafu ~]# dnf config-manager -v --dump-variables fubar-local-repo
Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repograph, repomanage, reposync
DNF version: 2.7.5
cachedir: /var/cache/dnf
Unknown configuration option: foo = bar in /etc/yum.repos.d/fubar-local.repo
arch = x86_64
basearch = x86_64
releasever = 28
I don’t know of a “verify” option you can use but I suspect one might exist.
And if you need to remove option “foo” the only way I know is to use a text editor 🙁
References
Almost always in something technical I’m looking stuff up and a references section is a good idea:
http://www.hoopchuk.org/wordpress/code-template/
Print Friendly
I prefer a PDF to print something like this.
I use plugin “Print, PDF & Email by PrintFriendly”.
Subversion
$Id: code-template.txt 4149 2019-04-25 19:03:45Z hoopchuk $