Skip to content

Tag: Plugins

4.3 update

Posted in Site News, and Software

I updated to WP 4.3 yesterday and found that one of my plugins ceased working, it also stopped the website from loading, both the blog and admin pages.
So I decided that I would raise a ticket to let the developer know there was an issue with the plugin:
https://wordpress.org/support/topic/cannot-redeclare-get_language_attributes?replies=2#post-7315181

I’m very happy that the problem has been fixed, but can’t say that I was ecstatic with the developers comment, seeing as my feedback was the first one posted after I’d checked to ensure there wasn’t one already raised. (The post ID’s give it away).

Perhaps I’m just in a grumpy mood today, as I often have to deal with many cases of people not reading things correctly, getting the wrong end of the stick or just ignoring the facts in-front of them. Normally these are my customers so it’s hard to rant at their complete lack of understanding or attention to detail, and you just have to point out their mistake.

I felt a little dissuaded from raising feedback in the future.

#software #sitenews #wordpress #plugins

Social linking text plugin

Posted in Coding

Whenever I make a post I like to have the Publicize element of Jetpack update my Social Media stuff when I make a new post. However I like to prefix the message that goes out with the text “[Blog]” so that on twitter it’s clean that I’m not just linking to something random. I usually remember to it the text but on occasion I forget completely and kick myself as it’s rather inconsistent.

After digging about in the bowls of wordpress there appear to be some functionality you can use to default before and after the usual Publicize text and link, I know that the ability to add a #Blaugust hashtag during the event would have been useful.

A number of places I read indicated you could add this functionality to the theme, however when I tried this it didn’t work for me correctly, so I opted for the plugin method which I’ve detailed below should you want to do the same. Yes there is most likely a plugin that will do all of this for you but it’s nice to build it yourself.

Note : you will need access to your website via FTP or a website portal that allows you to create folders and files.

  1. First you will need to navigate from the root of your wordpress install to the folder wp-content and then plugins.
  2. Create a folder for your plugin, mine is called “Publicize-Plugin”
  3. Navigate to your newly created folder and create a new php file, this usually takes the same name as the plugin folder, in my example it’s called Publicize-Plugin.php
  4. You will need to create the header elements of the file to just cover the basics your file will need to look something like this:
    <?php
    /*
    Plugin Name: Publicize Plugin
    Description: Custom Code for publicize function
    Author: welshtroll
    Version: 1.0
    */
    /* Prefix Code Goes Here */
    /* Suffix Code Goes Here */
    ?>
  5. Next up is adding the logic to Prefix the text to your publicize, you need to replace the text /* Prefix Code Goes Here */ with the following:
    function Publicize_prefix() {
         return '[Blog] ';
    }
    
    add_filter('wpas_default_prefix', 'Publicize_prefix');
  6. The first part creates an function (rename as you wish) that will return the prefix “[Blog] ” (Note the space after the text to stop it going straight against the generated title and link).
  7. The second part registers that function to be called when the prefix is need, the function name will need to match.
  8. So in theory you should be able to visit your wordpress admin plugin page and enable the plugin.
  9. The final step is to replace the placeholder /* Suffix Code Goes Here */
    function Publicize_suffix() {
         return '';
    }
    
    add_filter('wpas_default_suffix', 'Publicize_suffix');
  10. This will add the suffix element, in mine it’s empty but you could add anything you like such as hashtags. Again remember it will attach it directly to the text so add a space at the start.
  11. Now when you are creating a new post your publicize should contain your additional text.

You can find the file here http://welshtroll.co.uk/files/sampleplugin.txt

And there you have it, a basic plugin to modify the default publicize text.

#Coding #Plugins