Git Command Line Snippets: Update Name and Email

GitHubThis post is part of the series on Git Command Line Snippets where I am taking a look at performing actions on GitHub using the git command line.

Before you start using Git you need to enter your credentials to identify yourself as the author. The name and email address should both be set to the same as the ones you use in GitHub.

To set your username you can use this command:

git config --global user.name "azurecurve"

To set your email address you can use this command:

git config --global user.email "github@example.co.uk"

Git Command Line Snippets: Series Index

GitHubBack in April 2020, I did a series on using GitHub when developing for ClassicPress. More recently I have started to take a look at using the git command line to help automate making commits, releases and other actions. I’ m going to use this git snippets series to record the commands I have been using.

You can use an ordinary Windows command prompt or PowerShell to run git commands; I started out using command line, but did move onto running them in PowerShell as soon as I wanted to run commands sequentially.

If you’re reading this post on azurecurve | Ramblings of an IT Professional, then the post will automatically refresh otherwise check Git Command Line Snippets for new posts.

Continue reading “Git Command Line Snippets: Series Index”

azurecurve ClassicPress Plugins: Load Admin CSS

ClassicPress PluginsThis is part of the azurecurve ClassicPress Plugins series which introduces the plugins I have available for ClassicPress.

The plugin I am going to cover in this post, is one written specifically for ClassicPress ; Load Admin CSS.

Functionality

Change the styling of your admin dashboard with custom CSS.

Options are maintained via a Settings page on the **azurecurve** menu.

Example CSS usage to change the font size in the textarea:

textarea.wp-editor-area{
	font-size: 1.33em;
}

This plugin is multisite compatible, with options set on a per site basis.

Download

The plugin can be downloaded from my GitHub.

Click to show/hide the azurecurve ClassicPress Plugins Series Index

azurecurve ClassicPress Plugins: Strong Password Generator

ClassicPress PluginsThis is part of the azurecurve ClassicPress Plugins series which introduces the plugins I have available for ClassicPress.

The plugin I am going to cover in this post, is one written specifically for ClassicPress ; Strong Password Generator.

Functionality

Create password forms allowing users to create strong passwords consisting of upper/lower case letters, numbers and symbols.

Options are maintained via a Settings page on the **azurecurve** menu.

Password forms are placed using the `strong-password-generator` shortcode and can have a number of parameters supplied to override the defaults from the options page; each shortcode must have an `id` parameter supplied. Available parameters are:

  • password-length – length of password to be generated.
  • password-minimum-length – minimum length of passwords which can be generated.
  • password-maximum-length – maximum length of passwords which can be generated.
  • password-number – number of passwords to generate.
  • password-maximum-number – maximum umber of passwords which user can generate.
  • text-before – text to display before password form.
  • text-after – text to display after password form.
  • label-password-length – label for password length field.
  • label-password-number – label for number of passwords to generate field.
  • label-lowercase – label for valid lowercase field.
  • label-uppercase – label for valid uppercase field.
  • label-numeric – label for valid numbers field.
  • label-symbols – label for valid symbols field.
  • allow-lowercase – allow user to include uppercase characters.
  • allow-uppercase – allow user to include uppercase characters.
  • allow-numeric – allow user to include number.
  • allow-symbols – allow user to include symbols.
  • valid-lowercase – list of valid lowercase characters.
  • valid-uppercase – list of valid uppercase characters.
  • valid-numeric – list of valid numbers.
  • valid-symbols – list of valid symbols.

Example shortcode usage:

[strong-password-generator id="password-1"  text-before="The password generator below can be used to produce passwords compatible with Microsoft Dynamics GP." allow-symbols=1]

This plugin is multisite compatible, with options set on a per site basis.

Download

The plugin can be downloaded from my GitHub.

Click to show/hide the azurecurve ClassicPress Plugins Series Index

azurecurve ClassicPress Plugins: Contact Forms

ClassicPress PluginsThis is part of the azurecurve ClassicPress Plugins series which introduces the plugins I have available for ClassicPress.

The plugin I am going to cover in this post, is one written specifically for ClassicPress; Contact Forms.

Functionality

A simple contact forms plugin with an options page allowing default settings to be configured; these settings can, in most cases, be overridden when adding a contact form to a page. This plugin supports the use of multiple contact forms on a page.

Contact forms can be placed on pages using the simple-contact-form shortcode which supports the following parameters:

  • id is the only mandatory parameter; a unique id for each contact form on the page must be supplied.
  • send-from-email allows the default send from email address to be overridden.
  • send-from-name allows the default send from email name to be overridden.
  • recipients is a comma separated list of email address which allows the default recipients to be overridden.
  • label-name allows the default label for the name field to be overridden.
  • label-email allows the default label for the email field to be overridden.
  • label-subject allows the default label for the subject field to be overridden.
  • label-message allows the default label for the message field to be overridden.
  • subject allows the default subject for the name field to be overridden. If an empty subject is provided, users can free form type a subject. Multiple subjects to allow picking from a drop down list can be supplied, separated with a |.
  • subject-prefix allows a subject prefix to be added to all subjects when the email is sent and override the default.

