D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
homehopshortterm
/
www
/
wp-content
/
plugins
/
pixwell-core
/
includes
/
Filename :
core.php
back
Copy
<?php /** Don't load directly */ defined( 'ABSPATH' ) || exit; 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_is_amp' ) ) { function pixwell_is_amp() { return function_exists( 'amp_is_request' ) && amp_is_request(); } } if ( ! class_exists( 'Rb_Category_Select_Walker', false ) ) { /** * Class Rb_Category_Select_Walker */ class Rb_Category_Select_Walker extends Walker { var $tree_type = 'category'; var $cat_array = []; var $db_fields = [ 'id' => 'term_id', 'parent' => 'parent', ]; public function start_lvl( &$output, $depth = 0, $args = [] ) { } public function end_lvl( &$output, $depth = 0, $args = [] ) { } public function start_el( &$output, $object, $depth = 0, $args = [], $current_object_id = 0 ) { $this->cat_array[ str_repeat( ' - ', $depth ) . $object->name . ' - [ ID: ' . $object->term_id . ' / Posts: ' . $object->category_count . ' ]' ] = $object->term_id; } public function end_el( &$output, $object, $depth = 0, $args = [] ) { } } } /** pixwell name to ID */ 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 ); } } /** get protocol */ if ( ! function_exists( 'pixwell_protocol' ) ) { function pixwell_protocol() { $protocol = 'https'; if ( ! is_ssl() ) { $protocol = 'http'; } return $protocol; } } /** * @param $text * * @return bool|string * pixwell translation */ if ( ! function_exists( 'pixwell_translate' ) ) { function pixwell_translate( $text = null ) { if ( empty( $text ) ) { return false; } $text = trim( $text ); $translation_data = pixwell_translation_default(); $key = 't_' . $text; $translate = pixwell_get_option( $key ); if ( ! empty( $translate ) ) { return esc_html( $translate ); } if ( isset( $translation_data[ $text ] ) ) { return $translation_data[ $text ]; }; return false; } } if ( ! function_exists( 'pixwell_decode_shortcode' ) ) { function pixwell_decode_shortcode( $shortcode ) { return base64_decode( $shortcode, true ); } } /** * @return array|mixed|void * return default data */ if ( ! function_exists( 'pixwell_translation_default' ) ) { function pixwell_translation_default() { $translation_data = [ 'share_email' => esc_html__( 'I found this article interesting and thought of sharing it with you. Check it out:', 'pixwell-core' ), 'read_later' => esc_html__( 'Read it Later', 'pixwell-core' ), 'bookmark_empty' => esc_html__( 'Please add some posts to see your added bookmarks.', 'pixwell-core' ), 'facebook' => esc_html__( 'Facebook', 'pixwell-core' ), 'fans' => esc_html__( 'fans', 'pixwell-core' ), 'like' => esc_html__( 'like', 'pixwell-core' ), 'twitter' => esc_html__( 'Twitter', 'pixwell-core' ), 'followers' => esc_html__( 'followers', 'pixwell-core' ), 'follow' => esc_html__( 'follow', 'pixwell-core' ), 'pinterest' => esc_html__( 'Pinterest', 'pixwell-core' ), 'pin' => esc_html__( 'pin', 'pixwell-core' ), 'instagram' => esc_html__( 'Instagram', 'pixwell-core' ), 'love' => esc_html__( 'Love', 'pixwell-core' ), 'sad' => esc_html__( 'Sad', 'pixwell-core' ), 'happy' => esc_html__( 'Happy', 'pixwell-core' ), 'sleepy' => esc_html__( 'Sleepy', 'pixwell-core' ), 'angry' => esc_html__( 'Angry', 'pixwell-core' ), 'dead' => esc_html__( 'Dead', 'pixwell-core' ), 'wink' => esc_html__( 'Wink', 'pixwell-core' ), 'page' => esc_html__( 'Page', 'pixwell-core' ), 'telegram' => esc_html__( 'Telegram', 'pixwell-core' ), 'members' => esc_html__( 'Members', 'pixwell-core' ), 'join' => esc_html__( 'Join', 'pixwell-core' ), ]; $translation_data = apply_filters( 'pixwell_translation_data', $translation_data ); return $translation_data; } } /** 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-core' ); } elseif ( $number > 999 ) { $number = str_replace( '.0', '', number_format( ( $number / 1000 ), 1 ) ) . esc_attr__( 'k', 'pixwell-core' ); } return $number; } } 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_dark_mode_id' ) ) { function pixwell_get_dark_mode_id() { if ( is_multisite() ) { return 'D_' . trim( str_replace( '/', '_', preg_replace( '/https?:\/\/(www\.)?/', '', get_site_url() ) ) ); } return 'RubyDarkMode'; } } if ( ! function_exists( 'pixwell_calc_crop_sizes' ) ) { /** * @return array[] */ function pixwell_calc_crop_sizes() { $settings = get_option( 'pixwell_theme_options', [] ); $crop = true; 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; } } if ( ! function_exists( 'pixwell_total_word' ) ) { function pixwell_total_word( $content = '' ) { if ( empty( $content ) ) { return 0; } $content = preg_replace( '/(<\/[^>]+?>)(<[^>\/][^>]*?>)/', '$1 $2', $content ); $content = nl2br( $content ); $content = strip_tags( $content ); if ( preg_match( "/[\x{4e00}-\x{9fa5}]+/u", $content ) ) { // preg_match_all( '/[\x{4e00}-\x{9fa5}]+/u', $content, $matches ); // $count = $matches[0] ? count( $matches[0] ) : 0; $count = mb_strlen( $content, get_bloginfo( 'charset' ) ); } elseif ( preg_match( "/[А-Яа-яЁё]/u", $content ) ) { $count = count( preg_split( '~[^\p{L}\p{N}\']+~u', $content ) ); } elseif ( preg_match( "/[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7A3}]+/u", $content ) ) { $count = count( preg_split( '/[^\p{L}\p{N}\']+/', $content ) ); } elseif ( preg_match( "/[\x{3040}-\x{309F}\x{30A0}-\x{30FF}]+/u", $content ) ) { $count = count( preg_split( '/[^\p{L}\p{N}\']+/', $content ) ); } else { $count = count( preg_split( '/\s+/', $content ) ); } return $count; } }