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 / footer.php.html
Created September 30, 2018 19:19 — forked from ajtroxell/footer.php.html
Using Magnific Popup with Wordpress Now, from: http://ajtroxell.com/using-magnific-popup-with-wordpress-now/
@smjuber
smjuber / gist:96e5d37ae2e218e07221d540dc9f4fcc
Created September 30, 2018 20:02 — forked from gam3ov3r/gist:2724041
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

<?php
// Numeric Page Navigation
function bones_page_navi() {
global $wp_query;
$bignum = 999999999;
if ( $wp_query->max_num_pages <= 1 )
return;
echo '<nav class="pagination">';
@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/
@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 / 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
==================
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 / README.md
Created March 4, 2020 15:39 — forked from ControlledChaos/README.md
Sanitization of WordPress Customizer controls

Sanitize the WordPress Customizer

WordPress Snippets

@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() {