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
@smjuber
smjuber / script.js
Last active September 21, 2020 20:37
hide a HTML5 video when it finishes playing
onended="videoEnded()";
// To your video tag, and then just have a function videoEnded() hide the video.
// Or with just a jQuery function… I'm writing this without testing, so hopefully it will work-
$('video').on('ended',function(){ $(this).hide(); });
// Thanks, Ended up getting it working with this:
$('#vid2').hide();
$('#vid1').on('ended',function(){
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}
@smjuber
smjuber / post-type-metaboxes.php
Created July 24, 2020 19:37 — forked from devinsays/post-type-metaboxes.php
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() {
@smjuber
smjuber / README.md
Created March 4, 2020 15:39 — forked from ControlledChaos/README.md
Sanitization of WordPress Customizer controls

Sanitize the WordPress Customizer

WordPress Snippets

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’ ); ?>" />
@smjuber
smjuber / ie67891011-css-hacks.txt
Created January 23, 2019 07:30 — forked from ricardozea/ie67891011-css-hacks.txt
IE CSS hacks - IE6, 7, 8, 9, 10, 11
IE6 Only
==================
_selector {...}
IE6 & IE7
==================
*html or { _property: }
IE7 Only
==================
@smjuber
smjuber / sanitize.php
Created October 15, 2018 14:10 — forked from weartstudio/sanitize.php
WordPress: Sanitize elements for WP Customizr. Sanitize functions.
<?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
@smjuber
smjuber / functions.php
Created October 11, 2018 13:24 — forked from srikat/functions.php
How to use Customizer API to add settings for Header background color and background image in Genesis. https://sridharkatakam.com/how-to-use-customizer-api-to-add-settings-for-header-background-color-and-background-image-in-genesis/
/**
* HEX Color sanitization callback.
*
* - Sanitization: hex_color
* - Control: text, WP_Customize_Color_Control
*
* Note: sanitize_hex_color_no_hash() can also be used here, depending on whether
* or not the hash prefix should be stored/retrieved with the hex color value.
*
* @see sanitize_hex_color() https://developer.wordpress.org/reference/functions/sanitize_hex_color/