Include categories custom fields in REST api - json

I am working with Advanced custom fields, where I add an image selector for categories in wp - But I can't see the data in my JSON response for categories?
I have tried to use several plugins to do the same, but That haven't worked either -
I am using ACF to rest plugin to include acf fields in the response, which works fine on custom post types - where it creates an array field called "acf"
This field is not created in my categories though - Am i missing a function to use it in taxonomies?
examples.
domain.com/wp-json/wp/v2/recipies (a custom post type)
returns everything including acf.
domain.com/wp-json/v2/categories (a texonomy)
returns all of the categories, but nothing about acf
domain.com/wp-json/wp/v2/categories/37 (a single category)
returns the category but nothing about acf.
domain.com/wp-json/wp/v2/categories/37?_embed[0] (way of getting all embedded stuff)
Does not show acf
Hope that you can put me on the right path.

To anybody who is interested, and runs into this problem.
I talked to the developer of acf-to-rest, and there is a bug in version 2, where it doesn't save taxonomies correctly - It is fixed in version 3, but you can't update it yet through wordpress, since it is still in beta -
Redownload the plugin and go into your wp-config file
here you need to define that you are going to use version 3. paste this line into the wp-config file
define('ACF_TO_REST_API_REQUEST_VERSION', 3);
The endpoints has been rewritten, so you also need to read up on that if you are using the acf endpoints for updating etc.
To read more about the bug, go github page
To read about the end points - go here
I hope that this will help somebody in the future.

Related

Onenote does not return pages

This is similar question as OneNote pages API doesn't return pages in section-groups.
I'm using the Get sections and get Section pages with Sections expanded to get names for all pages in a notebook. However using the same requests all the time, the sections in section groups sometimes disappears, and wont reappear before recreating the group.
Is this a bug that one can somehow work around, or is there a better way of polling all the page names from a specific notebook? The pages need to be in order.
If you are trying to get all the page names for a Notebook, a work-around exists by using an OData nested filter. The idea is to query for all pages, $expand the parentNotebook, and then $filter on the id of the parentNotebook. Here is an example URL.
GET ~/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$notebook_id_here}'
Here is another SO question where someone employs a similar pattern: Best way to use One Note API to GET specific pages in specific section in specific notebook?
Update:
You can control the order of the returned pages by using OData's $orderby and specifying properties that exist on the entities in the returned entity set (in this case, the entity is pages). From dev.onenote.com: "The default [order] is lastModifiedTime desc (most recently modified page first)."
Under https://dev.onenote.com/docs#/reference/get-pages there is a section, "Page properties", that shows all the properties returned by this call. Since we are getting all the pages available to a user that exist in a notebook, the only property we can use is unfortunately createdTime.
The query param to add looks like $orderby=createdTime
In full:
GET ~/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$notebook_id_here}&$orderby=createdTime
I just tested this using Fiddler against my own pages so I think it should work. The nice thing is that it is a single request.
GET https://www.onenote.com/api/v1.0/me/notes/pages?$expand=parentNotebook&$filter=parentNotebook/id%20eq%20'{$YOUR_NOTEBOOK_ID_HERE}'&$orderby=createdTime

How can i add custom fields to moodle course like user

How can i add custom fields to course detail? just like user. Is there any plugin to do? I tried moodle-course_meta.And i can add additional fields to course,but when i try to use in upload course with and without adding profile_field_ as prefix,It doesn't take the value from the csv file.
Eg. i created custom field for a course using the plugin and call it note
And upload csv file which has field name note and also tried like what we do on user profile_field_note. On both no luck. but the rest course fields such as shortname,fullname... are imported properly.
I am on moodle version 2.8.3
There is no easy way to do it at the moment.
Some options are listed on tracker issue https://tracker.moodle.org/browse/MDL-34634
They include writing your own course format plugin or using the contributed local/admintool plugin, there are several links on this issue. The second option may be not properly compatible with backup/restore.

Drupal 7 - Adding Nodes Through phpmyadmin is not Working Correctly

