Tag Archives: WordPress

đź‘Ť Liked: Why Blog?⤴

from @ wwwd – John's World Wide Wall Display

Liked What is academic blogging and how can you use it to build your professional profile? | by Lorna Campbell (thinking.is.ed.ac.uk)
an informal outlet, blogs allow you to experiment with different writing styles and voices, enabling you to find a tone that is right for you.

Lorna Campbell, @LornaMCampbell
What is academic blogging and how can you use it to build your professional profile?.

There are many other good reasons that would apply inside and outside academia in this post/presentation.

Lorna is drinking her own blogwater with @cogdog‘s WordPress presentation splot too.

A month of Blogs.ed⤴

from @ education

We launched our new University Academic Blogging service a month ago, with a significant new piece - our Blogs.ed WordPress platform - and it's been a sheer delight to watch Blogs.ed grow. I've mentioned in a previous post that as well as being closely aligned … Continue reading A month of Blogs.ed

A few loose WordPress LTI threads⤴

from @ education

There are about 8 blog posts queued up and needing written before things start to fade from my memory. I've even made a list in case I forget them. However, I can't quite stop myself from just quickly bashing this one out if only to … Continue reading A few loose WordPress LTI threads

Luna Carmona at @wp_glasgow⤴

from @ wwwd – John's World Wide Wall Display

Event #51: “Build a Community with WordPress and Social Media”, by Luna Carmona

Luna started by giving Mark Z of FB as a good model for communication. Someone to be trusted! I guess this indicated I was not the target audience;-)

I did enjoy the talk. Luna covered the way she had used social media to support building a community around Achieve More Scotland. This is a small but valuable organisation. In a couple of years they have greatly increased online engagement.

Takeaways:

  • try multiple channels don’t be scared of dropping the ones that have little engagement.
  • Meet community where it exists using the channels folk already use.
  • Twitter in the morning, Instagram in the middle of the day and Facebook in the evening.
  • Try for community rather than followers.
  • Respond quickly.

There are lessons for online educational communities here.

There wasn’t much specific WordPress information I wonder if some IndieWeb tech could help?

Apprentice SPLOT Maker⤴

from @ education

Continuing my foray into enquiry-based, self-regulated, mastery learning, I've been hacking away at some more SPLOT code. After my last efforts I felt like I now had enough knowledge to try customise the SPLOTBox theme to see how well it might fit my requirements for … Continue reading Apprentice SPLOT Maker

Academic Blogging; or what we did this summer…⤴

from @ education

https://twitter.com/UoE_LTW/status/1042790396752003075 We're a week out from launching a new blogging service - a project that has had a number of false starts and delays along the way - and I am so impressed with the work the team have done to get this there. There's … Continue reading Academic Blogging; or what we did this summer…

WordPress LTI Testing: Part 4⤴

from @ education

This follows on from a series of previous posts documenting some thinking about integrating WordPress with a VLE via LTI: Laying it all out to begin WordPress LTI Testing: Part 1 WordPress LTI Testing: Part 2 WordPress LTI Testing: Part 3 Doing the thinking above … Continue reading WordPress LTI Testing: Part 4

A feed for my microcast⤴

from @ wwwd – John's World Wide Wall Display

As part of my summer holiday fun with WordPress I though I might create a ‘proper’ RSS feed for my microcast.

There are quite a few podcast plugins that would do the job but I though it might be interesting to try a bit of DIY.

Back when I started a class podcast at Radio Sandaig I used to create the RSS feed by hand with a text editor and a fair bit of copy and paste. Over at Edutalk we use feedburner to massage the feed for iTunes.

I used information from How to Roll Your Own Simple WordPress Podcast Plugin | CSS-Tricks to get me started with the template.

I copied the feed-rss2.php file from the wp-includes folder to my child theme folder renaming it feed-microcast.php

wp-content/themes/sempress-child/feed-microcast.php

I adjusted the query to get the posts from my microcast category. I also hard coded the title, link, image and a few other things to simplify the process a little.

I then used the template from CSS-Tricks as a guide to adding the various podcast tags to my template.

This ended up with a pretty broken feed, mostly due to my lack of care, but I fixed it up later I got it linked up.

