Skip to content

Instantly share code, notes, and snippets.

@otobrglez
otobrglez / i-love-ps.ps1
Created April 14, 2023 09:44
Recursively renaming files with PowerShell
# Oto Brglez - <otobrglez@gmail.com>
$folderPath = "dodo-was-here" | Resolve-Path
Get-ChildItem -Path $folderPath -Recurse -File |
ForEach-Object {
$newName = Join-Path (Split-Path $_.FullName) `
-ChildPath ($_.FullName -replace $folderPath,'' -replace '/|\\','-' -replace '^(.)','')
Rename-Item -Path $_.FullName -NewName $newName -Force # -WhatIf
}
@alexandreelise
alexandreelise / README.md
Last active May 29, 2023 21:19
Render All Joomla! 4 Standard Form Fields

j4xall

Render All Joomla! 4 Standard Form Fields using a article layout override. To make it work, you can put this the j4xall.php file at this location:


JPATH_ROOT/templates/cassopeia/html/com_content/article/j4xall.php

<?php
function renderForm ($endpoint) {
// get the data from the API and convert it to a PHP object
$formResult = file_get_contents($endpoint);
$formContent = json_decode($formResult);
$formFields = $formContent->fields;
// start building the DOM
$dom = new DOMDocument();
$form = $dom->createElement('form');
@alex-wdmg
alex-wdmg / wp_breadcrumbs.php
Last active April 12, 2024 06:21 — forked from Dimox/dimox_breadcrumbs.php
A custom WordPress nav walker class to implement the Bootstrap 4 breadcrumbs style in a custom theme using the WordPress.
<?php
/**
* WP Bootstrap Breadcrumbs
*
* @package WP-Bootstrap-Breadcrumbs
*
* Description: A custom WordPress nav walker class to implement the Bootstrap 4 breadcrumbs style in a custom theme using the WordPress.
* Author: Dimox - @Dimox, Alexsander Vyshnyvetskyy - @alex-wdmg
* Version: 1.1.0
* Author URI: https://github.com/Dimox
@Yiannistaos
Yiannistaos / Joomla-HTMLHelper.php
Last active April 26, 2023 07:53
Quick Intro into the Joomla! HTMLHelper class
<?php
// Quick Intro into the Joomla HTMLHelper class
// Checkout also this video: https://www.youtube.com/watch?v=aHY_hsu7iuk
// File: \libraries\src\HTML\HTMLHelper.php
use Joomla\CMS\HTML\HTMLHelper;
// Image
echo HTMLHelper::_('image', 'plg_system_web357framework/fix404errorlinks.png', Text::_('Fix 404 Error Links extension for Joomla!'), null, true);
echo HTMLHelper::_('image', 'media/plg_system_web357framework/images/fix404errorlinks.png', Text::_('Fix 404 Error Links extension for Joomla!'), null, false);
@alexandreelise
alexandreelise / htmlhelper-select-options-with-empty-default.php
Created September 26, 2020 01:03
Code snippet for HTMLHelper select options with empty default value
<label for="demo">Demo</label>
<select id="demo" name="demo">
<?php array_unshift($this->myExampleOptionsArray, null); ?>
<?php echo HTMLHelper::_('select.options', $this->myExampleOptionsArray, 'value', 'text', $this->selectedOptionValue ?? '');?>
</select>
@marsjaninzmarsa
marsjaninzmarsa / version-string.php
Created January 2, 2020 05:53
My solution for cache busting in WordPress (drop-in to `/mu-plugins/` in Bedrock).
<?php
/**
* Replaces query version in registered scripts or styles with file modified time
*
* @link https://wordpress.stackexchange.com/a/346024/51130 based on
*
* @param $src
*
* @return string
// gulpfile.js
// Initialize modules
const gulp = require('gulp');
// Importing all the Gulp-related packages we want to use
const concat = require('gulp-concat');
const sourcemaps = require('gulp-sourcemaps');
const sass = require('gulp-sass');
//const browserSync = require('browser-sync');
//const server = browserSync.create();
const child = require('child_process');
@alexandreelise
alexandreelise / add-custom-fields-to-core-modules-j3x.php
Created November 26, 2019 09:23
Add custom fields to core modules in Joomla! 3
<?php
defined('_JEXEC') or die;
?>
<div class="latestnews">
<ul class="list-group list-group-flush">
<?php foreach ($list as $item) : $image = json_decode($item->images); ?>
<?php
// most important part
// context:
// for articles: com_content.article