Add Twitter Card to WordPress without Plugin

Reading this blog, one may think I focus on WordPress development and enhancements. That is not the case by any means. The focus of my career focused on the implementation of Microsoft Dynamics 365 Business Central. The concept behind this blog is to share bits of [technical] “stuff” that I encounter on my journey. The WordPress concepts come into play as I continue to enhance this site.

Sharing the content on this site on social platforms is another way to relay information that may be helpful to some. I recently became more active in the following Twitter posts and felt that it would be an excellent platform to share my blog posts. 

I went over to Twitter, pasted the link to a blog post that I wanted to share, and hoped to see a “preview” of the content. Well, I was wrong. The only thing in the “tweet” was the link to the post. After a bit of digging, I found that there is a “Twitter Card.” The Twitter Card is meta-information on the page of your site that relays to Twitter how the page preview should look in a Tweet. I found that there is a Twitter Card Validator that will alert you of any Twitter Card issues for the link that you’d like to Tweet. Of course, my post failed validation.

Several WordPress Plugins are available that add Twitter Cards to your pages, but I prefer to use as few Plugins as possible to reduce the risk of any issues. Just as I did when changing the Login Page, I opted to get the Cards onto my posts myself through functions and actions.

Add the following to your Theme’s functions.php file (replace the image url and the twitter creator tag with your image and tag):

function twittercard()
{
	if(is_single() || is_page()) {
    	$twitter_title  = get_the_title();
		$twitter_url    = get_permalink();
		$twitter_desc   = get_the_excerpt();
		$twitter_image	= 'https://www.dvlprlife.com/tweetimage.jpg?rating=PG&size=75';
		
		echo '<meta name="twitter:card" value="summary" />';		
		echo '<meta name="twitter:title" value="'  . $twitter_title . '" />';
		echo '<meta name="twitter:url" value="' . $twitter_url . '" />';
		echo '<meta name="twitter:description" value="' . $twitter_desc . '" />';
		echo '<meta name="twitter:image" value="' . $twitter_image . '" />';

		echo '<meta name="twitter:creator" value="@dvlprlife" />';
	}
}

add_action('wp_head', 'twittercard');

 

Please note that doing this without a plugin does require some programming knowledge, and before ever making any changes, you should always back up your site.

Make a note and save the code added; if the function.php file is updated and replaced, the code will need to be added to the file again. You can also look into setting child themes to keep you from losing the edit.

Permanent link to this article: https://www.dvlprlife.com/2022/05/add-twitter-card-to-wordpress-without-plugin/

Delete files within subfolders older than a certain period using PowerShell

In keeping true to the concept of this blog, “Follow the life of an ERP developer, one post at a time,” this post allows you to “follow” something that I needed to crush – deleting files older than a specific number of days or hours including subfolders.

Many moons ago, I created an application that created log files capturing event details. The log files’ sole Delete Key In Bluepurpose was to review events and troubleshoot issues when processing these events. The files are saved in a folder structure divided and grouped by Year, Month, and Event Type. The grouping is helpful for troubleshooting and finding specific transactions, but with several types of events and, at times, a decent volume, there can be a decent amount of disk space wasted; realistically, there isn’t a need to keep diagnostic logs forever. The data does become stale after a certain period.
I created this PowerShell script to delete files from a folder and subfolders older than a certain number of hours from the time of script execution:

$sourcepath = 'D:\Archive\'
$CurrDate = Get-Date
$MaxHours = -1200

Foreach($folder in (Get-ChildItem $sourcepath -Recurse  | where {  $_.PSIsContainer }))
{
    #"Folder: $folder"
    Foreach($file in (Get-ChildItem $folder.FullName | where { ! $_.PSIsContainer }))
    {
	#"File: $file"
        if($file.LastWriteTime -lt ($CurrDate).AddHours($MaxHours))
        {
	        #"Filter File: $file"
            Write-Host -ForegroundColor Yellow ($file.FullName) 
            Remove-Item $file.FullName
        }
    }
}

