This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Just copy the following code in functions.php file into your theme. | |
*/ | |
add_action('after_setup_theme','window_mag_retina_script'); | |
function window_mag_retina_script(){ | |
wp_enqueue_script( 'retina-js', 'https://cdnjs.cloudflare.com/ajax/libs/retina.js/2.1.3/retina.min.js', array( 'jquery' ), '1.0', true ); | |
} | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Widget_Online_Support extends WP_Widget { | |
/** | |
* Widget constructor. | |
*/ | |
private $options; | |
private $prefix; | |
function __construct() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function prefix_login_form( $login_only = 0 ) { | |
global $user_ID, $user_level, $user_identity; | |
$redirect = site_url(); | |
if ( $user_ID ) : ?> | |
<?php if ( empty( $login_only ) ): ?> | |
<div class="user-login"> | |
<div class="author-avatar"><?php echo get_avatar( $user_ID, $size = '80' ); ?></div> | |
<p class="welcome-text"><?php esc_html_e( 'Welcome', 'window-mag' ); ?> | |
<strong><?php echo $user_identity ?></strong> .</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Works only with wordpress plugin (WP ULike) url: https://wordpress.org/plugins/wp-ulike/ | |
function prefix_get_posts_liked_by_current_user( $user_id = '' ) { | |
if ( function_exists( 'wp_ulike' ) ) { | |
global $wpdb; | |
$result = array(); | |
if ( ! $user_id ) { | |
$user_ID = get_current_user_id(); | |
} | |
$likes = $wpdb->get_results( " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function prefix_lang_object_ids($object_id, $type) { | |
if( is_array( $object_id ) ){ | |
$translated_object_ids = array(); | |
foreach ( $object_id as $id ) { | |
$translated_object_ids[] = apply_filters( 'wpml_object_id', $id, $type, true, $current_language ); | |
} | |
return $translated_object_ids; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('language_attributes', 'aprefix_add_opengraph_doctype'); | |
function aprefix_add_opengraph_doctype( $output ) { | |
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"'; | |
} | |
add_action( 'wp_head', 'prefix_insert_fb_in_head', 5 ); | |
function prefix_insert_fb_in_head() { | |
global $post; | |
if ( !is_singular()) //if it is not a post or a page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'booking_form_calculated_booking_cost', 'prefix_calculate_prices_based_on_cars_count', 10, 3 ); | |
function prefix_calculate_prices_based_on_cars_count( $cost, $book_obj, $posted ) { | |
$additional_cost = 198.6; //Change Cost Here | |
if ( 'public-tour' == get_field( 'oks-tour-type', $book_obj->product->id ) ) { | |
if ( $posted['wc_bookings_field_persons'] >= 1 && $posted['wc_bookings_field_persons'] <= 5 ) { | |
return $cost + $additional_cost; | |
} elseif ( $posted['wc_bookings_field_persons'] >= 6 && $posted['wc_bookings_field_persons'] <= 10 ) { | |
return $cost + ( $additional_cost * 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove Class Filter Without Access to Class Object | |
* | |
* In order to use the core WordPress remove_filter() on a filter added with the callback | |
* to a class, you either have to have access to that class object, or it has to be a call | |
* to a static method. This method allows you to remove filters with a callback to a class | |
* you don't have access to. | |
* | |
* Works with WordPress 1.2+ (4.7+ support added 9-19-2016) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function prefix_egyptian_cities() { | |
$cities = array( | |
'10th of Ramadan', | |
'15th of May', | |
'6th of October', | |
'Abnub', | |
'Abu Hammad', | |
'Abu Hummus', | |
'Abu Kebir', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dev_log( $log_data ) { | |
$log_file_name = "log"; | |
if ( ! file_exists( $log_file_name ) ) { | |
mkdir( $log_file_name, 0777, true ); | |
} | |
$log_file_data = $log_file_name . '/log_' . date( 'd-M-Y' ) . '.log'; | |
file_put_contents( $log_file_data, $log_data . "\n", FILE_APPEND ); | |
} | |
//For wordpress developers: put this function into your plugin or theme (functions.php) and call it to test your data |
OlderNewer