Skip to content

Instantly share code, notes, and snippets.

View marcwieland95's full-sized avatar

Marc Wieland marcwieland95

View GitHub Profile
@tkadlec
tkadlec / perf-diagnostics.css
Last active June 8, 2023 17:47
CSS used to highlight potential performance issues
:root {
--violation-color: red; /* used for clear issues */
--warning-color: orange; /* used for potential issues we should look into */
}
/* IMAGES */
/*
* Lazy-Loaded Images Check
* ====
@kingkool68
kingkool68 / use-remote-media.php
Last active March 24, 2024 11:37
Check if a local file exists in the WordPress media library and if it doesn't exist, replace the URL with a different URL. Helpful when working with a local site that doesn't have all of the media downloaded as the production site. See https://localwp.com/community/t/proxying-requests-to-wp-content-uploads-to-a-production-site/15701
<?php
// Put this in wp-config.php and replace https://example.com/ with the URL of the production site.
define( 'RH_USE_REMOTE_MEDIA_URL', 'https://example.com/' );
// Put the rest of this in functions.php or a custom plugin or somewhere else.
if ( defined( 'RH_USE_REMOTE_MEDIA_URL' ) && ! empty( RH_USE_REMOTE_MEDIA_URL ) ) {
add_filter( 'wp_get_attachment_image_src', 'filter_wp_get_attachment_image_src' );
add_filter( 'wp_calculate_image_srcset', 'filter_wp_calculate_image_srcset' );
add_filter( 'wp_get_attachment_url', 'filter_wp_get_attachment_url' );
}
@Jakobud
Jakobud / _poly-fluid-sizing.scss
Last active September 18, 2022 14:24
Poly Fluid Sizing using linear equations, viewport units and calc()
/// poly-fluid-sizing
/// Generate linear interpolated size values through multiple break points
/// @param $property - A string CSS property name
/// @param $map - A SASS map of viewport unit and size value pairs
/// @requires function linear-interpolation
/// @requires function map-sort
/// @example
/// @include poly-fluid-sizing('font-size', (576px: 22px, 768px: 24px, 992px: 34px));
/// @author Jake Wilson <jake.e.wilson@gmail.com>
@mixin poly-fluid-sizing($property, $map) {
@Shelob9
Shelob9 / caldera_forms_render_field_structure-change-default.php
Created December 22, 2016 17:23
Examples of using the Caldera Forms filter caldera_forms_render_field_structure to modify field display when rednering forms, see: https://calderaforms.com/doc/caldera_forms_render_field_structure/
<?php
/**
* Change the default for a dropdown to "red" if a specific user meta key is set for current user
*/
add_filter( 'caldera_forms_render_field_structure', function( $field_structure, $form ){
//make sure to change field ID to your field's ID here!
//not that $field_structure is not the same as field config, but that is stored in $field_structure[ 'field' ]
if( 0 != get_current_user_id() && 'fld_1234' == $field_structure[ 'field' ][ 'ID' ] ) {
if( 'red' == get_user_meta( get_current_user_id(), 'color', true ) ){
$field_structure[ 'default' ] = 'red';
@zeshanshani
zeshanshani / acf_options_multilingual.php
Last active October 10, 2023 11:25
Creates separate Advanced Custom Fields options pages for the specified languages.
<?php // Don't copy this line if you are inserting in a file that has it already.
/**
* ACF Options Page
*
* Instructions:
* Add more languages to the array below: $languages
*
* @author: Zeshan Ahmed <https://zeshanahmed.com/>
*/
@petertwise
petertwise / wp-cli-oneclick-install.sh
Last active January 2, 2024 20:17
Customized wordpress install script with WP CLI
#!/bin/bash
# Install Wordpress with Square Candy default using WP CLI
read -p 'Site URL (example.com): ' url
read -p 'Site Title: ' title
read -p 'WP Admin username: ' admin_user
read -sp 'WP Admin password: ' admin_password
read -p '
WP Admin email: ' admin_email
read -p 'Database name: ' dbname
read -p 'Database user: ' dbuser
anonymous
anonymous / heartbeat-api.php
Created March 17, 2016 12:57
Heartbeat-Schnittstelle von WordPress abschalten
<?php
// Heartbeat-Schnittstelle komplett abschalten
add_action('init', 'stop_heartbeat', 1);
function stop_heartbeat()
{
wp_deregister_script('heartbeat');
}
// Heartbeat-Schnittstelle außerhalb der Beiträge abschalten
@eyecatchup
eyecatchup / git-commit-log-stats.md
Last active July 12, 2024 09:40
Some commands to get git commit log statistics for a repository on the command line.

git commit stats

Commands to get commit statistics for a Git repository from the command line -
using git log, git shortlog and friends.




@neverything
neverything / comopser-wp-cli.md
Last active December 7, 2021 07:42
Install composer and wp-cli on cyon.ch hostings with SSH access.

Cyon.ch/Hostpoint - Install composer & wp-cli

SSH into your server and stay in the home directory of the user. Check if you have a bin directory in your user directory already, in case you do, omit the mkdir bin.

Use bin folder in $HOME for user scriptsr

For the commands to be loaded from the bin directory run echo "export PATH=$HOME/bin:$PATH" >> ~/.bashrc. For the new config to be used run source ~/.bashrc or close and reopen your SSH session.

Composer

@mojaray2k
mojaray2k / acf-conditional.php
Last active July 14, 2018 21:11
WordPress Meta Box Conditional Logic and Interaction with Advance Custom Fields
/**
* Meta Box { Conditional Logic
*
* @description: hide / show fields based on a "change" field
* @created: 12/21/14
*/
add_action('admin_head', 'non_acf_conditional_logic');
if (!function_exists('non_acf_conditional_logic')) {
function non_acf_conditional_logic(){
global $current_screen;