If you want to specify the number of days, replace:

if($file.LastWriteTime -lt ($CurrDate).AddHours($MaxHours))

with

if($file.LastWriteTime -lt ($CurrDate).AddDays($MaxDays))

Remember to replace the $MaxHours variable with $MaxDays.

Permanent link to this article: https://www.dvlprlife.com/2022/05/delete-files-within-subfolders-older-than-a-certain-period-using-powershell/

How to Delete a Sprint in Azure DevOps

When working with Project Planning in Azure DevOps, Sprints are easy to create and assign to Work Items. While there is an easy way to make a Sprint, the option to delete a sprint in Azure DevOps isn’t quite as obvious. It may not often be that you want to delete a sprint (which may be why it isn’t glaring us in the face), but if you play around with Planning and Sprints, you may find yourself needing to delete a sprint (or more) from a project in Azure DevOps

To delete a Sprint in AzureDevOps:

  1. Go to Project Settings
  2. Go into the Project Configuration in the Boards section of the Project Settings
  3. Find the sprint that you’d like to delete and click the ellipsis to open up an additional Menu
  4. Click Delete Menu Item

Delete a sprint in Azure DevOps

Deleting a Sprint may not be something you may not need to do often, but if you do – now you know!

Permanent link to this article: https://www.dvlprlife.com/2022/05/how-to-delete-a-sprint-in-azure-devops/

May 2022 Cumulative Updates for Dynamics 365 Business Central and Microsoft Dynamics NAV

The May updates for Microsoft Dynamics NAV and Microsoft Dynamics 365 Business Central are now available.

Before applying the updates, you should confirm that your implementation is ready for the upgrade and
ensure compatibility with your modifications. Work with a Microsoft Partner to determine if you are ready and what is needed for you to apply the update.

Please note that SaaS customers will automatically be upgraded to 20.1 over the coming days/weeks and should receive an email notification when upgraded.

Direct links to the cumulative updates are listed here:

Dynamics 365 Business Central On-Premises 2022 Release Wave 1 Updates – Update 20.1 (May 2022)

Dynamics 365 Business Central On-Premises 2021 Release Wave 2 Updates – Update 19.7 (May 2022)

Dynamics 365 Business Central On-Premises 2021 Release Wave 1 Updates – Update 18.13 (May 2022)

Dynamics 365 Business Central On-Premises 2020 Release Wave 2 Updates – Update 17.17 (April 2022)

Dynamics 365 Business Central On-Premises 2020 Release Wave 1 Updates – Update 16.17 (October 2021)

Dynamics 365 Business Central On-Premises 2019 Release Wave 2 Updates – Update 15.17 (April 2021)

Dynamics 365 Business Central On-Premises Spring 2019 Updates – Update 35 (May 2022)

Dynamics 365 Business Central On-Premises October’18 Updates – Update 18 (April 2020)

Microsoft Dynamics NAV 2018 – Update 52 (May 2022)

Microsoft Dynamics NAV 2017 – Update Update 61 (January 2022)

Microsoft Dynamics NAV 2016 – Update 67 (July 2021)

Permanent link to this article: https://www.dvlprlife.com/2022/05/may-2022-cumulative-updates-for-dynamics-365-business-central-and-microsoft-dynamics-nav/

Business Central 2022 Wave 1 – Users can Export Report Datasets to XML

With each update of Dynamics 365 Business Central, Microsoft enhances what is often referred to as the base application and enhances the development environment. Dynamics 365 Business Central 2022 Wave 1 has several exciting new features in the development environment. One of the exciting features is that Users can Export Report Datasets to XML.

Users and developers can get report datasets in XML format, which they can then archive, use for integration scenarios or troubleshoot the reports during development.

Similar to the Export dataset to Excel (no layout) capability added in Dynamics 365 Business Central 2021 release Wave 1, business users and developers can now get report datasets in XML directly from the Send to section of the request page.