Example shortcode usage:

[simple-contact-form id="contact-us" recipients="bob@example.com,jane@example.com" subject="Sales|Support|Accounts" subject-prefix="Contact us from example.com:"]

This plugin is multisite compatible, with options set on a per site basis.

Download

The plugin can be downloaded from my GitHub.

Click to show/hide the azurecurve ClassicPress Plugins Series Index

azurecurve ClassicPress Plugins: Redirect

ClassicPress PluginsThis is part of the azurecurve ClassicPress Plugins series which introduces the plugins I have available for ClassicPress.

The plugin I am going to cover in this post, is one written specifically for ClassicPress ; Redirect.

Functionality

Redirect URIs with a 301 (permanent) or 302 (temporary) redirect; redirects can be edited, toggled on/off and easily deleted if required.

URLS for redirect can be added manually, or you can enable automatic redirect when a permalink is changed.

This plugin is multisite compatible, with options set on a per site basis.

Download

The plugin can be downloaded from my GitHub.

Click to show/hide the azurecurve ClassicPress Plugins Series Index

ClassicPress Petitions — Let Your Voice Be Heard

ClassicPressClassicPress started life as a hard-fork of WordPress 4.9; one of the differentiators is the Gutenberg block editor which started by replacing the TinyMCe editor (now generally referred to as the “classic editor”) and is now beig rolled out through other part of a WordPress site.

However, this is just one of the differentiators. One of the largest other differences is the decision making process used by ClassicPress is petition based with the community casting votes instead of a small number of contributors, or even one man, making the decision.

Viktor Nagornyy has a very good write up of the petition process. If you’re a member of the ClassicPress community, or a WordPress user looking for an alternative where you can make a difference, check out the petitions available for voting upon.

ClassicPress Plugin Development: Save an Options Page

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

Once you have an options page created, you need to create the process to save the options when the user changes them.

The example I am using in this post is from my Remove Revisions plugin which uses a PHP namespace.

namespace azurecurve\RemoveRevisions;

Continue reading “ClassicPress Plugin Development: Save an Options Page”

ClassicPress Plugin Development: Create an Options Page

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

Anything more than a very simple plugin will hae options which the site administrator will need to be able to change. this means an options page which is added to the settings menu. ClassicPress does have a settings API which can be used; however, I do not use this API as I’ve previously found it to be overly complex and difficult to use, so I roll my own settings pages.

The example in this post are from my Remove Revisions plugin which uses a namespace:

namespace azurecurve\RemoveRevisions;

As I am using a namespace the options page was added in a function simply called display_options; if a namespace wasn’t in use, I’d have used a vedor/plugin prefix and called the function azrcrv_rr_display_options.

The example takes advantage of the page title from the settings menu (which I covered in the last post as well as loading options, which can be done
with defaults or with with multilevel defaults.

Below is a sample of the display_options from Remove Revisions with the controls removed, leaving behind the basic framework of the page, with the header, load of options and then the form with submit button:

/**
 * Display Settings page.
 *
 * @since 1.0.0
 *
 */
function display_options(){

	if (!current_user_can('manage_options')){
        wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'remove-revisions'));
    }
	
	// Retrieve plugin configuration options from database
	$options = get_option_with_defaults('azrcrv-rr');	
	
	?>
	
	<div id="azrcrv-rr-general" class="wrap">
		
		<h1>
			<?php
				esc_html_e(get_admin_page_title());
			?>
		</h1>
		
		<form method="post" action="admin-post.php">
			
			<input type="hidden" name="action" value="azrcrv_rr_save_options" />
			<input name="page_options" type="hidden" value="enable-cron" />
			
			<?php
				//
				wp_nonce_field('azrcrv-rr', 'azrcrv-rr-nonce');
			?>
			
			/*
				your options here
			*/
			
			<input type="submit" name="btn_save" value="<?php esc_html_e('Save Settings', 'remove-revisions'); ?>" class="button-primary"/>
		</form>
	</div>
	<?php
	
}

The hidden input action and the wp_nonce_field is used for the save of the options, which I’ll cover in the next post in this series.

Click to show/hide the ClassicPress Plugin Development Series Index

ClassicPress Plugin Development: Get Options Page Title

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

Over the last couple of posts in this series, I’ve discussed how options can be loaded and saved, loaded with defaults and loaded with multilevel defaults. Over the next couple of pages, I’m going to show how an options page can be created and the options saved, but first a quick post on how the options page title can be populated.

I’ve seen a lot of plugins where the options page title has been a string which has been echoed. However, when the options page is added to the settings main menu, the first parameter is the page title. So instead of echoing a new string, we can use the get_admin_page_title function to get the title set when the options page was added to the menu.

<h1>
	<?php
		esc_html_e(get_admin_page_title());
	?>
</h1>

As you can see from the example code, above, the call to get_admin_page_title has been wrapped with a esc_html_e to echo and escape the page title.

Click to show/hide the ClassicPress Plugin Development Series Index