I have received a Microsoft Access database file and was tasked to convert the contents into something readable by mySQL standards for a Drupal 7 website database. I managed to upload them into the "node" table successfully, with the correct content type classification, unique primary keys and node IDs, etc. Or so I thought.
When I checked the Drupal site, I checked the list of content type X, and all of the new stuff was there. However, when I tried to click them, instead of opening the new page like I expected it to, I received a "page not found" message, instead. I tried looking for the new content manually via "Find Content", but none of it was showing up. I checked entity reference lists that referenced content type X, but they were not showing up on those lists, either.
I checked which fields were required for content type X, and I found that "location category" and "address" were required fields. So to test, I only added 1 entry to each of those tables (both field_data and field_revision versions of the required field), representing the 1st of the many I tried to transfer over. Still nothing. I have no idea what I could be doing wrong. Can anyone offer some insight?
Adding content to Drupal through the database is absolutely the wrong way to go about creating content. I suggest you try any of the following methods:
Create the nodes programmatically using Drupal's API functions:
http://fooninja.net/2011/04/13/guide-to-programmatic-node-creation-in-drupal-7/
Upload data through a CSV file using the Feeds module:
http://drupal.org/project/feeds/

MSG Google Calendar adding a Feed

I know I must be brain-dead, and I had a solution about a month ago, but accidentally deleted it (oops)!
From the this page you can create a small widget calendar. With the date picker AND agenda (yes both are needed)
It produces some code like so:
<script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/calendar3.xml&up_calendarFeeds=&up_calendarColors=&up_firstDay=0&up_dateFormat=0&up_timeFormat=1%3A00pm&up_showDatepicker=1&up_hideAgenda=0&up_showEmptyDays=0&up_showExpiredEvents=1&synd=open&w=320&h=165&title=__MSG_Google_Calendar__&lang=en&country=ALL&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>
However it doesn't specify the calendar, and always loads the local calendar. I see there is the variable up_calendarFeeds in there, and that got me thinking I should try to add a feed. I searched and found google's page on feeds. The says the feed url is in the format of:
https://www.google.com/calendar/feeds/userID/private-magicCookie/full
full over basic is for machine readable, of which I assume the gadget uses. However when I set the up_calenderFeeds variable with my data, It loads nothing. What am I missing? This being my final code:
<script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/calendar3.xml&up_calendarFeeds=https://www.google.com/calendar/feeds/ohmusama#gmail.com/private-0b7544f4b5f2198fc76c96e59f285dad/full&up_calendarColors=&up_firstDay=0&up_dateFormat=0&up_timeFormat=1%3A00pm&up_showDatepicker=1&up_hideAgenda=0&up_showEmptyDays=0&up_showExpiredEvents=1&synd=open&w=195&h=500&title=Portland+IPA+Calendar&lang=en&country=ALL&border=%23ffffff%7C3px%2C0px+solid+%23999999&output=js"></script>
Alright, since no one was able to help me. I searched and searched and found some answers.
There are a variety of different variables in the get string with many characters that need escaping. First for what ever reason, up_calendarFeeds must be set to ({}) which url encoded ends up being up_calendarFeeds=%28%7B%7D%29
Then you need to set 2 variables for your calendar to work properly (I think you need both), up_c0u and up_c0c both to your feed path. Note that It seems this can be in an array form, so you can add many feeds by incrementing 0, so up_c1u up_c2u up_c3u etc

How to save WP widget instances to options

I'm a little confused about this, even though I have read all of the API and searched for hours.
When I activate my plugin I add some values to the options database, e.g.
add_option('code','24');
How do I update that value or use it in the widget? I only see "instances" now, like the example on this page:
http://wpcoderz.com/creating-a-multi-instance-widget-with-wordpress-2-8/
You can get an option using get_option and update it using update_option. But you should use instances instead of options for widget settings (like title) because that's the purpose of instances. You don't have to care about storing instance value - WP does it for you. If you don't understand instances well, look at codex.wordpress.org/Widgets_API.