Skip to content

Instantly share code, notes, and snippets.

View smjuber's full-sized avatar
🙂
Howdy, Stranger.

Mehadi Hasan Juber smjuber

🙂
Howdy, Stranger.
View GitHub Profile
@smjuber
smjuber / repair-mysql-data.ps1
Created October 28, 2020 16:59 — forked from josemmo/repair-mysql-data.ps1
Repair MySQL data directory (for XAMPP)
# Based on this answer: https://stackoverflow.com/a/61859561/1956278
# Backup old data
Rename-Item -Path "./data" -NewName "./data_old"
# Create new data directory
Copy-Item -Path "./backup" -Destination "./data" -Recurse
Remove-Item "./data/test" -Recurse
$dbPaths = Get-ChildItem -Path "./data_old" -Exclude ('mysql', 'performance_schema', 'phpmyadmin') -Recurse -Directory
Copy-Item -Path $dbPaths.FullName -Destination "./data" -Recurse
@devinsays
devinsays / post-type-metaboxes.php
Last active June 4, 2022 06:34
Example code shows how to register a post type and add basic metaboxes.
<?php
/**
* Example code for tutorial post on custom meta boxes:
* https://wptheming.com/2010/08/custom-metabox-for-post-type/
*/
/**
* Registers the event post type.
*/
function wpt_event_post_type() {
@weartstudio
weartstudio / sanitize.php
Last active September 10, 2022 08:55
WordPress: Sanitize elements for WP Customizr. Sanitize functions. Image upload, adsense box, checkbox, text, select
<?php
//sanitize adsense box adsense codes
function weart_sanitize_adsense( $input ) {
esc_js($input);
$input = str_replace(array("\r", "\n"), '', $input);
return $input;
}
//sanitize checkbox
File path for a pre WordPress 4.7 asset:
<img src="<?php echo get_template_directory_uri(); ?>/images/filename.png" />
File path for a WordPress 4.7 + asset:
<img src="<?php echo get_theme_file_uri( ‘/images/filename.png’ ); ?>" />
if(!function_exists('get_theme_file_uri')){
function get_theme_file_uri( $file = '' ) {
$file = ltrim( $file, '/' );
if ( empty( $file ) ) {
$url = get_stylesheet_directory_uri();
} elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$url = get_stylesheet_directory_uri() . '/' . $file;
} else {
$url = get_template_directory_uri() . '/' . $file;
}
@morgyface
morgyface / social-share.php
Last active September 26, 2018 15:54
WordPress | Social Share Buttons
<style>
div.social-share {position:absolute; bottom:0; right:0; text-align:center}
div.social-share h5 {font-size:0.875em; color:#333; text-transform:uppercase; margin:0}
div.social-share ul {padding:0; margin:0; list-style:none; font-size:2em}
div.social-share ul li {display:inline-block; margin-right:0.375em}
div.social-share ul li:last-child {margin:0}
div.social-share ul li a span {display:none}
div.social-share ul li a {text-decoration:none}
/* Change links to official colours */
div.social-share ul li.facebook a {color:#3b5998}
@ControlledChaos
ControlledChaos / README.md
Last active September 21, 2023 05:54 — forked from saas786/sanitize_checkbox.php
Sanitization of WordPress Customizer controls

Sanitize the WordPress Customizer

WordPress Snippets

@taoyuan
taoyuan / npm-using-https-for-git.sh
Last active May 27, 2024 16:32
Force git to use https:// instead of git://
# npm using https for git
git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://
# npm using git for https
git config --global url."git@github.com:".insteadOf https://github.com/
git config --global url."git://".insteadOf https://
@themepaint
themepaint / Woocommerce Price Filter CSS
Created February 2, 2016 08:20
Woocommerce Price Filter CSS
.price_slider{
margin-bottom: 1em;
}
.price_slider_amount {
text-align: right;
line-height: 2.4em;
font-size: 0.8751em;
}