Archive for the ‘WordPress’ Category

16 June, 2014 — Development, Snippets, WordPress

Hide A WordPress Plugin From Plugin List

I was recently working on a client site, which required me to create a custom plugin for his website. I wanted to hide the plugin from the user, as he was a beginner and the plugin contained some sensitive functions to run his website.

In this snippet, I’ll show you how you can easily hide a WordPress plugin from the plugin list. The plugin will still work, but just won’t appear in the plugin list.

Just add the following snippet to your current theme’s functions.php file:

function hide_my_plugin() {
    global $wp_list_table;
    $hidearr = array('plugin-directory/plugin-file.php');
    $myplugins = $wp_list_table->items;
    foreach ($myplugins as $key => $val) {
        if (in_array($key,$hidearr)) {
            unset($wp_list_table->items[$key]);
        }
    }
}
add_action('pre_current_active_plugins', 'hide_my_plugin');

Replace plugin-directory/plugin-file.php in above code with your plugin’s directory and file name. You can find this info by clicking on edit plugin link from the plugin list.

What about Multisite?

If you wanna hide the plugin from your WordPress Multisite, then you above snippet will not remove the plugin from the Network admin list. Here’s a snippet which will work on the WordPress Multisite

function mu_hide_plugins_network( $plugins ) {
    // let's hide akismet
    if( in_array( 'akismet/akismet.php', array_keys( $plugins ) ) ) {
        unset( $plugins['akismet/akismet.php'] );
    }
    return $plugins;
}
 
add_filter( 'all_plugins', 'mu_hide_plugins_network' );
11 May, 2014 — Development, WordPress

Sitewide Message WordPress Plugin

WordPress Sitewide Message

Sitewide Message Plugin for WordPress is a plugin to allow you to simply add a banner message to the top of your website. It will display all the time on any page.

Features

It’s a simple plugin, but here’s what’s on offer:

  • Like message to any page or website
  • Change the font colour
  • Change the background colour
  • Custom text

Coming Soon

Some funky features are coming soon!

  • Scheduled Message
  • Link Location (new window / same window)

You can install it from the plugin’s page of your WordPress dashboard or get more information and download the plugin from the official Sitewide Message page.

8 May, 2014 — Development, Snippets, WordPress

Scheduled Content WordPress Plugin

Scheduled Content Plugin for WordPress is a plugin for easily scheduling content to be shown or hidden on set dates down to the hour and minute.

I first released this plugin over a year ago now; branded to an old company of mine, however with the recent update I have added some new features; as well as cleaned up the code. You will also see I have re-branded it to That Blogger.

Features

It’s a simple plugin, but here’s what’s on offer:

  • Allows shortcodes in the content
  • Schedule show date
  • Schedule show date  inc time
  • Schedule expiry date
  • Schedule expiry date inc time

Example

Here is a quick example of how to use the plugin. Just install and activate the plugin and wrap anything you want to schedule in a [schedule] tag.

[schedule on='2014-12-01' at="10:01" expon='2014-12-01' expat="13:15"] the content you want to hide here [/schedule]

You can install it from the plugin’s page of your WordPress dashboard or get more information and download the plugin from the official Scheduled Content page.

25 April, 2014 — Snippets, WordPress

Increase WordPress Memory Limit

If you use WordPress often or have a lot of plugins installed you may have come across a PHP memory limit error. This happens when WordPress doesn’t have enough memory to achieve what you are trying to do.

In version 2.5 the WordPress core team added a wp-config.php option WP_MEMORY_LIMIT which allows you to configure the maximum amount of memory that can be used by PHP.

Changing this option in the wp-config.php will only affect your WordPress site and not any other PHP sites.

The default memory allocated to WordPress is 40MB for normal WordPress installations and 64MB for multisite installs. The core will also take into account the php.ini file if there is one and if this number is greater than the default 40MB allocated by WordPress the higher number will then be used.

To change the WordPress memory limit you just add the following into the wp-config.php.

define('WP_MEMORY_LIMIT', '64M');

If this doesn’t change your allocated memory limit your hosts may not allow you change this setting, if this is the case you should contact your hosting company.

9 January, 2014 — Development, Snippets, WordPress

Create a “Recent Posts” Module Outside of WordPress

Not all websites run on WordPress, but some websites might decide to use WordPress as their blogging choice. They decide they want to display the recent posts from the blog on the website. However the website isn’t in the WordPress core. So how do we display the recent posts on the website?

The Code

To be able to use WordPress outside of the WordPress core is simple. Just include the 

wp-load.php
 file in your website:

// Include the wp-load from WordPress Install
include('wp-load.php');

// Get the last 10 posts
$recent_posts = wp_get_recent_posts(array(
    'numberposts' => 10
));

// Output the posts
echo '<ul>';
foreach($recent_posts as $post) {
    echo '<li><a href="', get_permalink($post['ID']), '">', $post['post_title'], '</a></li>';
}
echo '</ul>';

Once you have the 

wp-load.php
 file included, the entire WordPress core is open to use!