To export the data to an XML file:

  • Open the report request page and enter the desired filters
  • Click the Send to action
  • Choose XML and then OK

The Send to XML document renders the report data to an XML file.

Permanent link to this article: https://www.dvlprlife.com/2022/05/business-central-2022-wave-1-users-can-export-report-datasets-to-xml/

Business Central 2022 Wave 1 – Demo Tool and Demo Data for Manufacturing Scenarios

With each update of Dynamics 365 Business Central, Microsoft enhances what is often referred to as the base application and enhances the development environment. Dynamics 365 Business Central 2022 Wave 1 has several exciting new features in the development environment. One of the exciting features is the long awaited addition of a Demo Tool and Demo Data for Manufacturing Scenarios.

The demo tool and data contain products that demonstrate various manufacturing scenarios. There are demonstration data to show sub-contractors, sub-assemblies, Item tracking, and Variants, among several other functions.

The demo tool is available for both On-Premise and SaaS implementations. SaaS implementations install the tool through AppSource and the product media for On-Premise deployments.

In the SaaS Environment, the applications can be installed via AppSource. Open the Extension Marketplace and search for “Contoso Coffee,” and click Get It Now for the app-specific to your country id of Business Central. Once the extensions are installed, they will be visible on the extension management page.

Customers who have an On-Premises Business Central installation can find the media in the country-specific Applications folder within the installation media.

The demo tool adds several items geared toward something many of us enjoy – Coffee. You are in control of the Contoso Coffee Company.

There is the SP-SCM1009 Airpot which is a product with a bill of material (BOM), a subassembly, and Routing. The SP-SCM1009 Airpot demonstrates the standard production flow. The SP-SCM1011 Airpot Duo requires item tracking and uses components that also need item tracking. Another item, SP-SCM1004 Autodrip, has been set up to demonstrate various flushing methods for components and operations using Standard Cost. Item SP-SCM1008 Autodrip Lite has been added to the Item List to show the use variants.

Permanent link to this article: https://www.dvlprlife.com/2022/05/business-central-2022-wave-1-demo-tool-and-demo-data-for-manufacturing-scenarios/

Change WordPress Login Page without a PlugIn

WordPress is the most popular way to create your website or blog. It is an open-source content management system that allows you to manage important aspects of your website without knowing anything about programming. WordPress also supports plugins, which are small applications that work within the software framework to offer additional functionality. 

This blog is running WordPress (I am not giving away any big secret as it is easy enough to find this out). WordPress has the popularity, leaving many “bad actors” who try to compromise WordPress sites with brute force login attacks. There are plugins available, such as Limit Login Attempts Reloaded, that help prevent malicious attacks targeting your login page. With this plugin, you can limit the number of failed login attempts and lock out users who attempt to login incorrectly on several attempts.

Another way to protect your WordPress Site from brute force login attacks is to change your login page. Changing your login page makes it more difficult for malicious login attempts because your login is not one of the known login pages. Several plugins are available for you, but it is easy to do without adding additional plugins to your site. Using a Plugin generally does not require any programming knowledge. Please note that doing this without a plugin  does require some programming knowledge, and before ever making any changes, you should always back up your site.

  1. The default login page is wp-login.php. Download this file from your website and open it with a text editor.
  2. Replace all occurrences of wp-login.php in the file with the name of the file you’d like for your login page (keep the PHP extension)
  3. Save the file with the same name you replaced the wp-login.php page value with in the file.
  4. Delete or rename the old wp-login.php file
  5. Upload your new login file
  6. You can now log in using the link <homepage WordPress baseurl>/<your login page>; replace the values with your values.

WordPress allows for filter hooks to override specific actions within the framework. After you rename the login page, you should set a few hooks to properly redirect a user when they log out of your site.

add_filter( 'logout_url', function(){
	$login_url = wp_nonce_url(site_url('.php')."?action=logout", 'log-out');
	return $login_url;						  
}, 30, 2);
add_filter( 'logout_redirect', function() {return esc_url( home_url() );}, 30, 2 );

