Schlagwort-Archive: Wordpress

Give feedback on errors with the WordPress Settings API

After working with the WordPress Settings API I first found no easy way out to give feedback on errors.

As a lot of you I was reading the tutorials from David Gwyer, Ozh, BobGneu and Otto, but none of them gave proper information on how to pass the error messages to the user when theie values fail the validation test.

BUT…. I found a somehow quick but practicable way to bypass the lack of user validation information.

Take the sanitize function you call from register_setting which is responsible to check the values:


<?php

function myplugin_options_validate($input) {

// use  $input['error'] and $input['message'] for error messages

$input['error'] = false;

$input['message'] = '';

# do some regex validation

if (1=!1) { // yes we have an error

$input['error'] = true;

$input['message'] = 'you have got an error: 1!=1';

}

return $input;

}

?>

Now go to the function which creates the settings form (most called via add_options_page) and check with $_GET[‘settings-updated’].


<?php

function myplugin_options_page() {

if ($_GET['settings-updated'])  { // yes, settings have been changed

if ($_GET['settings-updated'] && $options['error']) {
print '<div>'.$options['message'].'</div>';
}

}

?>

That’s it.

WordPress: Create unique content with Old Post Spinner

WordPress 3.2 ok!

NOW WITH ABILITY TO CREATE UNIQUE CONTENT

Create a complete unique new post on a random old one and promote it to the top of your blog.

It is really easy to handle and self-explanatory.

Compared to other plugins which do pretty much the same my plugin uses the build in functionality of WordPress’ own “cronjob”. This makes the whole part much more stable and (what is even more important) bypasses workload away from the server.

Every promotion is registered in a log file.

Download

Download directly from WordPress.org repository.

FAQ

Is there anything I should be aware of? Any limitations?

Yes! This plugin should no be used with permalink structures that include dates.

Please explain me the settings’ values

Old Post Spinner (OPS) checks if a certain amount of time has passed. If so it promotes (or duplicates, depending on the settings) a random post to any position you like.

E.G. take this values:

  • Minimum interval between old post promotions: 2000 minutes
  • Random maximum interval (added to minimum interval): 500 minutes

Now OPS will every 200 0+ X minutes (where X lies somewhere random between 0 and 500) pick up one old post and promote (or duplicate) it to the defined position.

OPS will take into account which posting categories you never want to promote

You can also specify an minimum age for a post to be considered.

What will happen? Let’s take 10 posts ordered by age with No. 1 the as the youngest one. OPS picks the, let’s say, sixth post and give it the current date to promote it to position number one.

If you want a post to be promoted to position 3 OPS will place it, regarding the date, exactly in the middle between number 2 and (the old) number 3, which now will drop to position 4.

What is the difference between duplicating and promoting?

Promoting will move the post to a new position, whereas duplicating will copy a post to the new position, so the latter generates a new post.

What are the best practice values?

They are installed as default values. Minimum interval: 2000 minutes, Random interval: 500 minutes, Post age: 14 days. But maybe you should experiment with your own values. It’s up to you.

What do you mean with spinning?

Spinning means the creation of a new “spinned” content. That will create a new and unique post every time it gets promoted (or duplicated).

How do I spin the title and the content?

That requires a bit of handwork. You can manually add multiple synonym versions of any sentence and any word you want. That is done by using the characters |, { and }. I give you an example:


Hello, my name is {Jack|Jim} and I love {Tennis|Golf}.

Using this spinning instructions sentence will generate this four different result sentences every time your article is promoted:

  • Hello, my name is Jack and I love Tennis.
  • Hello, my name is Jack and I love Golf.
  • Hello, my name is Jim and I love Tennis.
  • Hello, my name is Jim and I love Golf.

So, with a little bit of extra afford you are able to create a complete unique post every time.

Just add as many synonym sentences as you like between the curly brackets ”{“, “}” and separate each synonym sentence by Pipe “|”.

You can nest your sentences as well:


Hello, my name is {Jim|{Handsome|Ugly}Joe}.

Will result in:

  • Hello, my name is Jim.
  • Hello, my name is Handsome Joe.
  • Hello, my name is Ugly Joe.

IMPORTANT: Please post this spinning instruction sentences in the extra Old-Post-Spinner meta box of WordPress (see the screenshot) and NOT into the normal text and content form fields

What will happen if I only want to spin the title or the content?

No problem. If you only fill in spinning instructions on the title, then only the title will be spinned. The content won’t change. Same with the content, if you only want the content to be spinned, than leave the spinning instructions on the title empty.

What date will the promoted posts get?

Posts promoted to first position will get the current date. Posts below first position will be placed right in the middle of the enclosing posts.

Why should I use a category to ignore from promotion?

Some posts are simply not meant to be spinned. Especially if they are date-related. E.g. you should place posts with news into an omitted category.

But how do I hide the category from my blog?

If you don’t want this category to appear in you blog you can use the “AVH Extended Categories” plugin.

How can I recover the original dates?

All original dates are stored as custom fields. The name is “ops_original_pub_date”.

How can I support you?

That is nice of you. You can donate via Paypal.

How can I promote my newly dated posts to twitter now?

I think you should consider to use a service like twitterfeed.com. It will pickup your promoted posts and send status messages to twitter.

Do you have other plugins?

Check out my other WordPress Plugins.

Where do I post my feedback?

Here

Changelog

2.4.0 (06.07.2011)

  • testing with WordPress 3.2 -> OK
  • small security bugfix

2.3.3 (10.06.2011)

  • testing with WordPress 3.1.3 -> OK
  • removing schedule cron value when deactivating as well

2.3.2 (12.04.2011)

  • small security bugfix

2.3.1 (25.03.2011)

  • bugs fixed on test routine, when entering wrong values

2.3.0 (15.03.2011)

  • using minutes instead of hours

2.2.1 (26.02.2011)

  • testing with WordPress 3.1 -> ok

2.2 (19.02.2011)

  • tested with 3.0.5
  • more FAQs
  • new screenshots
  • more log entries to check for
  • more translations

2.15 (04.12.2010)

  • tested with WordPress 3.02

2.14 (11.08.2010)

  • tested with 3.01
  • new screenshots

2.13 (11.07.2010)

  • Fresher design of meta boxes
  • new wording
  • correcting typo errors

2.12 (11.07.2010)

  • creating a brand new permalink when duplicating
  • fixing a bug where not unique permalinks could get deleted

2.11 (10.07.2010)

  • now detects an existing “Google XML Sitemaps Generator for WordPress”-Plugin and starts creating the sitemap on request

2.10 (09.07.2010)

  • tuning the visual design

2.02 (08.07.2010)

  • small bugfix where on rare occasions (special PHP/server configuration) OPS creates an error

2.01 (07.07.2010)

  • adding more logging messages

2.00 (06.07.2010)

  • Now you can even duplicate a unique post instead of only promoting it

1.21 (05.07.2010)

  • delete spinning instructions as well when removing of plugin

1.20 (25.06.2010)

  • NOW WITH ABILITY TO CREATE UNIQUE CONTENT (Read FAQs on that, please)
  • fixed little date bug

1.10 (18.06.2010)

  • first multi language version
  • German added

1.09 (18.06.2010)

  • tested for WordPress 3.0 – ok
  • log folder error message now appears inside admin header

1.08 (17.06.2010)

  • fixed unnecessary warning messages on development systems

1.07 (16.06.2010)

  • moving log folder to wp-content path to face some problems when updating

1.06 (15.06.2010)

  • fixing problems some might have with the creation of log folder

1.05 (12.06.2010)

  • new FAQs
  • checking of implausible values
  • new screenshots

1.04 (08.06.2010)

  • better logview (check for still not existing log file)

1.03 (07.06.2010)

  • small bugfixes

1.02 (06.06.2010)

  • using build in WordPress Cronjob
  • better logfile view

1.01 (05.06.2010)

  • little bugfixes, wording
  • including of deinstalation routine to delete all data
  • implementing a better log file viewer

1.00 (04.06.2010)

  • first Version

WordPress: Empty Plugin Template – A plugin template to start with

S T I L L   B E T A

As it says, an empty plugin considering all the advices given in

http://codex.wordpress.org/Writing_a_Pluginhttp://codex.wordpress.org/Creating_Options_Pages and http://planetozh.com/blog/2009/09/top-10-most-common-coding-mistakes-in-wordpress-plugins/

Including:

  • multi language ability
  • uninstall routine
  • data delete routine (avoid orphaned data)
  • coding advices
  • security aspects (validating user inputs, nonces)
  • external third party stuff (Ajax, CSS, Javascript)
  • shortcode
  • WordPress scheduler (“cronjob”)

Download from WordPress repository

Changelog

0.1 (17.02.2011)

  • first Version

WordPress für mobile Geräte (Android, iPhone) fit machen

Mit Schrecken musste ich feststellen, dass mein WordPress-Template auf einem mobilen Endgerät mehr als bescheiden aussieht, fast unleserlich ist und ewig zum Laden braucht. Das musste in Angriff genommen werden.

Wer seine eigene Website auf mobile Anwendbarkeit testen will, kann das unter ready.mobi erledigen. Dort erfolgt eine genauere Analyse für:

  • MIME Typen
  • Character encoding
  • Pop up Fenster
  • Alt texts für Bilder
  • Nutzen der Stylesheets
  • Tabellen
  • Übergroße Bilder

Und es besteht die Möglichkeit, die Seite mit einem Emulator zu besuchen.

Nach dieser schlecht gelaufenen Analyse habe ich mir drei verschiedene Plugins vorgenommen.

Ich habe mich für MobilePress entschieden, weil es einfach zu installieren ist und ein eigenes Template eingebaut hat. Und vor allem scheint es auch immer noch gepflegt zu werden. Man installiert es wie jedes beliebige Plugin. Eventuell muss noch der Webseiten-Cache geleert werden, falls man ein Cache-Plugin installiert hat. Das war es auch schon.

Ein jetzt durchgeführte Test gab bei fast allen Punkten “grünes Licht” und vor allem kann man mein Blog jetzt auch ohne Kopfschmerzen auf einem Android-Handy lesen.

Ein  sehr guter Artikel mit Tests zu 9 anderen Plugins findet sich aktuell bei Dr. Web.

http://www.handypark.de/webmaster/blogs/wp-viewmobile.html