Skip to content

Instantly share code, notes, and snippets.

View Mamaduka's full-sized avatar

George Mamadashvili Mamaduka

View GitHub Profile
@Mamaduka
Mamaduka / gist:2972170
Created June 22, 2012 11:22
Featured image Open Graph meta tag
<?php
function canvas_featured_open_graph_meta() {
if ( is_single() || is_page() ) {
global $post;
if ( has_post_thumbnail( $post->ID ) )
$thumbnail_id = get_post_thumbnail_id( $post->ID );
if ( ! empty( $thumbnail_id ) ) {
$thumbnail_src = wp_get_attachment_image_src( $thumbnail_id );
@Mamaduka
Mamaduka / gist:2972198
Created June 22, 2012 11:27
Facebook, display logo as image.
<?php
function canvas_logo_open_graph_meta() {
if ( ! is_single() || ! is_page() )
return;
if ( isset($woo_options['woo_logo']) && $woo_options['woo_logo'] )
echo '<meta property="og:image" content="' . esc_url( $woo_options['woo_logo'] ) . '" />';
}
add_action( 'wp_head', 'canvas_logo_open_graph_meta' );
@Mamaduka
Mamaduka / gist:3403629
Created August 20, 2012 12:16
Snippet for WPSE
<?php
// Setting Field with multiple checkboxes
function mamaduka_settings_field() {
$options = get_option( 'georgian_keyboard_options' );
?>
<input name="georgian_keyboard_options[user-element-on-comment]" type="checkbox" id="georgian_keyboard_options[user-element-on-comment]" value="1" <?php checked( 1, $options['user-element-on-comment'] ); ?> />
<span><?php _e( 'Use Georgian when writing in comment field', 'georgiankeyboard' ); ?></span>
<br />
<input name="georgian_keyboard_options[user-element-on-author]" type="checkbox" id="georgian_keyboard_options[user-element-on-author]" value="1" <?php checked( 1, $options['user-element-on-author'] ); ?> />
<span><?php _e( 'Use Georgian when writing in author field', 'georgiankeyboard' ); ?></span>
@Mamaduka
Mamaduka / gist:3958721
Last active October 12, 2015 02:38
Add parent category class to post_class() function
<?php
/**
* Add parent category class to post_class() function
*
* @link http://wordpress.stackexchange.com/q/23259#23260
*/
function mamaduka_add_parent_category_class( $classes, $class, $post_id ) {
foreach ( (array) get_the_category( $post_id ) as $cat ) {
if ( ! empty( $cat->parent ) ) {
$parent_cat = &get_category( $cat->parent );
<?php
/**
* Get Users Purchases
*
* Retrieves a list of all purchases by a specific user.
*
* @access public
* @since 1.0
* @param int|string $user User ID or email address
* @param int $number Number of purchases to retrieve
@Mamaduka
Mamaduka / gist:5146162
Created March 12, 2013 19:29
WooCommerce: Disable Automatic Order Cancelling
<?php
/**
* Disable automatic order cancelling.
*/
add_filter( 'woocommerce_cancel_unpaid_order', '__return_false' );
<?php
/**
* Add specific thumbnail size for posts and pages.
*/
function wysija_set_thumbnail_size() {
$model_config = WYSIJA::get( 'config', 'model' );
// Holds arry of thumbnail sizes
$sizes = $model_config->getValue('thumb_size');
@Mamaduka
Mamaduka / functions.php
Last active December 20, 2015 22:28 — forked from remkus/functions.php
<?php
**/
* How to detect is a certain page template is in use.
*
* @link http://www.wupperpiraten.de/2009/12/is-a-certain-page-template-active/
*/
function is_pagetemplate_active( $pagetemplate = '' ) {
global $wpdb;
if ( empty( $pagetemplate ) )
@Mamaduka
Mamaduka / README.md
Created February 11, 2014 19:13
Setting up Cron on OVH

Because OVH doesn't support URL for Cron, we need to create and add custom PHP file:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://www.lovelysecret.be/wp-cron.php?f8c7891ad19adc
0dde19beb11eb67b2b&action=wysi
ja_cron&process=all');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);