The above hooks will set urls to use when a user logs out of your site and the page they will be redirected after the logout.

Add the hooks to the functions.php file of your theme. Make a note and save the code for the hooks added. If the function.php file is updated and replaced the hooks will need to be added to the file again.

Note: There is a hook for the ‘login_url’ if you want the default login to route to your new page. Setting the hook does make the page visible again as a different page name. Do not set the hook if you intend to mask this page to make it more difficult to find.

Permanent link to this article: https://www.dvlprlife.com/2022/05/change-wordpress-login-page-without-a-plugin/

Business Central 2022 Wave 1 – Multiple Report Layouts in Reports and Report Extensions

With each update of Dynamics 365 Business Central, Microsoft enhances what is often referred to as the base application and enhances the development environment. Dynamics 365 Business Central 2022 Wave 1 has several exciting new features in the development environment. One of the exciting features is the option for multiple report layouts within a single report or report extension. This provides report developers the option to add alternative layout options in a single report or report extension.

In earlier versions of Dynamics 365 Business Central, you could only embed a single layout of each report layout type (RDLC or Word) in a report or report extension. If there were a need to have additional layouts, the layout was setup as Custom Report Layout. In Dynamics 365 Business Central 2022 Wave 1 a new Rendering section has been added; you can now include multiple layouts of different or the same type.

Rendering Section

Rendering Section

To enable multiple layouts, you must use the Rendering section of a report object. Inside the Rendering section, you define one or more layout sections. In each layout section, you specify details about the layout file path and name, a Caption property, and a Summary property, which is displayed to the user on the Report Layouts page in Dynamics 365 Business Central.

The default layout is defined with the DefaultRenderingLayout report property. Note: This DefaultRenderingLayout property cannot be set on report extension objects, only on report objects.

DefaultRenderingLayout Property

DefaultRenderingLayout Property

When a report with multiple layouts is loaded, the report layouts are visible on the Report Layout Page. The layout is selected on the Report Layout Selection Page.

Note: The old properties for defining RDLC, Word, and the default layout, still exist but cannot be used in combination with the new rendering section. A report author must use one or the other.

See What’s new and planned for Dynamics 365 Business Central for additional information.

Permanent link to this article: https://www.dvlprlife.com/2022/05/business-central-2022-wave-1-multiple-report-layouts-in-reports-and-report-extensions/

Repository-specific username/email configuration

You set up your repository. You cloned the repository and made some changes. You commit your changes and get the error – Make sure you configure your ‘user.name’ and ‘user.email’ it git

Make sure you configure your 'user.name' and 'user.email' it git

When working with Git as a source control management tool, you need to have defined the user name and email config value when checking in code. These values identify the user in commits. If you don’t have these configured, you’ll see a message – Make sure you configure your ‘user.name’ and ‘user.email’ it git

The username/email configuration can be set globally or at the project level.

To set your global username/email configuration:

  1. Open the terminal command line.
  2. Set your username: git config ––global user.name “<your name>”
  3. Set your email address: git config ––global user.email “youremail@example.com”

To set repository-specific username/email configuration:

  1. From the command line, change into the repository directory.
  2. Set your username: git config user.name  “<your name>”
  3. Set your email address: git config user.email “youremail@example.com”

Verify your configuration by displaying your configuration value –

git config ––get user.email
git config ––get user.name

Permanent link to this article: https://www.dvlprlife.com/2022/05/repository-specific-username-email-configuration/

Hello, World!

If you are new to or familiar with computer programming, you’ll most likely be familiar with “Hello, World!”

“Hello, World!” is typically the first program that someone learns to write and is often used to test that the compiler is installed correctly.

I am not new to blogging and community involvement; however, I have stepped away from it for a while and wanted to get back into it and share my experiences and what I learned along the way.

Well, friends, this post is my “Hello, World!” for this site.

Permanent link to this article: https://www.dvlprlife.com/2022/05/hello-world/