Skip to content

Instantly share code, notes, and snippets.

View waylay's full-sized avatar
🏠
Working from home

Cristian Ionel waylay

🏠
Working from home
  • WCD
  • Brno, Czech Republic
  • X @waylay
View GitHub Profile
@waylay
waylay / social-sharing.php
Created January 19, 2017 08:26
Social sharing without JS
<div class="social-sharing">
<?php
$link = urlencode(get_permalink());
?>
<ul>
<li>Share this on...</li>
<li class="twitter"><a href="https://twitter.com/intent/tweet?url=<?php echo $link; ?>" target="_blank">Twitter</a></li>
<li class="facebook"><a href="https://facebook.com/sharer.php?u=<?php echo $link; ?>" target="_blank">Facebook</a></li>
<li class="google-plus"><a href="https://plus.google.com/share?url=<?php echo $link; ?>" target="_blank">Google+</a></li>
<li class="linkedin"><a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php echo $link; ?>" target="_blank">LinkedIn</a></li>
@waylay
waylay / debug.php
Created November 1, 2016 15:03
Quick Debug
<?php
if (!function_exists('dd')) {
function dd()
{
$args = func_get_args();
echo "<script>";
echo "console.log(".json_encode($args).")";
echo "</script>";
}
}
@waylay
waylay / customizer.php
Last active August 28, 2016 18:57
Add Logo Upload field in WordPress Customizer
<?php
/**
* Create Logo Setting and Upload Control
* Namespaced for Sage Usage
*/
function add_header_logo_settings($wp_customize) {
// add a setting for the site logo
$wp_customize->add_setting('header_logo');
// Add a control to upload the logo
$wp_customize->add_control( new \WP_Customize_Image_Control( $wp_customize, 'header_logo',
@waylay
waylay / search_and_replace.html
Created August 17, 2016 19:24
Search & Replace SQL Generator for changing WordPress URLs
<div>Old Url:</div> http://<input id="old_url" name="old_url" type="text" value="old_url" onchange="replaceMyText()" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>
<div>New Url:</div> http://<input id="new_url" name="new_url" type="text" value="new_url" onchange="replaceMyText()" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>
<div id="haystack">
UPDATE wp_options SET option_value = replace(option_value, 'http://old_url', 'http://new_url') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://old_url','http://new_url');
UPDATE wp_posts SET post_content = replace(post_content, 'http://old_url', 'http://new_url');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://old_url','http://new_url');
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old_url', 'http://new_url') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = repl