Skip to content

Instantly share code, notes, and snippets.

View vyskoczilova's full-sized avatar

Karolína Vyskočilová vyskoczilova

View GitHub Profile
@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.
*/
@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>
@HoldOffHunger
HoldOffHunger / bradvin.social.share.urls.txt
Last active April 18, 2024 13:41
Social Share URL's (Summary)
https://www.facebook.com/sharer.php?u={url}
https://www.facebook.com/dialog/share?app_id={app_id}&display={page_type}&href={url}&redirect_uri={redirect_url}
https://reddit.com/submit?url={url}&title={title}
https://twitter.com/intent/tweet?url={url}&text={title}&via={user_id}&hashtags={hash_tags}
https://www.linkedin.com/sharing/share-offsite/?url={url}
https://api.whatsapp.com/send?phone={phone_number}&text={title}%20{url}
https://www.tumblr.com/widgets/share/tool?canonicalUrl={url}&title={title}&caption={text}&tags={hash_tags}
http://pinterest.com/pin/create/button/?url={url}
https://www.blogger.com/blog-this.g?u={url}&n={title}&t={text}
https://www.evernote.com/clip.action?url={url}&title={title}
@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
@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.

@dillansimmons
dillansimmons / passUTM.js
Last active January 11, 2024 18:00
Pass current UTMS to in page links Javascript
// JS for grabbing utm params and parsing into url
var getRefQueryParam = function() {
var temp = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
var decode = function(s) {
return decodeURIComponent(s.split("+").join(" "));
};
temp[decode(arguments[1])] = decode(arguments[2]);
});
return temp;
@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:
@rynaldos-zz
rynaldos-zz / wc-custom-purchased-column.php
Last active June 15, 2020 06:26
[WooCommerce 3.0+] Re-instate the "Purchased items" column on orders page
add_filter('manage_edit-shop_order_columns', 'wc_custom_purchased_column');
function wc_custom_purchased_column($columns)
{
$new_array = array();
foreach ($columns as $key => $title) {
if ($key == 'billing_address') {
$new_array['order_items'] = __('Purchased', 'woocommerce');
}
@gilzow
gilzow / put-inside-functions.php
Created January 5, 2017 17:03
Removes user endpoints from WordPress REST API
<?php
/**
* Remove user list endpoint from rest api
*/
add_filter('rest_endpoints', function($aryEndpoints){
if(isset($aryEndpoints['/wp/v2/users'])){
unset($aryEndpoints['/wp/v2/users']);
}
if(isset($aryEndpoints['/wp/v2/users/(?P<id>[\d]+)'])){
unset($aryEndpoints['/wp/v2/users/(?P<id>[\d]+)']);
@danwellman
danwellman / .jshintrc
Last active March 5, 2018 13:51 — forked from ScheerMT/.jshintrc
JSHint configuration as of v2.9.3 - Strict Settings with some exceptions made. Settings marked as deprecated were *not* included in order to futureproof for newer versions.
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for JSHint[1] setting
// config values to be most strict:
//
// * set all enforcing options to true
// * set all relaxing options to false