suifengtec
Forum Replies Created
-
Forum: Reviews
In reply to: [WP Baidu Map] 用不了了我稍后检查下
Forum: Plugins
In reply to: [WooCommerce] Why must with Jetpack? there should have a skip btn!the skip btn is on the bottom section of the installing screen.
Forum: Plugins
In reply to: base64-encoded image upload using REST APImay it will help you:
public static function upload_image_as_term_thumbnail( $term_id, $img_base64Str ){ global $blog_id, $wpdb; if(!empty($img_base64Str)) { list($type, $img_base64Str) = explode(';', $img_base64Str); list(, $type) = explode(':', $type); list(, $type) = explode('/', $type); list(, $img_base64Str) = explode(',', $img_base64Str); $type = strtolower($type); $img = base64_decode($img_base64Str); /* wp_upload_dir( null, false ); */ $wp_upload_dir = wp_upload_dir(); $filename = "term_thumbnail_".time().".$type"; $path_to_file = $wp_upload_dir['path']."/".$filename; $filetype = wp_check_filetype( basename( $filename), null ); if( !function_exists( 'wp_handle_upload' ) ){ require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); } @file_put_contents( $path_to_file, $img ); $attachment = array( 'post_author' => 1, 'post_content' => '', 'post_content_filtered' => '', 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), 'post_excerpt' => '', 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => $filetype['type'], 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_password' => '', 'to_ping' => '', 'pinged' => '', 'post_parent' => 0, 'menu_order' => 0, 'guid' => $wp_upload_dir['url'].'/'.$filename, ); $wpdb->insert("{$wpdb->prefix}posts", $attachment); $attach_id = $wpdb->insert_id; if($attach_id == false){ return false; } $attach_data = wp_generate_attachment_metadata( $attach_id, $path_to_file ); wp_update_attachment_metadata( $attach_id, $attach_data ); update_attached_file($attach_id, $path_to_file); self::set_term_thumbnail( $term_id, $thumbnail_id ); /* or you may need the image URL */ return $attach_id; } return false; }
- This reply was modified 7 years, 9 months ago by suifengtec.
Forum: Reviews
In reply to: [WP Accelerator for Chinese] it's useful for me also,thank you!ok!
Forum: Plugins
In reply to: [JWT Authentication for WP REST API] Route ErrorIt’s for POST, so if you try to visit, it may be a 404 …
Forum: Themes and Templates
In reply to: Directory Multipurposes WordPress theme@chimpstudio
your JobCareer is a nice project,but it need to be polished.Forum: Plugins
In reply to: [Crayon Syntax Highlighter] it's not compatible with bbPressa temp hack:
add_filter('bbp_get_reply_content','coolwp_bbp_get_the_content',100,2); function coolwp_bbp_get_the_content($content, $reply_id){ return wpautop( $content ); }
Forum: Plugins
In reply to: [JSON API] No Access-Control-Allow-Origin header is present – error!me too:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost:8100' is therefore not allowed access.
Forum: Plugins
In reply to: [WordPress REST API (Version 2)] How to use the custom parameter in the URL?I want to add a callback function to format the return post data,for example:
https://dev/wp-json/wp/v2/posts?callback=ABCD
it should return data as follow:
ABCD([{"id":1...},{"id":2...},{"id":3...}])
Forum: Plugins
In reply to: [WooCommerce] Please add a filter hook for product title/missing attributesAnother hook should be add to prevent broken breadcrumb:
includes/class-wc-breadcrumb.php
/** * Single post trail * * @param int $post_id * @param string $permalink */ private function add_crumbs_single( $post_id = 0, $permalink = '' ) { if ( ! $post_id ) { global $post; } else { $post = get_post( $post_id ); } if ( 'product' === get_post_type( $post ) ) { $this->prepend_shop_page(); if ( $terms = wc_get_product_terms( $post->ID, 'product_cat', array( 'orderby' => 'parent', 'order' => 'DESC' ) ) ) { $main_term = apply_filters( 'woocommerce_breadcrumb_main_term', $terms[0], $terms ); $this->term_ancestors( $main_term->term_id, 'product_cat' ); $this->add_crumb( $main_term->name, get_term_link( $main_term ) ); } } elseif ( 'post' != get_post_type( $post ) ) { $post_type = get_post_type_object( get_post_type( $post ) ); $this->add_crumb( $post_type->labels->singular_name, get_post_type_archive_link( get_post_type( $post ) ) ); } else { $cat = current( get_the_category( $post ) ); if ( $cat ) { $this->term_ancestors( $cat->term_id, 'post_category' ); $this->add_crumb( $cat->name, get_term_link( $cat ) ); } } /*suifengtec $this->add_crumb( get_the_title( $post ), $permalink ); $post_title = apply_filters('woocommerce_frontend_breadcrumb_single_post_title',get_the_title( $post )); $this->add_crumb( $post_title, $permalink ); */ $post_title = apply_filters('woocommerce_frontend_breadcrumb_single_post_title',get_the_title( $post )); $this->add_crumb( $post_title, $permalink ); }
Forum: Reviews
In reply to: [Wise Chat] a nice plugin!Wise Chat shortcode is in the content of some posts of mine load by AJAX,Wise Chat can load UI without functionality.
Thanks for your tip!
I solved this problem by coding a custom function.
yes,you’r right!
Forum: Plugins
In reply to: [WP Fastest Cache] Nice plugin! zh_CN for it!may more people can use it!