steelbridge.io

Website Engineering With A Passion For Quality

Celtein Text Widget

A custom plugin developed to add colors and styles matching the legacy styles of a website produced in the 90’s. Retro!! Love it.

<!--?php /* Plugin Name: Celtein Text Widget
Plugin URI: https://steelbridge.io/celtein-text-widget/
Description: Celtein Text Widget adds a custom text widget to the Celtein Theme that allows for a custom styled text area
Version: 1..0.0
Author: Chris Parsons Author
URI: https://steelbridge.io License: GPL v3
*/



// If this file is called directly, abort. if ( ! defined( 'WPINC' ) ) { die; } define( 'CELTEIN_TEXT_WIDGET_VERSION', '1.0.0' ); class CelteinText_Widget extends WP_Widget { public function __construct() { parent::__construct( 'celteintext_widget', __( 'Celtein Text Widget', 'celteintextdomain' ), array( 'classname' =&gt; 'celteintext_widget',&lt;br ?--> 'description' =&gt; __( 'A basic text widget developed for the Celtein theme.', 'celteintextdomain' )
)
);

load_plugin_textdomain( 'celteintextdomain', false, basename( dirname( __FILE__ ) ) . '/languages' );

}

/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/

public function widget( $args, $instance ) {

extract( $args );

$title = apply_filters( 'widget_title', $instance['title'] );
$message = $instance['message'];

echo $before_widget . '
<div class="card-class">

'
;

if ( $title ) {
echo $before_title . $title . $after_title;
}

echo '
<div class="textwidget">'
. $message . '</div>
'
. '

</div>
'
;
echo $after_widget;

}

/**
* Sanitize widget form values as they are saved.
*
* @see WP_Widget::update()
*
* @param array $new_instance Values just sent to be saved.
* @param array $old_instance Previously saved values from database.
*
* @return array Updated safe values to be saved.
*/

public function update( $new_instance, $old_instance ) {

$instance = $old_instance;

$instance['title'] = strip_tags( $new_instance['title'] );
$instance['message'] = ( $new_instance['message'] );

return $instance;

}

/**
* Back-end widget form.
*
* @see WP_Widget::form()
*
* @param array $instance Previously saved values from database.
*/

public function form( $instance ) {

$title = esc_attr( $instance['title']);
$message = esc_attr($instance['message']); ?&gt;

<label for="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;"><!--?php _e('Title:'); ?--></label>


<label for="&lt;?php echo $this-&gt;get_field_id('message'); ?&gt;"><!--?php _e('Text &amp;amp; HTML'); ?--></label>
<textarea id="&lt;?php echo $this-&gt;get_field_id('message'); ?&gt;" class="widefat" cols="20" name="&lt;?php echo $this-&gt;get_field_name('message'); ?&gt;" rows="16">&lt;?php echo $message; ?&gt;</textarea>

<!--?php &lt;br ?--> }

}

/* Register the widget */
add_action( 'widgets_init', function(){
register_widget( 'CelteinText_Widget' );
});

Warning: Fatal Error

Plugin Trouble: WordPress

A fairly common occurrence users of WordPress experience is known as the “white screen of death”. Well, it’s not death and really it’s not the end of the world either. Although some of you panic when your website decides to stop working.

Typically the white screen is accompanied by a couple paragraphs of text signaling you with “Warning” and “Fatal Error”. This is happening because WordPress can’t load the contents of your website. If you look at the statements maybe you can see the word ‘plugins’ located in the file directory string. I have included a photo below where I have circled the file folder in question.

fatal error plugins

Most fatal errors are associated with a plugin issue.

So, if you see something like whats pictured above, I’ll share with you the solution to getting your site back.. alive and functioning.

Step 1.

Use your code editor, IDE ( Integrated Development Environment) to FTP (File Transfer Protocol) into your sites root directory. Not sure about this? Call your hosting company. I know of one hosting company that offers great support for customers like you. Find them here SteelBridge Media. I use Coda and Dreamweaver. Atom is another one that I like. Textmate, Sublime are a couple others that have served me well. I stick with the two spendy editors, Coda and Dreamweaver.

Anyway, your goal here is to connect via FTP so you can find the plugins folder within the WordPress file structure.

Step 2.

Once you’ve successfully connected to your host, look for the ‘wp-content’ folder, then find the plugins folder.

Step 3.

Rename the plugins folder to ‘plugins-og’. Renaming the plugins folder deactivates all the software contained inside. If you look inside the plugins folder, you’ll see a series of subfolders all containing the plugins you downloaded. One or more of those plugins are causing the trouble you’re experiencing.

plugins folder

The plugins folder can be accessed via ftp

Step 4.

Go to your browser and access “http://the-name-of-your-website-goes-here.com/wp-admin” (use ‘your’ domain name silly, not my example)

Log-in to your WordPress website and activate another theme. I use one of the default themes that come with WordPress upon installation. Pick the Twenty Sixteen theme and activate it. (From your WordPress dashboard, find themes here Appearance -> Themes. Hover over your the Twenty Sixteen theme or any other theme and select the activate button). Activating another theme allows you to see that your WordPress installation is okay. It’s okay because the newly activated theme works! Test your site out to be sure. If you can’t activate a new theme because there aren’t any themes, upload one. Look for the ‘Add New’ button. And if that still doesn’t work, you need to contact me.

Step 5.

Once you have proven out your site works, go back to your plugins folder you accessed via FTP. Open that folder and rename all your plugin sub-folders to end in ‘-og’ and restore the original name of the parent folder to ‘plugins’ (your parent folder was originally ‘plugins’, put it back to that .

Reactivate your original theme and test your site. Don’t be surprised to find stuff missing or non functional. The goal here is to see if your website loads and you don’t get the ‘Warning’ screen.

Once you can see your website loads with out errors (errors are messages that appear on your screen telling you shit is f’ed up) you’re ready for the next step.

Step 6.

Go back to your FTP client and start renaming/restoring original names of the plugins sub-folders ONE AT A TIME to their original name. That means removing the ‘-og ‘ I instructed you to attach to each file folder name. Again these are the files found in the plugins folder.

As you restore each file folder to original name, take some time to verify your site works. This is the whole point of this stage of the process. We are trying to isolate the offending plugin/folder. Test it, reload it. Clear your browser cache!!!

Eventually you will find the offending plugin when you test the site after restoring any given plugin folder name. You’ll know because the ‘white screen of death appears’.

Step 7.

Rename the folder that caused your site to ‘crash’. Yeah, the “white screen of death” thing. Crash means your site didn’t load. So, you saw the error message again. This means the last plugin you restored is a bad, very bad plugin. Delete it from within your WordPress dashboard. Why? Well, some plugins should go through an uninstall process controlled by a script included within the plugin’s folder. I avoid deleting from my IDE. Better yet.. just leave it renamed, then find the developer and reach out and share your experience. Most developers want to help and learn. Expect a reply!

At this point you can look for another similar plugin that provides the solution the offending plugin did at one time not so long ago. Additionally, Once again, you could try to contact the plugin developer and ask for an update. Or, maybe you shouldn’t be plugging around with any and all plugins online! Why? Because if you do that enough, you’ll catch website-crabs, browsyphilis, firefoxitis, safariamydia.

My advice is pay someone to develop a plugin for you. Someone who will keep your site healthy and produce custom plugins that are sanitary!

I can help you. Build plugins. I do that!

Questions? Send me your comments below.