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; } }