• 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.

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

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • PHP Snippet to Hide AdSense Unit on WordPress 404 Page

    Here is Easy PHP Snippet to Hide AdSense Unit on WordPress 404 Page to Avoid Policy Violation and Decrease False Impression, False Low CTR.

  • OpenStack Swift & HPCloud CDN PHP Bindings : Basics

    Here is the basics of OpenStack Swift & HPCloud CDN PHP Bindings for the WordPress Plugin developers and those who works with PHP based CMS.

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

  • PowerAmp Settings for Higher Sound QualityOctober 4, 2023
  • Affordable Earphone/IEM for Audiophiles: HiFiMan RE-400 WaterlineOctober 2, 2023
  • What is Hardware Security Module (HSM)September 30, 2023
  • Transducer Technologies of HeadphonesSeptember 28, 2023
  • What is Analog-to-Digital Converter (ADC)September 27, 2023
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