Skip to content

Instantly share code, notes, and snippets.

Avatar

Karolína Vyskočilová vyskoczilova

View GitHub Profile
View wp-simple-localization.php
<?php
function lynt_is_en() {
$path_parts = explode('/', $_SERVER['REQUEST_URI']);
if (isset($path_parts[1]) && $path_parts[1] === 'en') {
return true;
}
View render-reusable-block.php
<?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() ) {
/**
@jenssogaard
jenssogaard / ACF Gutenberg get block fields
Created Feb 22, 2019
Helper class for ACF and Gutenberg. Get blocks fields by passing block_id and post_id.
View ACF Gutenberg get block fields
<?php
namespace JensSogaard;
class BlockHelper
{
/**
* Gets ACF fields for a specific block on a given post
* @author Jens Soegaard <jens@jenssogaard.com>
*/
public function getBlockFromPage(string $block_id, int $post_id)
@mailenkno
mailenkno / gutenberg-sample-content.html
Last active Apr 8, 2021
WordPress Gutenberg Sample Content
View gutenberg-sample-content.html
<!-- wp:paragraph {"align":"center","customTextColor":"#000000","backgroundColor":"very-light-gray","fontSize":"small"} -->
<p style="color:#000000;text-align:center" class="has-background has-small-font-size has-very-light-gray-background-color">Gutenberg Sample Content.<br/>Put together with ❤️ by <a href="https://artisanthemes.io/">Artisan Themes</a>.</p>
<!-- /wp:paragraph -->
<!-- wp:heading {"level":1} -->
<h1>This is a heading (H1)</h1>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>This is a heading (H2)</h2>
@JadedDragoon
JadedDragoon / svg-inliner.php
Last active Oct 1, 2020
WordPress filter to convert image tags for locally-hosted SVG files into inline SVG (and thus enabling the SVG to be styled with CSS)
View svg-inliner.php
<?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
Created Aug 7, 2018
Small script to detect reverse proxy
View proxytest.php
<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>
View bradvin.social.share.urls.txt
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 Mar 31, 2018
Adds product's stock quantity on admin order detail page
View functions.php
<?php
/**
* Adds product's stock quantity on admin order detail page in WooCommerce
* @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
* Prosim ODSTRANTE otvaraciu <?php znacku pred umiestnenim do functions.php
*/
@Niq1982
Niq1982 / flywheel-local-xdebug-vscode.md
Last active May 24, 2020
WordPress debugging with XDebug on Flywheel Local & VSCode
View flywheel-local-xdebug-vscode.md

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 Mar 8, 2021
Pass current UTMS to in page links Javascript
View passUTM.js
// 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;