• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » WordPress Plugin to Avoid Snippet on Theme’s functions.php

By Abhishek Ghosh May 28, 2016 1:18 am Updated on May 28, 2016

WordPress Plugin to Avoid Snippet on Theme’s functions.php

Advertisement

As all know, adding snippet on Theme’s functions.php or Child Theme’s functions.php is not good. Here is a WordPress Plugin to Avoid Snippet on Theme’s functions.php. In this new version you can drop the snippets as PHP files from SFTP. In Our Previous Article and Release of Previous Version We Discussed Why That is Bad.

 

WordPress Plugin to Avoid Snippet on Theme’s functions.php

 

First read the previous guide and understand how that old version worked. We have WordPress Template for Plugins. In my GitHub repo, you will get all kind of templates.

This current one has added one PHP function. We have a subdirectory inside the plugin named snippets. With PHP function, we are fetching the php files from that :

Advertisement

---

Vim
1
2
3
4
foreach (glob("snippets/*.php") as $filename)
{
    include $filename;
}

Here is the Plugin on GitHub repo, you can download and install it.

Previously, as example if you were following this guide to remove WordPress post image linking, you were adding this kind of snippet :

Vim
1
2
3
4
5
6
7
8
9
10
11
function k99_image_link_void( $content ) {
    $content =
        preg_replace(
            array('{<a(.*?)(wp-att|wp-content\/uploads)[^>]*><img}',
                '{ wp-image-[0-9]*" /></a>}'),
            array('<img','" />'),
            $content
        );
    return $content;
}
add_filter( 'the_content', 'k99_image_link_void' );

With this plugin, you can save this snippet as PHP file with a meaningful name like remove-image-link.php and directly drop inside the /snippets/ directory of the plugin.

Instead of using :

Vim
1
include dirname(__FILE__)."/example.php";

we are fetching all the files from the snippets directory. Many use this in WordPress development :

Vim
1
include "./common.php";

like lines. That most likely to fail when the script is invoking include when it is actually being included by another script in another directory. Our snippet is slightly different. It will avoid to load one single PHP when it has dependency on other files. It is tricky usage to avoid collision. We have lot of such useful WordPress snippets.

Those who are new WordPress users, they should not use that method. They should activate the Plugin. Go to Plugins > Editor and select our Plugin. Thereafter select the included default.php file inside snippets directory. Then paste the PHP code, and save the file. That is shown in this screenshot :

WordPress Plugin to Avoid Snippet on Theme’s functions-php

Here is the full size image.

 

Report Bug Against This WordPress Plugin to Avoid Snippet on Theme’s functions.php

 

So far, we have no target to make the plugin available in WordPress Repo. When we develop for official repo, we have to add more lines for near perfect coding. Our FTP to Zip WordPress Backup Plugin. There are newbie “white hackers”. They open security issue without reading the details. It is for helping to somehow rescue from a bad shared host. It is a wastage of time to argue and show point. Many developers are keeping advanced plugins in GitHub or own server. Additionally SVN (which WordPress uses) is a painful system to update. SVN via Git has problems too.

This Article Has Been Shared 317 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to WordPress Plugin to Avoid Snippet on Theme’s functions.php

  • Taxonomy in WordPress : how to use WordPress Taxomonies effectively

    Taxonomies in Wordpress can be used to arrange, classify and group post. Learn how you can use Taxomomies in Wordpress effectively.

  • Best AdSense Ad Code Injector Plugin For WordPress : Ad Injection

    Best AdSense Ad Code Injector Plugin For WordPress currently available is Ad Injector. This plugin can help for logical category wise custom ad unit injection.

  • List of Open Source PHP MySQL Based Blogging Softwares

    List of Open Source PHP MySQL Based Blogging Softwares lists the most commonly used and available softwares those can run on any LAMP server easily.

  • YouTube Tips : Embed Playlist, YouTube’s audio, YouTube HTML5 Player

    Here are YouTube Tips to Embed YouTube Playlist, YouTube’s audio, YouTube HTML5 Player in any webpage or WordPress page or posts. Let us see how we can do them.

  • TechArticle schema : Implementing in WordPress

    TechArticle schema is a specification described under Article, which is under CreativeWork, which is under Thing. Here is how to implement TechArticle schema.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023
  • What is Vehicular Ad-Hoc Network? January 24, 2023
  • Difference Between Panel Light, COB Light, Track Light January 21, 2023
  • What is COB LED? How LED Chip On Board Works January 20, 2023

About This Article

Cite this article as: Abhishek Ghosh, "WordPress Plugin to Avoid Snippet on Theme’s functions.php," in The Customize Windows, May 28, 2016, January 27, 2023, https://thecustomizewindows.com/2016/05/wordpress-plugin-to-avoid-snippet-on-themes-functions-php/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT