D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
homehopshortterm
/
public_html
/
wp-content
/
themes
/
pixwell
/
includes
/
Filename :
core.php
back
Copy
<?php /** Don't load directly */ defined( 'ABSPATH' ) || exit; if ( ! function_exists( 'rb_get_term_meta' ) ) { function rb_get_term_meta( $key, $term_id = null ) { if ( empty( $term_id ) ) { $term_id = get_queried_object_id(); } // get meta fields from option table $metas = get_metadata( 'term', $term_id, $key, true ); /** fallback */ if ( empty( $metas ) ) { $metas = get_option( $key ); $metas = isset( $metas[ $term_id ] ) ? $metas[ $term_id ] : []; } if ( empty( $metas ) || ! is_array( $metas ) ) { return []; } return $metas; } } /** check AMP */ if ( ! function_exists( 'pixwell_is_amp' ) ) { function pixwell_is_amp() { return function_exists( 'amp_is_request' ) && amp_is_request(); } } if ( ! function_exists( 'pixwell_get_option' ) ) { function pixwell_get_option( $option_name = '' ) { $settings = get_option( 'pixwell_theme_options', [] ); if ( empty( $option_name ) ) { return $settings; } elseif ( isset( $settings[ $option_name ] ) ) { return $settings[ $option_name ]; } return false; } } if ( ! function_exists( 'pixwell_set_tos_defaults' ) ) { function pixwell_set_tos_defaults() { /** disable default elementor schemes */ update_option( 'elementor_disable_color_schemes', 'yes' ); update_option( 'elementor_disable_typography_schemes', 'yes' ); $current = get_option( 'pixwell_theme_options', [] ); $file = get_theme_file_path( 'backend/assets/defaults.json' ); if ( ! file_exists( $file ) || ! empty( $current ) ) { return false; } ob_start(); include $file; $response = ob_get_clean(); $data = json_decode( $response, true ); if ( is_array( $data ) ) { set_transient( '_ruby_old_settings', $current, 30 * 86400 ); update_option( 'pixwell_theme_options', $data ); } return false; } } if ( ! function_exists( 'pixwell_convert_to_id' ) ) { function pixwell_convert_to_id( $name ) { $name = strtolower( strip_tags( $name ) ); $name = str_replace( ' ', '-', $name ); return preg_replace( '/[^A-Za-z0-9\-]/', '', $name ); } } /** * @param $meta * @param $post_id * * @return bool * fallback if don't active plugin */ if ( ! function_exists( 'rb_get_meta' ) ) { function rb_get_meta( $meta = null, $post_id = null ) { return false; } } /** get protocol */ if ( ! function_exists( 'pixwell_protocol' ) ) { function pixwell_protocol() { if ( ! is_ssl() ) { return 'http'; } return 'https'; } } /** show over k */ if ( ! function_exists( 'pixwell_show_over_k' ) ) { function pixwell_show_over_k( $number ) { $number = intval( $number ); if ( $number > 999999 ) { $number = str_replace( '.00', '', number_format( ( $number / 1000000 ), 2 ) ) . esc_attr__( 'M', 'pixwell' ); } elseif ( $number > 999 ) { $number = str_replace( '.0', '', number_format( ( $number / 1000 ), 1 ) ) . esc_attr__( 'k', 'pixwell' ); } return $number; } } if ( ! function_exists( 'wp_body_open' ) ) { function wp_body_open() { do_action( 'wp_body_open' ); } } if ( ! function_exists( 'pixwell_getimagesize' ) ) { /** * @param $image * * @return array|false */ function pixwell_getimagesize( $image ) { if ( empty( $image ) ) { return false; } return @getimagesize( $image ); } } if ( ! function_exists( 'pixwell_get_theme_mode' ) ) { /** * @return string */ function pixwell_get_theme_mode() { $dark_mode = pixwell_get_option( 'dark_mode' ); if ( empty( $dark_mode ) || 'browser' === $dark_mode ) { return 'default'; } elseif ( 'dark' === $dark_mode ) { return 'dark'; } $is_cookie_mode = (string) pixwell_get_option( 'dark_mode_cookie' ); if ( '1' === $is_cookie_mode ) { $id = pixwell_get_dark_mode_id(); if ( ! empty( $_COOKIE[ $id ] ) ) { return $_COOKIE[ $id ]; } } $first_visit_mode = pixwell_get_option( 'first_visit_mode' ); if ( empty( $first_visit_mode ) ) { $first_visit_mode = 'default'; } return $first_visit_mode; } } if ( ! function_exists( 'pixwell_calc_crop_sizes' ) ) { /** * @return array[] */ function pixwell_calc_crop_sizes() { $crop = true; $settings = get_option( 'pixwell_theme_options', [] ); if ( ! empty( $settings['pos_feat'] ) && ( 'top' === $settings['pos_feat'] ) ) { $crop = [ 'center', 'top' ]; } $sizes = [ 'pixwell_370x250' => [ 370, 250, $crop ], 'pixwell_370x250-2x' => [ 740, 500, $crop ], 'pixwell_370x250-3x' => [ 1110, 750, $crop ], 'pixwell_280x210' => [ 280, 210, $crop ], 'pixwell_280x210-2x' => [ 560, 420, $crop ], 'pixwell_400x450' => [ 400, 450, $crop ], 'pixwell_400x600' => [ 400, 600, $crop ], 'pixwell_450x0' => [ 450, 0, $crop ], 'pixwell_780x0' => [ 780, 0, $crop ], 'pixwell_780x0-2x' => [ 1600, 0, $crop ], ]; foreach ( $sizes as $crop_id => $size ) { if ( empty( $settings[ $crop_id ] ) ) { unset( $sizes[ $crop_id ] ); } } if ( ! empty( $settings['featured_crop_sizes'] ) && is_array( $settings['featured_crop_sizes'] ) ) { foreach ( $settings['featured_crop_sizes'] as $custom_size ) { if ( ! empty( $custom_size ) ) { $custom_size = preg_replace( '/\s+/', '', $custom_size );; $hw = explode( 'x', $custom_size ); if ( isset( $hw[0] ) && isset( $hw[1] ) ) { $crop_id = 'pixwell_' . $custom_size; $sizes[ $crop_id ] = [ absint( $hw[0] ), absint( $hw[1] ), $crop ]; } } } } return $sizes; } }