I didn’t want to use the custom post type approach used in the article because that would involve editing all the old posts or converting them to the new type somehow.

My first idea was to create a feed template and switch to that when the RSS feed for my microcast category was called for.

After failing to get the template to switch for the standard category feed, /category/microcast/feed I ended up with a custom feed at /feed/microcast.

and I add

add_action('init', 'customRSS');
function customRSS(){
        add_feed('microcast', 'customRSSFunc');
}

function customRSSFunc(){
        get_template_part('feed', 'microcast');
}

to my functions.php file.

I then spent a bit of time using the W3C feed validation service until I fixed the feed up to valadate.

I’ve still got to get a link to the feed into the microcast category page head tag and I hope to do that as soon as I’ve gone a bit of research. For now I’ve a link in the sidebar.

Here is the template: WordPress RSS feed template for my microcast

Using the WordPress REST API to post a book from WikiSource to PressBooks with python⤴

from @ Sharing and learning

I am using Pressbooks to build an online edition of Southey and Coleridge’s Omniana. I transcribed the text for Volume I on wikisource. This post is about how I got that text into pressbooks; copy and paste didn’t appeal, so I thought I would try using the WordPress REST API. You could probably write a PHP plugin that would do this, but I find python a bit easier for exploratory work, so I used that.

Getting the data from Wikisource is reasonably trivial. On wikisource I have transcluded the page transcriptions into a single HTML file of the whole book. This file is relatively easy to parse into the individual articles for posting to Pressbooks, especially as I added <hr /> tags before each article (even the first) and added stop at the end.

In the longer term I want to start indexing the PressBook Omniana using wikidata for linked data. This will let me look at the semantic graph of what Southey and Coleridge were interested in.

First steps with the WordPress API

I’ve not used the WordPress API before, but it is well documented and there is a useful series of articles on envatoTuts+: Introducing the WP REST API.

Put /wp-json onto the end of a WordPress blog URL and you can see the routes and endpoints (e.g. this blog, my Pressbooks/Omniana). (I use the JSON viewer chrome plugin to make these easier to read.) I found wp-api-python very useful in helping make requests against these in python. It’s available via pip as wordpress-api and I found it required python the libraries request beautifulsoup4, requests-oauthlib and six. It authenticates via  OAuth, so on WordPress you need the  WordPress REST API – Oauth1.0a plugin or similar; there’s more than you need to know about how OAuth works  on envatotuts+.

I installed the Oauth1.0a plugin for the network on a WordPress multisite and PressBook test servers. Network activation seemed to generate errors on Pressbooks and plain multisite WordPress, so I activated it only for the individual blog/book. Then in the Users tab on the admin screen I was will be able to view and set up applications:

Add Application screen from the OAuth1.0a plugin

Filling out the details and clicking on save consumer and  gave me a client key and client secret.

Back in python I used these to poke around the various API endpoints of my test multisite installation of WordPress, e.g.

from wordpress import API
base_url = "http://wordpress.home.local/test"
api_path = "/wp-json/wp/v2/"
wpapi = API(
    url=base_url,
    consumer_key="thisismykey",
    consumer_secret="thisismysecret",
    api="wp-json",
    version="wp/v2",
    wp_user="phil",
    wp_pass="thisismypassword",
    oauth1a_3leg=True,
    creds_store="~/.wc-api-creds.json",
    callback="http://wordpress.home.local/test/api-test"
)
print("listing posts")
resource = "posts"
try:
    response = wpapi.get(base_url+api_path+resource)
    for post in response.json():
        print(post['id'], post['title'])
except Exception as e:
    print("couldn't get posts")
    print(e)

wpapi uses requests methods, documented here.  Other useful properties and methods are

  • r.ok: boolean, True if HTTP status code is <400
  • r.content, response content in bytes,
  • r.text, response content in text
  • r.headers, response headers
  • r.iter_lines() content a line at a time
  • r.json() response as a json object

Posting to WordPress

Following the envatoTuts+ Creating, Updating, and Deleting Data article and translating to python:

