function b2_recursive_sanitize_text_field($array) { foreach ($array as $key => &$value) { if (is_array($value)) { $value = b2_recursive_sanitize_text_field($value); } else { $value = sanitize_text_field(str_replace(array('{{', '}}'), '', wp_strip_all_tags($value))); } } return $array; } function b2_str_ends_with($haystack, $needle) { $length = strlen($needle); if ($length == 0) { return true; } return (substr($haystack, -$length) === $needle); } function b2_redirect_404($post_type) { $allows = ['document', 'circle', 'infomation', 'shop', 'links', 'newsflashes', 'circle', 'ask']; if (in_array($post_type, $allows)) { if ($post_type == 'links') { $open = b2_get_option('links_main', 'link_open'); } else { $open = b2_get_option($post_type . '_main', $post_type . '_open'); } if ((int) $open == 0) { wp_redirect(home_url('/404')); exit; } } } function b2_get_decimal_length($number) { $number = (string) $number; $decimalPosition = strpos($number, '.'); return $decimalPosition === false ? 0 : strlen(substr($number, $decimalPosition + 1)); } function b2_add($a, $b) { $multiplier = pow(10, max(b2_get_decimal_length($a), b2_get_decimal_length($b))); return round(($a * $multiplier + $b * $multiplier) / $multiplier, 2); } function b2_sub($num1, $num2) { $multiplier = pow(10, max(b2_get_decimal_length($num1), b2_get_decimal_length($num2))); return round(($num1 * $multiplier - $num2 * $multiplier) / $multiplier, 2); } function b2_mul($num1, $num2) { $multiplier = pow(10, b2_get_decimal_length($num1) + b2_get_decimal_length($num2)); return round(($num1 * pow(10, b2_get_decimal_length($num1)) * ($num2 * pow(10, b2_get_decimal_length($num2)))) / $multiplier, 2); } function b2_div($num1, $num2) { $multiplier = pow(10, b2_get_decimal_length($num1) - b2_get_decimal_length($num2)); return round(($num1 * pow(10, b2_get_decimal_length($num1))) / ($num2 * pow(10, b2_get_decimal_length($num2))) / $multiplier, 2); } add_filter('rest_enabled', '__return_true'); add_filter('rest_jsonp_enabled', '__return_true'); // add_action('b2_aside_bar','b2_aside_bar'); // function b2_aside_bar(){ // echo ''; // } // function b2_remove_category( $string, $type ) { // if ( $type != 'single' && $type == 'category' && ( strpos( $string, 'category' ) !== false ) ){ // if(b2_get_option('normal_main','remove_category_tag')){ // $url_without_category = str_replace( "/category/", "/", $string ); // return trailingslashit( $url_without_category ); // } // } // return $string; // } // add_filter( 'user_trailingslashit', 'b2_remove_category', 100, 2); /*https://blog.wpjam.com/m/limit-login-attempts/ 限制IP登录错误次数6次*/ // add_action('wp_login_failed', function($username){ // $key = $_SERVER['REMOTE_ADDR']; // $times = wp_cache_get($key, 'wpjam_login_limit'); // $times = $times ?: 0; // wp_cache_set($key, $times+1, 'wpjam_login_limit', MINUTE_IN_SECONDS*15); // }); // add_filter('authenticate', function($user, $username, $password){ // $key = $_SERVER['REMOTE_ADDR']; // $times = wp_cache_get($key, 'wpjam_login_limit'); // $times = $times ?: 0; // if($times > 5){ // remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3); // remove_filter('authenticate', 'wp_authenticate_email_password', 20, 3); // return new WP_Error('too_many_retries', '你多次登录失败,请15分钟后重试!'); // } // return $user; // }, 1, 3 ); //临时设置全站的下载权限 // add_filter( 'b2_get_download_rights','set_new_download_role', 10,2); // function set_new_download_role($role,$post_id){ // return 'all|free'; // } //后台文章中禁止选择作者 // function b2_remove_page_fields() { // remove_meta_box('authordiv', 'post', 'normal'); // } // add_action( 'admin_menu' , 'b2_remove_page_fields' ); // add_action( 'transition_post_status','publish_circle_gift', 998, 3 ); // function publish_circle_gift($new_status, $old_status, $post){ // $user_id = $post->post_author; // $post_type = $post->post_type; // $post_id = $post->ID; // $has_gift = get_post_meta($post_id,'b2_circle_has_gift',true); // if(!$has_gift && $new_status === 'publish'){ // $key = get_post_meta($post_id,'single_circle_gift_key',true); // $value = get_post_meta($post_id,'single_circle_gift_value',true); // $notice = get_post_meta($post_id,'single_circle_gift_notice',true); // if($value && $key == 'money'){ // $money = B2\Modules\Common\User::money_change($user_id,(float)$value); // B2\Modules\Common\Message::add_message(array( // 'user_id'=>$user_id, // 'msg_type'=>92, // 'msg_read'=>1, // 'msg_date'=>current_time('mysql'), // 'msg_users'=>$user_id, // 'msg_credit'=>(float)$value, // 'msg_credit_total'=>get_user_meta($user_id,'zrz_rmb',true), // 'msg_key'=>$post_id, // 'msg_value'=>'' // )); // update_post_meta($post_id,'b2_circle_has_gift',1); // return; // } // if($notice && $key == 'gift'){ // B2\Modules\Common\Message::add_message(array( // 'user_id'=>$user_id, // 'msg_type'=>93, // 'msg_read'=>0, // 'msg_date'=>current_time('mysql'), // 'msg_users'=>$user_id, // 'msg_credit'=>0, // 'msg_credit_total'=>0, // 'msg_key'=>$post_id, // 'msg_value'=>$notice // )); // update_post_meta($post_id,'b2_circle_has_gift',1); // } // } // } // add_filter( 'b2_is_user_in_circle_return', 'my_user_in_circle_1998',2,3); // function my_user_in_circle_1998($status,$user_id,$circle_id){ // if($circle_id == 123 || $circle_id == 2){ return true; } // return $status; // } // add_action('b2_post_views','b2_view_credit'); // function b2_view_credit($data){ // if(!$data['user_id']) return; // if(!wp_using_ext_object_cache()) return; // $count = wp_cache_get('view_'.$data['user_id'], 'my_post_view'); // if($count > 3) return; // \B2\Modules\Common\Gold::update_data([ // 'date'=>current_time('mysql'), // 'to'=>$data['user_id'], // 'gold_type'=>0, // 'no'=>1, // 'post_id'=>$data['post_id'], // 'msg'=>__('阅读文章积分奖励:${post_id}','b2'), // 'type'=>'my_read_credit', // 'type_text'=>__('积分奖励','b2'), // 'read'=>0 // ]); // wp_cache_set('view_'.$data['user_id'],$count+1,'my_post_view',DAY_IN_SECONDS); // } 广州涉外经济学院 – 服装吧

广州涉外经济学院

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索