Skip to content

Instantly share code, notes, and snippets.

View vyskoczilova's full-sized avatar

Karolína Vyskočilová vyskoczilova

View GitHub Profile
@hakre
hakre / DomTree.php
Last active February 22, 2021 11:40
DomTree - Dump DomDocument based documents, suiting debugging needs
<?php
/**
* DomTree
*
* Dump DomDocument based documents, suiting debugging needs
*
* @author hakre <http://hakre.wordpress.com/>
* @link http://stackoverflow.com/questions/26321597/getting-price-from-amazon-with-xpath/26323824#26323824
* @link http://stackoverflow.com/questions/12108324/how-to-get-a-raw-from-a-domnodelist/12108732#12108732
* @link http://stackoverflow.com/questions/684227/debug-a-domdocument-object-in-php/8631974#8631974
<?php
/**
* Renders content before the blog starts. Using a reusable gutenberg block.
*/
function generate_blog_intro() {
/**
* Make sure we are on the posts page.
*/
if ( is_home() ) {
/**
@dasilvaluis
dasilvaluis / gulpfile.js
Last active September 27, 2021 09:34
Gettext Scanner Gulp Script for Twig Projects
/**
* Gettext Scanner Script for Twig Projects
* v1.3
*
* Developed by Luís Silva
* https://github.com/luism-s
*/
/**
* Purpose:
@Tusko
Tusko / functions.php
Last active February 27, 2022 13:46
WP Ajax search (ACF included)
<?php
/* Wordpress Custom Search by title, ACF, post_meta */
// Wordpress ?s= redirect to /search/
function wpa_search_redirect() {
global $wp_rewrite;
if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { return; }
$search_base = $wp_rewrite->search_base;
if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) {
wp_redirect(home_url("/{$search_base}/" . urlencode(get_query_var('s'))));
@carolinan
carolinan / gist:2b66e074b14d2cf73ad19e002540b436
Created February 26, 2022 08:36
filter block transforms
const { addFilter } = wp.hooks;
const { assign, merge } = lodash;
const { createBlock } = wp.blocks;
function filter(settings) {
return assign({}, settings, {
transforms: merge(settings.transforms, {
from: [
{
type: 'block',
@tangrufus
tangrufus / settings-api-tabs-demo.php
Created July 26, 2014 07:58
Adding Tabs with Settings API
<?php
/*
* Plugin Name: Settings API Tabs Demo
* Plugin URI: http://theme.fm/?p=
* Description: This is a demo showing off usage of tabs with the WordPress Settings API
* Version: 1.0
* Author: kovshenin
* Author URI: http://theme.fm
* License: GPL2
*/
@JadedDragoon
JadedDragoon / svg-inliner.php
Last active May 5, 2022 12:29
WordPress filter to convert image tags for locally-hosted SVG files into inline SVG (and thus enabling the SVG to be styled with CSS)
<?php
/*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
@romanpamula
romanpamula / functions.php
Last active August 8, 2022 07:53
Adds product's stock quantity on admin order detail page
<?php
/**
* Adds product's stock quantity on admin order detail page in WooCommerce
*
* Snippet updated on 18/9/2021 for compatibility with PHP 8
*
* @since 3.0.0
* @see https://pamula.sk/woocommerce-ako-zobrazit-pocet-produktov-na-sklade-v-detaile-objednavky/
*
* Please REMOVE the opening <?php tag before placing into functions.php
@lynt-smitka
lynt-smitka / proxytest.php
Last active August 17, 2022 10:53
Small script to detect reverse proxy
<html>
<body>
<script>
var serverport = '<?php echo intval($_SERVER['SERVER_PORT']);?>';
var browserport = window.location.port || (window.location.protocol === 'https:' ? '443' : '80');
var color = (serverport === browserport ? 'green' : 'red');
var text = "<pre style='color:#color'>Server port: "+serverport+"<br>Browser port: "+browserport+"</pre>";
document.write(text.replace("#color",color));
</script>
<pre>
@Niq1982
Niq1982 / flywheel-local-xdebug-vscode.md
Last active December 17, 2022 09:33
WordPress debugging with XDebug on Flywheel Local & VSCode

Flywheel Local configuration

Flywheel Local has XDebug installed by default if you choose “Custom” instead of “Preferred” when setting up a new local environment. If you don’t know which your current site is running, you can detect it by going to ”Site Setup” tab. If you can change the PHP version there, you have the “Custom” environment running. If not, just export your site, import it back and choose “Custom”.

Now that we have the right environment, remember what PHP version you are running, open the right PHP settings file (for example /Local Sites/my_site/conf/php/7.0.3/php.ini) and add these lines in the [Xdebug] section:

xdebug.remote_enable=1
xdebug.remote_autostart=1

Save the php.ini and restart your site container in Flywheel to apply new settings.