WordPress/ClassicPress Plugin Development: Checking If Function Exists In Namespace

WordPress PluginI’ve been developing my own plugins for WordPress and, more reently, ClassicPress. At times it’s been necessary to check if a function exists.

It’s fairly straightforward to do this check:

if (!function_exists('azrcrv_get_breadrumbs')){
	// code here
}

I also use a few plugins developed by other people. One of the ones I’ve been reviewing recently is Estimated Read Time by CodePotent.

John uses namespaces in his plugins which means the check also needs to include the namespace. You can check for this using the following syntax (the highlighted section is the namespace defined in the plugin):

if (function_exists('CodePotent\EstimatedReadTime\process_shortcode')){
	// code here
}

I’m posting this as a reminder to myself as it took me a few minutes of searching before I found the right answer.

Migrating to ClassicPress: Using Migration Plugin With Unsupported WordPress Version

ClassicPressThis post is part of a series on migrating to ClassicPress from WordPress.

ClassicPress provide a migration plugin which you can use to migrate from WordPress to ClassicPress. The developers working on ClassicPress are also keeping the plugin updated for new releases of WordPress, but will lag a little behind as they need to wait for WordPress to release the new version before they can update the migration plugin.

I’ve been doing testing on ClassicPress and this has also included testing the plugin. Sometimes I’ve wanted to upgrade from an version not supported by the plugin.

The easiest way, in my experience, to use the plugin on a new version of WordPress before it is officially supported, is to amend the plugin to change the value to which the $wp_version_max parameter is being set:

admin-page.php showing line 318

Changing the value from 5.0.2 to 5.0.3 will allow the migration plugin to be run against the latest version of WordPress.

Instead of updating the plugin, you can also add the following line to your theme’s functions.php:

add_filter( 'classicpress_ignore_wp_version', '__return_true' );

I’ve tended to go with updating the plugin code, rather than adding the code to my functions file as I prefer to only have code in my theme that is for the benefit of the theme itself.

Click to show/hide the Migrating to ClassicPress Series Index

GitHub Announces New Unlimited Repos & Unitifed Enterprise Offering

GitHubI’ve recently been taking a look at ClassicPress and one of the subjects that came up was that it might, for the plugin directory, use GutHub instead of SVN like WordPress.

I create an account and started looking into creating repositories for my plugins. Hot all of my plugins are on that site however, as not all have been released to the public. Some of them are only going to be usable to me (for example plugins drive both the GP Table Reference and my distilleries website) and you were limited on GitHub to a certain number of private repositories.

However, GitHub yesterday announced the following:

  • GitHub Free now includes unlimited private repositories. For the first time, developers can use GitHub for their private projects with up to three collaborators per repository for free. Many developers want to use private repos to apply for a job, work on a side project, or try something out in private before releasing it publicly. Starting today, those scenarios, and many more, are possible on GitHub at no cost. Public repositories are still free (of course—no changes there) and include unlimited collaborators.
  • GitHub Enterprise is the new unified product for Enterprise Cloud (formerly GitHub Business Cloud) and Enterprise Server (formerly GitHub Enterprise). Organizations that want the flexibility to use GitHub in a cloud or self-hosted configuration can now access both at one per-seat price. And with GitHub Connect, these products can be securely linked, providing a hybrid option so developers can work seamlessly across both environments.

The second point isn’t relevant to me, but the first might be useful as it will allow me to store both my public and private plugins in the same place.

More details are available from the GitHub blog.

Migrating to ClassicPress: What About The Plugins and Themes I Use?

ClassicPressThis post is part of a series on migrating to ClassicPress from WordPress.

As ClassicPress is based off WordPress 4.9.8, all current, non-Gutenberg, WordPress plugins and themes will be compatible with ClassicPress.

A growing number of plugins are stating that they are and will continue to be compatible with ClassicPress. There is a < forum post listing plugins confirmed as working with ClassicPress v1 on the ClassicPress forums; this is not to say that other plugins won’t work, but they haven’t been confirmed yet. This thread will be maintained for v2 of ClassicPress as well, which is when potentially breaking changes could be introduced.

If you think you might migrate to ClassicPress and want to confirm if the plugins you use will be supported with it, reach out to the authors of your favourite plugins and ask them to support ClassicPress. There is even a sample email message you can adapt and use.

Click to show/hide the Migrating to ClassicPress Series Index

Migrating to ClassicPress: Backup Before Running the Migrate Plugin

ClassicPressThis post is part of a series on migrating to ClassicPress from WordPress.

Before running the migration plugin, it’s recommend to make a complete backup of your site; both files and database should have a good backup made. This isn’t particular to migrating to ClassicPress; I make the same recommendation for any process which is going to impact on files and/or database.

By a good backup, I mean verifying that the backup has worked (e.g. all the expected files are downloaded and the database backup file contains the relevant tables. Without this you won’t be able to restore in case of need.

Click to show/hide the Migrating to ClassicPress Series Index

Migrating to ClassicPress: ClassicPress Migration Plugin Now Supports WordPress 5

ClassicPressThis post is part of a series on migrating to ClassicPress from WordPress.

I mentioned yesterday that the ClassicPress migration plugin was not ready yet for WordPress v5, but was coming soon.

Apparently I should have waited a day and posted today, as the migration plugin is now supported with WordPress 5.

Click to show/hide the Migrating to ClassicPress Series Index

Migrating to ClassicPress: Run ClassicPress Migration Plugin

ClassicPressThis post is part of a series on migrating to ClassicPress from WordPress.

With the migration plugin installed, the next step is to complete the site migration.

The activated plugin is available from the Tools menu in the sidebar; select Switch to ClassicPress:

Migration Plugin on Tools menu - Switch to ClassicPress

Continue reading “Migrating to ClassicPress: Run ClassicPress Migration Plugin”

Migrating to ClassicPress: Install ClassicPress Migration Plugin

ClassicPressThis post is part of a series on migrating to ClassicPress from WordPress.

With the migration plugin downloaded, the next step is to install the plugin.

To do this, log into your WordPress site’s admin panel and select Plugins from the navigation pane and then click the Upload Plugin button at the top of the page, next to the Add Plugins header:

Add Plugins - Upload Plugins button

Continue reading “Migrating to ClassicPress: Install ClassicPress Migration Plugin”

Migrating to ClassicPress: Migrating from WordPress 5 to ClassicPress

ClassicPressThis post is part of a series on migrating to ClassicPress from WordPress.

In the last post, I downloaded the migration plugin. If the site you’re migrating is on WordPress 4.9.x then you are good to proceed; if your site is on WordPress 5, then you’ll need to wait a little time.

ClassicPress are about ready to release a version of the migration plugin which will allow migration of a WordPress 5 site. Once this updated plugin is released, all WordPress sites could be migrated to ClassicPress.

Click to show/hide the Migrating to ClassicPress Series Index

Migrating to ClassicPress: Download ClassicPress Migration Plugin

ClassicPressThis post is part of a series on migrating to ClassicPress from WordPress.

The easiest way to migrate an existing WordPress site to ClassicPress, is to use the ClassicPress migration plugin available from here:

ClassicPress migration plugin available at https://www.classicpress.net/migrate/

The file downloaded is a zip file, but, as the download page says, this does not need to be extracted; the zip can be uploaded directly via the WordPress plugin upload function.

Click to show/hide the Migrating to ClassicPress Series Index