efoertsch
Forum Replies Created
-
Forum: Plugins
In reply to: [Media API for WooCommerce] rest_upload_sideload_error(I think this is what happened. Haven’t thought about the code since I posted above what I ended up doing.)
I found those fields via the returned JSON from the WP Media API after my initial success in uploading a photo via the WC Media API. The documentation from https://developer.ww.wp.xz.cn/rest-api/reference/media/ is pretty sparse on details. Note the title field is defined as an object, but there are not details as to what is contained in the object. On examining the returned media JSON I saw those fields in the title field and gave them a try to see if the photos would retain the proper SKU-01 type naming convention – which they did.
Forum: Developing with WordPress
In reply to: Shortcode to execute Plugin functionThank you for your comments. Would you be able to tell me what I need to code for the problem I am trying to solve?
Forum: Developing with WordPress
In reply to: Shortcode to execute Plugin functionI think I totally screwed up my question/response. (If you haven’t guessed by now I am a complete newbie at this)
But to answer your question of when the value is to be calculated. I want the plug method to be called prior to the page being sent to the browser.
The way I *thought* this might work was:
1. User is directed to the WordPress page
2. WordPress sees the shortcode and calls associated filter function that points to the plugin method that returns text (eventually the plugin method will call a different server and return some html.)
3. WordPress get the text (html) from the plugin method and adds it to the webpage.
4. WordPress then sends the composed webpage to the browser.Perhaps my question should simply be: How can I have a WordPress page call a plugin function and incorporate the returned text from the plugin into the web page?
Forum: Developing with WordPress
In reply to: Shortcode to execute Plugin functionSorry. Bad cut paste of code. The correct last line of the code should be:
add_shortcode(‘shortcode-test-text’, ‘filter_test_text’);
And again it just displays the shortcode text ‘shortcode-test-text’ in the post.
Am I correct though in thinking the shortcode should execute the plugin method?
Forum: Plugins
In reply to: [Media API for WooCommerce] rest_upload_sideload_errorOK. Here’s a bit of a summary that will hopefully save someone hours or days of spinning wheels.
Got everything working for product and image uploads and Android app is being used in production. Here’s abbreviated WC setup I used.
1. Created ‘Android App’ user.
2. Created WC API key for ‘Android App’ and set access to ‘Read/Write’
3. Applied FAST CGI fix and JSON basic auth – https://support.metalocator.com/en/articles/1654091-wp-json-basic-auth-with-fastcgi
4. To keep WP from overwriting above changes also updated .htaccess file per https://perishablepress.com/stop-wordpress-changing-htaccess/.
5. Installed WC Media API – https://ww.wp.xz.cn/plugins/woo-media-api/
6. Activated WC Media API Plugin
7. Updated WC plugin file – https://ww.wp.xz.cn/support/topic/mime-type-image/
8. In my particular case every WC product is unique with it’s own SKU. To upload photos with image names related to the SKU, the SKU with appended photo sequence number were placed into the media.title.raw and media.title.rendered fields (Otherwise photos got names of ‘T’, ‘T-1’ as noted in prior post)
9. But WC would duplicate the photos uploaded and assign an additional sequence number, i.e. if I uploaded image SKU-01.jpg it created a SKU-01-1.jpg and then associated SKU-01-1.jpg to the product. The original uploaded photo was then extraneous. So my app logic was:
a. Upload product info to create new product
b. Upload photo(s), use the returned source_url value in next step
c. Associate photos to product by updating product, placing source_url value into product.image.src field
d. Delete the original uploaded photosForum: Plugins
In reply to: [Media API for WooCommerce] rest_upload_sideload_errorGetting there but not sure I am home yet. I can upload an image via Postman but
1. Still get the warning html ‘<b>Warning</b>: Illegal string offset ‘rendered’ in…’ before what looks like a vaild response.
2. The filename is apparently generated by the system like ‘T’, ‘T-1’
3. And the url does not indicate it points to a jpg, e.g. ‘http://aaaaa.org/wp content/uploads/2020/10/T-2’ . Uploads via WooCommerce web site have url like ‘http://aaaaa.org/wp-content/uploads/2020/09/IMG_20200902_093420-1.jpgBut I see the photo in media library. Going to carry on and add the urls to the product to see if the photos will display with the product OK.
Forum: Plugins
In reply to: [Media API for WooCommerce] rest_upload_sideload_errorThanks for the tip. For reference, I searched for the post and found https://ww.wp.xz.cn/support/topic/mime-type-image/. I passed it on to the server guy and we will give it a try. Stay tuned.
Forum: Plugins
In reply to: [Media API for WooCommerce] rest_upload_sideload_errorWe got further by adding the following line to the wp-config.php file:
‘define(‘ALLOW_UNFILTERED_UPLOADS’, true);’It got us past the rest_upload_sideload_error, but still no joy. Calling the API returns the same warning, and what looks like a valid response. But in looking at the Media Library, there is a entry made, but the image is named something like ‘unnamed-file.c’ , and the image file is corrupt.
Forum: Plugins
In reply to: [Media API for WooCommerce] rest_upload_sideload_errorStill getting some error after fixing month value in url. Still looking around for a fix.
Forum: Plugins
In reply to: [Media API for WooCommerce] rest_upload_sideload_errorI hate to admit it but part of my problem might be that I had the wrong value for month in the URL. (I am blaming that on to many hours riding herd on a hot laptop). Other complications preventing me from retesting fix. Stay tuned.