It's that simple:
$os = getOS($_SERVER['HTTP_USER_AGENT']);
echo $os;| //add_action('wp_footer', 'show_template'); | |
| add_action( | |
| 'wp_footer', | |
| function() { | |
| ?> | |
| <script>jQuery( function( $ ) { | |
| // Цепляемся за событие adding_to_cart | |
| $( document.body ).on( 'adding_to_cart', function( event, button ) { | |
| // Выцепляем инициатора события (ссылка/кнопка) | |
| var $btn = $( button[0] ); |
| add_filter( 'wooms_product_save', function($product, $data_api){ | |
| if( empty($data_api['image']['meta']['href']) ){ | |
| $product->set_status('draft'); | |
| } | |
| if( empty($data_api['description']) ){ | |
| $product->set_status('draft'); | |
| } | |
| return $product; | |
| }, 30, 2 ); |
| add_action( 'init', 'register_faq_post_type' ); // register cpt faq | |
| function register_faq_post_type() { | |
| register_post_type( 'faq', | |
| array( | |
| 'labels' => array( | |
| 'name' => 'Frequently Asked Questions', | |
| 'menu_name' => 'FAQ Manager', | |
| 'singular_name' => 'Question', | |
| 'all_items' => 'All Questions' | |
| ), |
| 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. | |
| } |
| 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() ), | |
| ) ); |
| <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; |
| //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; | |
| } | |
| }); |
| // Поддержка 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"/>'; |
| $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; | |
| } |