Skip to content

Instantly share code, notes, and snippets.

@conkonig
conkonig / get-latest-html-in-directory.php
Last active May 23, 2020 23:14
PHP get latest html template in a directory - (bug: didnt work past num 9 for some reason)
<?php
// example 1
$episodes = preg_grep('~^good-.*\.html$~', scandir(__DIR__));
$d = new DOMDocument;
$mock = new DOMDocument;
$d->loadHTML(file_get_contents(__DIR__ . '/' . end($episodes)));
$body = $d->getElementsByTagName('body')->item(0);
@conkonig
conkonig / remove-comments.php
Created February 20, 2020 09:29
Remove all comments from all php files in template directory
```
<?php
function rmcomments($id)
{
if (file_exists($id)) {
if (is_dir($id)) {
$handle = opendir($id);
while ($file = readdir($handle)) {
if (($file != ".") && ($file != "..")) {
@conkonig
conkonig / wordpress-pagination-boostrap-4
Last active February 17, 2020 10:41
Wordpress pagination for bootstrap 4 - that works anywhere and doesn't suck
Original credit to renzramos/wordpress-bootstrap-4-pagination - however his only works with the main loop. Small modification.
Now you can use in main query or custom wp query.
```php
<?php
if (!function_exists('pagination_that_doesnt_suck')) {
function pagination_that_doesnt_suck($query = 0)
{
@conkonig
conkonig / setting-up-docker-wordpress.md
Last active May 13, 2020 14:45
How to set up wordpress to work in docker

Creating a docker container for your wordpress site for local dev

####PROJECT DIRECTORY

(dir) wp-content
      - all your wordpress theme files and plugins
(dir) db-content
      - your sql database file to import
docker-compose.yml (code example below)