Файловый менеджер - Редактировать - /home2/cocinasdalloway/public_html/tienda/wp-content/themes/negan/framework/functions/update.php
Назад
<?php /** * This function allow get property of `woocommerce_loop` inside the loop * @since 1.1.7 * @param string $prop Prop to get. * @param string $default Default if the prop does not exist. * @return mixed */ if(!function_exists('negan_get_wc_loop_prop')){ function negan_get_wc_loop_prop( $prop, $default = ''){ return isset( $GLOBALS['woocommerce_loop'], $GLOBALS['woocommerce_loop'][ $prop ] ) ? $GLOBALS['woocommerce_loop'][ $prop ] : $default; } } /** * This function allow set property of `woocommerce_loop` * @since 1.1.7 * @param string $prop Prop to set. * @param string $value Value to set. */ if(!function_exists('negan_set_wc_loop_prop')){ function negan_set_wc_loop_prop( $prop, $value = ''){ if(isset($GLOBALS['woocommerce_loop'])){ $GLOBALS['woocommerce_loop'][ $prop ] = $value; } } } /** * This function allow get property of `negan_loop` inside the loop * @since 1.1.7 * @param string $prop Prop to get. * @param string $default Default if the prop does not exist. * @return mixed */ if(!function_exists('negan_get_theme_loop_prop')){ function negan_get_theme_loop_prop( $prop, $default = ''){ return isset( $GLOBALS['negan_loop'], $GLOBALS['negan_loop'][ $prop ] ) ? $GLOBALS['negan_loop'][ $prop ] : $default; } } remove_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' ); if(!function_exists('negan_override_woothumbnail_size')){ function negan_override_woothumbnail_size( $size ) { if(!function_exists('wc_get_theme_support')){ return $size; } $size['width'] = absint( wc_get_theme_support( 'gallery_thumbnail_image_width', 100 ) ); $cropping = get_option( 'woocommerce_thumbnail_cropping', '1:1' ); if ( 'uncropped' === $cropping ) { $size['height'] = 0; $size['crop'] = 0; } elseif ( 'custom' === $cropping ) { $width = max( 1, get_option( 'woocommerce_thumbnail_cropping_custom_width', '4' ) ); $height = max( 1, get_option( 'woocommerce_thumbnail_cropping_custom_height', '3' ) ); $size['height'] = absint( round( ( $size['width'] / $width ) * $height ) ); $size['crop'] = 1; } else { $cropping_split = explode( ':', $cropping ); $width = max( 1, current( $cropping_split ) ); $height = max( 1, end( $cropping_split ) ); $size['height'] = absint( round( ( $size['width'] / $width ) * $height ) ); $size['crop'] = 1; } return $size; } add_filter('woocommerce_get_image_size_gallery_thumbnail', 'negan_override_woothumbnail_size'); } if(!function_exists('negan_override_filter_woocommerce_format_content')){ function negan_override_filter_woocommerce_format_content( $format, $raw_string ){ $format = preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $raw_string); return apply_filters( 'woocommerce_short_description', $format ); } add_filter('woocommerce_format_content', 'negan_override_filter_woocommerce_format_content', 99, 2); } if(!function_exists('negan_wc_product_loop')){ function negan_wc_product_loop(){ if(!function_exists('WC')){ return false; } return have_posts() || 'products' !== woocommerce_get_loop_display_mode(); } } if(!function_exists('negan_add_ajax_cart_btn_into_single_product')){ function negan_add_ajax_cart_btn_into_single_product(){ global $product; if($product->is_type('simple')){ echo '<div class="wrap-single-addcart hidden">'; woocommerce_template_loop_add_to_cart(); echo '</div>'; } } add_action('woocommerce_after_add_to_cart_button', 'negan_add_ajax_cart_btn_into_single_product'); } if(!function_exists('negan_add_url_to_dropdown_product_category_widget')){ function negan_add_url_to_dropdown_product_category_widget( $output, $r ){ if( isset($r['taxonomy']) && $r['taxonomy'] == 'product_cat' ){ $output = preg_replace_callback( '~<option.*?value=["\']+(.*?)["\']+~', function( $match ){ $return = $match[0]; if(!empty($match[1])){ $url = get_term_link($match[1], 'product_cat'); if(!is_wp_error($url)){ $return .= ' data-url="'. esc_attr($url) .'"'; } } return $return; }, $output ); } return $output; } add_filter('wp_dropdown_cats', 'negan_add_url_to_dropdown_product_category_widget', 20, 2); } add_filter('woocommerce_single_product_flexslider_enabled', '__return_true'); add_action( 'wp_ajax_lastudio_ig_feed', 'negan_ajax_get_ig_feed' ); add_action( 'wp_ajax_nopriv_lastudio_ig_feed', 'negan_ajax_get_ig_feed' ); if(!function_exists('negan_ajax_get_ig_feed')){ function negan_ajax_get_ig_feed(){ // check token first; $token = Negan()->settings->get('instagram_token', ''); if(empty($token)){ wp_send_json_error(['msg' => __('Invalid Token', 'negan')]); } $life_time = get_transient('lastudio_ig_token'); if(empty($life_time)){ $ig_refresh_token_url = add_query_arg([ 'grant_type' => 'ig_refresh_token', 'access_token' => $token ], 'https://graph.instagram.com/refresh_access_token'); $response = wp_remote_get($ig_refresh_token_url); // request failed if ( is_wp_error( $response ) ) { wp_send_json_error(['msg' => __('Invalid Token [1]', 'negan')]); } $code = (int) wp_remote_retrieve_response_code( $response ); if ( $code !== 200 ) { wp_send_json_error(['msg' => __('Invalid Token [2]', 'negan')]); } $body = wp_remote_retrieve_body($response); $body = json_decode($body, true); $expires_in = (int) $body['expires_in'] - DAY_IN_SECONDS; if($expires_in > 0){ $token = $body['access_token']; $all_option = get_option(Negan::get_option_name(), []); $all_option['instagram_token'] = $token; update_option(Negan::get_option_name(), $all_option); set_transient('lastudio_ig_token', $body , $expires_in); } else{ wp_send_json_error(['msg' => __('Token Expired [3]', 'negan')]); } } $cache = get_transient('lastudio_ig_feed'); if(empty($cache)){ $ig_feed_url = add_query_arg([ 'fields' => 'caption,media_type,media_url,thumbnail_url,permalink,timestamp', 'access_token' => $token, 'limit' => 20 ], 'https://graph.instagram.com/me/media'); $response = wp_remote_get($ig_feed_url); if ( is_wp_error( $response ) ) { wp_send_json_error(['msg' => __('Invalid Token [4]', 'negan')]); } $code = (int) wp_remote_retrieve_response_code( $response ); if ( $code !== 200 ) { wp_send_json_error(['msg' => __('Invalid Token [5]', 'negan')]); } $data = wp_remote_retrieve_body($response); $data = json_decode($data, true); $cache = $data['data']; set_transient('lastudio_ig_feed', $cache, HOUR_IN_SECONDS * 12); } if(empty($cache)){ wp_send_json_error(['msg' => __('Invalid Token [6]', 'negan')]); } else{ wp_send_json_success($cache); } } } add_action('woocommerce_init', function (){ remove_action( 'woocommerce_before_shop_loop','woocommerce_catalog_ordering', 30 ); remove_action( 'woocommerce_before_shop_loop','woocommerce_result_count', 30 ); }, 100); // Disables the block editor from managing widgets in the Gutenberg plugin. add_filter( 'gutenberg_use_widgets_block_editor', '__return_false', 100 ); // Disables the block editor from managing widgets. add_filter( 'use_widgets_block_editor', '__return_false' );
| ver. 1.4 |
Github
|
.
| PHP 8.2.22 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка