Skip to content

Instantly share code, notes, and snippets.

View ibndawood's full-sized avatar
💭
I may be slow to respond.

Kader Ibrahim S ibndawood

💭
I may be slow to respond.
View GitHub Profile
@ibndawood
ibndawood / MyHelper.php
Created March 21, 2013 08:58
Accessing a View function in a helper. The current view object is stored in the _View attribute of the Helper class is extended by AppHelper and all other Helpers in CakePHP. $this->assign is a view function and if you want to use this view function in a Helper this is how we use it :
<?php
App::uses('AppHelper', 'View/Helper');
class MyHelper extends AppHelper{
public function assignTitle($pageTitle){
return $this->_View->assign('pageTitle', $pageTitle);
}
}
?>
@ibndawood
ibndawood / functions.php
Last active August 29, 2015 14:14
Add to Cart button for Catalog Mode : MediaCenter Wordpress Theme
function catalog_mode_add_to_cart_link( $link, $product ){
global $media_center_theme_options, $woocommerce_loop;
$product_item_size = isset( $woocommerce_loop['product_item_size'] ) ? $woocommerce_loop['product_item_size'] : $media_center_theme_options['product_item_size'];
$btn_classes = 'le-button';
$btn_classes .= ( $product_item_size == 'size-big' ) ? 'big' : '';
if ( ( isset( $media_center_theme_options['catalog_mode'] ) ) && ( $media_center_theme_options['catalog_mode'] == 1 ) ) {
$link = '<div class="add-cart-button"><a href="'. $product->get_permalink() . '" rel="nofollow" class="' . $btn_classes . '">View Product</a></div>';
@ibndawood
ibndawood / functions.php
Created April 7, 2015 04:47
Show price only to Registered Users
add_filter( 'woocommerce_get_price_html', 'show_price_only_to_registered_users', PHP_INT_MAX );
function show_price_only_to_registered_users( $price ) {
if( ! is_user_logged_in() ){
return __( 'Please register to view prices', 'theme_name' );
} else {
return $price;
}
}
@ibndawood
ibndawood / functions.php
Created May 15, 2015 07:12
Changing "Shop By Department" in MediaCenter Wordpress Theme
add_filter( 'mc_shop_by_department', 'mc_change_shop_by_department', PHP_INT_MAX );
function mc_change_shop_by_department(){
return 'Shop Categories'; // Your custom text here
}
@ibndawood
ibndawood / style.css
Created May 19, 2015 06:44
MediaCenter WP: Changing the color of product title
.product-title > a, .product-title > a:hover, .product-title > a:focus, .product-title > a:active{
color: #00FF00;
}
@ibndawood
ibndawood / functions.php
Last active September 9, 2015 13:54
Displaying Stock availability like product labels
add_action( 'woocommerce_before_shop_loop_item_title', 'mc_make_availability_like_ribbon', 25 );
function mc_make_availability_like_ribbon() {
global $product;
$availability = $product->get_availability();
$stock_status = $availability['class'];
if( $stock_status == 'out-of-stock' ) {
$label = __( 'Out of Stock', 'mediacenter' ) ;
@ibndawood
ibndawood / functions.php
Last active October 13, 2017 14:25
Enqueuing Custom color in child theme
add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX);
function enqueue_child_theme_styles() {
wp_dequeue_style( 'media_center-preset-color' );
wp_enqueue_style( 'child-custom-style', get_stylesheet_directory_uri() . '/assets/css/custom-color.css', array('media_center-main-style') );
}
@ibndawood
ibndawood / functions.php
Created September 17, 2015 12:49
Removing Out of Stock items in Live Search
function woocommerce_products_live_search(){
if ( isset( $_REQUEST['fn'] ) && 'get_ajax_search' == $_REQUEST['fn'] ) {
$query_args = array(
'posts_per_page' => 10,
'no_found_rows' => true,
'post_type' => 'product',
);
if( isset( $_REQUEST['terms'] ) ) {
@ibndawood
ibndawood / functions.php
Last active June 3, 2019 06:45
Changing "Our Charity Store" text in footer
function mybeth_change_charity_store_text() {
return esc_html__( 'Our Custom Store Text', 'bethlehem' );
}
add_filter( 'our_store_carousel_title', 'mybeth_change_charity_store_text' );
@ibndawood
ibndawood / functions.php
Created September 22, 2015 14:59
Change "See the Archive" text
<?php
add_filter( 'blog_archive_link_text', 'beth_child_change_archive_link_text' );
function beth_child_change_archive_link_text( $text ) {
return __( 'Your Text', 'bethlehem' );
}