Skip to content

Instantly share code, notes, and snippets.

View tdiphale's full-sized avatar

Titus Diphale tdiphale

  • Botswana Havard AIDS Partnership
  • Botswana
View GitHub Profile
@tdiphale
tdiphale / openssl.md
Created November 6, 2019 06:38 — forked from NoMan2000/openssl.md
Common OpenSSL Commands with Keys and Certificates

Common OpenSSL Commands with Keys and Certificates

SSL Info

Generate RSA private key with certificate in a single command

openssl req -x509 -newkey rsa:4096 -sha256 -keyout example.key -out example.crt -subj "/CN=example.com" -days 3650 -passout pass:foobar

Generate Certificate Signing Request (CSR) from private key with passphrase

openssl x509 -x509toreq -in example.crt -out example.csr -signkey example.key -passin pass:foobar

@tdiphale
tdiphale / README.md
Created September 4, 2019 12:24 — forked from itzikbenh/README.md
WordPress - How to upload images from a frontend form via the rest-api.

Before you go over the snippets I will summarize which functions are being used.

media_handle_upload('image', 0);

That's it! one function that would insert the image into the DB, create four copies with different sizes, and upload to the uploads directory. Regarding the arguments:

'image' is what holds all the data about the image. It comes from the POST request. In the JS file you will see what I mean.

'0' This is the $post_id. I set it to zero, because i'm not asigning this image to any post at the moment. In order for this function to work we need to add above it:

@tdiphale
tdiphale / tps-nav-menu-customization.php
Created July 8, 2019 06:46 — forked from tatianepires/tps-nav-menu-customization.php
WordPress: add class to LI and A elements output by wp_nav_menu()
<?php
// Add class to A element of .primary-menu
function tps_primary_menu_anchor_class($item_output, $item, $depth, $args) {
$item_output = preg_replace('/<a /', '<a class="nav-link" ', $item_output, 1);
return $item_output;
}
add_filter('walker_nav_menu_start_el', 'tps_primary_menu_anchor_class', 10, 4);
// Add class to LI element of .primary-menu
function tps_primary_menu_li_class($objects, $args) {