from wordpress import API
base_url = "http://wordpress.home.local/test"
api_path = "/wp-json/wp/v2/"
wpapi = API(
    url=base_url,
    consumer_key="thisismykey",
    consumer_secret="thisismysecret",
    api="wp-json",
    version="wp/v2",
    wp_user="phil",
    wp_pass="thisismypassword",
    oauth1a_3leg=True,
    creds_store="~/.wc-api-creds.json",
    callback="http://wordpress.home.local/test/api-test"
)

print("creating new post")
resource = "posts"
title = "86. Glover's Leonidas."
content = """Glover's Leonidas was unduly praised at its first appearance, and more unduly ...
..."""
excerpt = """Glover's Leonidas was unduly praised at its ..."""
data = {
    "content": content,
    "title": title,
    "excerpt": excerpt,
    "status": "draft",
    "categories": [190]
}
try:
    response = wpapi.post(base_url+api_path+resource, data)
    print(response.json())
except Exception as e:
    print("couldn't post")
    print(e)

The posts resource collection allows creation and retrieval  (POST and GET methods); a specific posts/(?P<id>[\d]+) resource allows update and delete (PUT, PATCH and DELETE methods).

The keys for the data dict are the same as the schema for the WordPress API method, which are also shown in the arguments listed in the JSON returned by wp-json for each endpoint under each route.

Posting to Pressbooks

Pressbooks has a whole extended set of api routes and endpoints, no ‘posts’ resources, but front-matter, back-matter, parts and chapters; all under the /pressbooks/v2/ path.

There is some documentation on the Pressbooks site.  I’m posting articles as chapters into a Pressbook site that already has some organised content, so I don’t have to worry about setting them up. Adapting from the above, changing to URL and credentials to those for my local test instance of Pressbooks, and changing the api-path, version, and resource name, this posts a test chapter to the content part of my book, as a “numberless” chapter-type:

from wordpress import API
base_url = "http://books.home.local/omniana"
api_path = "/wp-json/pressbooks/v2/"
wpapi = API(
    url=base_url,
    consumer_key="thisismykey",
    consumer_secret="thisismysecret",
    api="wp-json",
    version="pressbooks/v2",
    wp_user="phil",
    wp_pass="thisismypassword",
    oauth1a_3leg=True,
    creds_store="~/.wc-api-creds3.json",
    callback="http://books.home.local/omniana/api-test"
)
print("creating new chapter")
resource = "chapters"
data = {
"content": "test",
"title": "test",
"status": "publish",
"chapter-type": 48,
"part": 27
}
try:
response = wpapi.post(base_url+api_path+resource, data)
pprint(response.json())
except Exception as e:
print("couldn't post")
print(e)

Finding the ids for chapter-type and part need a little detective work. You can, of course use an API call to GET the parts and  list their names and ids, in a similar way to listing the posts in the first example above; or you can just edit the part or chapter-type in the Bookpress admin interface and inspect the url. It’s also worth noting that you need a different creds_store for each OAUTH provider you connect to.

Next Steps

As I said, parsing reading through and parsing the transcluded the page transcriptions wasn’t too hard (I put some markers in the transclusion to help). I made some changes to the content before posting it: perhaps the most interesting issue was  changing the wiki style footnotes to Pressbook style.

At the time of writing, I have started posting to the live/public instance of Omniana on Pressbooks but still have to sort some formatting issues: removing line breaks, making sure that the CSS selectors are appropriate for WordPress; that shouldn’t take long to fix.

Then I want to start indexing the articles using wikidata for linked data.

The post Using the WordPress REST API to post a book from WikiSource to PressBooks with python appeared first on Sharing and learning.

Update on Gutenberg — WordPress⤴

from @ wwwd – John's World Wide Wall Display

Bookmarked Update on Gutenberg (WordPress News)
Progress on the Gutenberg project, the new content creating experience coming to WordPress, has come a long way. Since the start of the project, there have been 30 releases and 12 of those happened…

WordPress 5.0 could be as soon as August with hundreds of thousands of sites using Gutenberg before release.

Source: Update on Gutenberg — WordPress

Although GlowBlogs will not be getting this until later in the year and after much testing I am still watching and occasionally testing Gutenberg.

From a selfish POV (my class uses iPads) I am still seeing some of the same issue on iPad as I mentioned before: Gutenberg on iPad. A lot better now, but the active text still goes behind the keyboard on occasion. I hope to do a bit more testing over the summer break.