This file contains hidden or 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 | |
// vars | |
$hero = get_field('hero'); | |
if( $hero ): ?> | |
<div id="hero"> | |
<img src="<?php echo $hero['image']['url']; ?>" alt="<?php echo $hero['image']['alt']; ?>" /> | |
<div class="content"> | |
<?php echo $hero['caption']; ?> |
This file contains hidden or 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 | |
// Stop if there's nothing to display. | |
if ( ! have_rows( 'services', 'option' ) ) { | |
return false; | |
} | |
if ( have_rows( 'services', 'option' ) ) : ?> | |
<?php while ( have_rows( 'services', 'option' ) ) : the_row(); |
This file contains hidden or 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 | |
$type = 'custom_post_type'; | |
$args = array( | |
'post_type' => $type, | |
'post_status' => 'publish', | |
'posts_per_page' => -1, | |
'ignore_sticky_posts'=> true | |
); | |
$my_query = null; | |
$my_query = new WP_Query($args); |
This file contains hidden or 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
function slug($str){ | |
$str = strtolower(trim($str)); | |
$str = preg_replace('/[^a-z0-9-]/', '-', $str); | |
$str = preg_replace('/-+/', "-", $str); | |
return $str; | |
} |
This file contains hidden or 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
$terms = get_the_terms( $post->ID, 'taxonomy-name' ); | |
if( $terms ){ | |
$term = array_shift( $terms ); | |
// echo name or slug | |
echo $term->name; //or | |
echo $term->slug; | |
} |
This file contains hidden or 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
// Поддержка Open Graph в WordPress | |
function add_opengraph_doctype( $output ) { | |
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"'; | |
} | |
add_filter('language_attributes', 'add_opengraph_doctype'); | |
function insert_fb_in_head() { | |
global $post; | |
if ( !is_singular()) | |
return; | |
echo '<meta property="fb:admins" content="Ваш ID в Facebook"/>'; |
This file contains hidden or 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
//http://epsiloncool.ru/programmirovanie/preventing-multiple-submits-in-contact-form-7 | |
jQuery(document).on('click', '.wpcf7-submit', function(e){ | |
if( jQuery('.ajax-loader').hasClass('is-active') ) { | |
e.preventDefault(); | |
return false; | |
} | |
}); |
This file contains hidden or 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
<img src="data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" data-src="your-image-here"> | |
<script> | |
function init() { | |
var imgDefer = document.getElementsByTagName('img'); | |
for (var i=0; i<imgDefer.length; i++) { | |
if(imgDefer[i].getAttribute('data-src')) { | |
imgDefer[i].setAttribute('src',imgDefer[i].getAttribute('data-src')); | |
} } } | |
window.onload = init; |
This file contains hidden or 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
function wc_get_customer_orders() { | |
// Get all customer orders | |
$customer_orders = get_posts( array( | |
'numberposts' => -1, | |
'meta_key' => '_customer_user', | |
'meta_value' => get_current_user_id(), | |
'post_type' => wc_get_order_types(), | |
'post_status' => array_keys( wc_get_order_statuses() ), | |
) ); |
This file contains hidden or 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
add_action('http_api_curl', 'sar_custom_curl_timeout', 9999, 1); | |
function sar_custom_curl_timeout( $handle ){ | |
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 60 ); // 30 seconds. Too much for production, only for testing. | |
curl_setopt( $handle, CURLOPT_TIMEOUT, 60 ); // 30 seconds. Too much for production, only for testing. | |
} | |
// Setting custom timeout for the HTTP request | |
add_filter( 'http_request_timeout', 'sar_custom_http_request_timeout', 9999 ); | |
function sar_custom_http_request_timeout( $timeout_value ) { | |
return 60; // 30 seconds. Too much for production, only for testing. | |
} |