Integrating WordPress Into PHP Scripts

Overview

Now, I had to use a custom made PHP script that I established a though in the past in a new WordPress application. Rather of creating a WordPress plugin to take care of this existing code, I pick out instead to use WordPress directly inside of my script.

Making use of WordPress inside of your script is a fantastic solution if you have a good deal of custom made PHP code.

When you have a big PHP code base from your earlier growth attempts. There are usually other libraries inside of your code, these types of as Symfony, Zend Framework, Pear, etcetera, that you do not want to acquire apart. You have performing code and you want it to keep together.

In my case, I had established a kind for knowledge collection for a consumer. But this was no common kind. It had over a hundred kind variables. They ended up produced up of textual content input, radio containers, checkboxes, and textarea’s. I preferred to use this kind directly inside of my WordPress application. As well as I preferred the integration to effortless.

The resolution was actually fairly easy.

Existing PHP Code

For instance, assume this is my existing PHP code (it is a easy script to illustrate this place).

<input type="text" name="first_name" value="”>

But the challenge is, that is only the kind to gather the knowledge. What about the glance and truly feel of the existing web site. How can I get the above code to glance like the exact template layout of my WordPress application.

For instance, a person resolution is to increase the raw HTML. But that is both of those time consuming, and it is not dynamic. If the WordPress template improvements, I have to go in below and manually modify it all over again. Not a little something I want to do.

My PHP Sort Page</p><form name="datacollection" method="post" action="index.php"> <input type="text" name="first_name" value="”></p></form></blockquote><p>But that wouldn’t accurately perform. I would have to match the navigation, contain the type sheets, and make certain the HTML matched accurately the glance and truly feel of my principal web site.</p><p><b>The Better Option</b></p><p>Instantiate WordPress, and use the developed in capabilities inside of your code.</p><blockquote><form name="datacollection" method="post" action="index.php"> <input type="text" name="first_name" value="”></p></form></blockquote><p>Do you see how effortless that was? WordPress is instantiated proper in my web page. Then I instruct the web page to simply call the header and footer capabilities of WordPress.</p><p>The header and footer capabilities give all the things I need to have for the template of my WordPress web site. It quickly populates the HTML, CSS, and any Javascript up on prime, and on the base it closes any tags that ended up open up.</p><p><b>Summary</b></p><p>Allow PHP do the perform. There is no need to have to replicate the WordPress code in pure HTML when you can have it generated quickly by WordPress alone.</p><p>The additional gain is that if the principal WordPress web site layout at any time improvements, the template wrapping your custom made PHP code will mirror those improvements immediately.</p></div><p> By <a>Paul Markovich</a></p></div></div></div><div class="single_tags clearfix"><div class="tags_text"><h5>Tags:</h5> <a href="https://accoladedigital.com/tag/how-to-make-a-blog/" rel="tag">how to make a blog</a>, <a href="https://accoladedigital.com/tag/how-to-make-a-website-2017/" rel="tag">how to make a website 2017</a>, <a href="https://accoladedigital.com/tag/how-to-make-a-wordpress-website/" rel="tag">how to make a wordpress website</a>, <a href="https://accoladedigital.com/tag/make-a-wordpress-website/" rel="tag">make a wordpress website</a>, <a href="https://accoladedigital.com/tag/wordpress/" rel="tag">wordpress</a></div></div><div class="icon_social_holder"><div class="blog_share qode_share"><div class="social_share_holder"><a href="javascript:void(0)" target="_self"><i class="icon-basic-share social_share_icon"></i><span class="social_share_title">Share</span></a><div class="social_share_dropdown"><div class="inner_arrow"></div><ul><li class="facebook_share"><a href="javascript:void(0)" onclick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=Integrating+WordPress+Into+PHP+Scripts&p[url]=https%3A%2F%2Faccoladedigital.com%2Fintegrating-wordpress-into-php-scripts%2F&p[images][0]=https://accoladedigital.com/wp-content/uploads/2017/07/how-to-put-in-ruby-on-rails-mysql2-gem-on-home-windows-10.jpg&p[summary]=Overview+Now%2C+I+had+to+use+a+custom+made+PHP+script+that+I+established+a+though+in+the+past+in+a+new+WordPress+application.+Rather+of+creating+a+WordPress+plugin+to+take+care+of+this+existing+code%2C+I+pick+out+instead+to+use+WordPress+directly...', 'sharer', 'toolbar=0,status=0,width=620,height=280');"><img itemprop="image" src="https://accoladedigital.com/wp-content/uploads/2017/08/Facebook-icon.jpg" alt="" /></a></li><li class="twitter_share"><a href="#" onclick="popUp=window.open('http://twitter.com/home?status=Overview+Now%2C+I+had+to+use+a+custom+made+PHP+script+that+I+established+a+though+in+the+past+in+a+new+WordPress+https://accoladedigital.com/integrating-wordpress-into-php-scripts/', 'popupwindow', 'scrollbars=yes,width=800,height=400');popUp.focus();return false;"><img itemprop="image" src="https://accoladedigital.com/wp-content/uploads/2017/08/twitter-icon.jpg" alt="" /></a></li><li class="google_share"><a href="#" onclick="popUp=window.open('https://plus.google.com/share?url=https%3A%2F%2Faccoladedigital.com%2Fintegrating-wordpress-into-php-scripts%2F', 'popupwindow', 'scrollbars=yes,width=800,height=400');popUp.focus();return false"><img itemprop="image" src="https://accoladedigital.com/wp-content/uploads/2017/08/google-icon.jpg" alt="" /></a></li><li class="linkedin_share"><a href="#" onclick="popUp=window.open('http://linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Faccoladedigital.com%2Fintegrating-wordpress-into-php-scripts%2F&title=Integrating+WordPress+Into+PHP+Scripts', 'popupwindow', 'scrollbars=yes,width=800,height=400');popUp.focus();return false"><img itemprop="image" src="https://accoladedigital.com/wp-content/uploads/2017/08/Linkedin-icon.png" alt="" /></a></li></ul></div></div></div><div class="qode_print"> <a href="#" onClick="window.print();return false;" class="qode_print_page"> <span class="icon-basic-printer qode_icon_printer"></span> <span class="eltd-printer-title">Print page</span> </a></div><div class="qode_like"><a href="#" class="qode-like" id="qode-like-10340" title="Like this">0<span> Likes</span></a></div></div></article><div class="comment_holder clearfix" id="comments"><div class="comment_number"><div class="comment_number_inner"><h5>No Comments</h5></div></div><div class="comments"></div></div><div class="comment_pager"><p></p></div><div class="comment_form"><div id="respond" class="comment-respond"><h3 id="reply-title" class="comment-reply-title"><h5>Post A Comment</h5> <small><a rel="nofollow" id="cancel-comment-reply-link" href="/integrating-wordpress-into-php-scripts/#respond" style="display:none;">Cancel Reply</a></small></h3><p class="must-log-in">You must be <a href="https://accoladedigital.com/wp-login.php?redirect_to=https%3A%2F%2Faccoladedigital.com%2Fintegrating-wordpress-into-php-scripts%2F">logged in</a> to post a comment.</p></div></div></div></div></div></div></div><footer ><div class="footer_inner clearfix"><div class="footer_bottom_holder"><div class="footer_bottom"><div class="textwidget"><div style="text-align: center;"> Copyright © 2017 | Legal <a href="https://accoladedigital.com/imprint/" target="_self">IMPRINT</a> | Our <a href="https://accoladedigital.com/terms-and-conditions/" target="_self">TOS</a> | <a href="https://accoladedigital.com/privacy-policy/" target="_self">Privacy</a> | Powered by <a href="http://aggieshost.com/" target="_blank">Blue1Hosting</a> | Designed by <em><strong>AccoladeDigital</strong></em> | <a href="https://accoladedigital.com/sitemap/">Sitemap</a> | <a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Faccoladedigital.com%2F&src=sdkpreparse">Share</a> | <span style="vertical-align:sub;"><script src="https://apis.google.com/js/platform.js" async defer></script> <g:plusone size="medium"></g:plusone></span> | <a class="twitter-share-button" target="_blank" href="https://twitter.com/intent/tweet">Tweet</a></div></div></div></div></div></div></footer></div></div> <script type="text/javascript">var c = document.body.className; c = c.replace(/woocommerce-no-js/, 'woocommerce-js'); document.body.className = c;</script> <script type='text/javascript'>var wpcf7 = {"apiSettings":{"root":"https:\/\/accoladedigital.com\/wp-json\/contact-form-7\/v1","namespace":"contact-form-7\/v1"},"recaptcha":{"messages":{"empty":"Please verify that you are not a robot."}},"cached":"1"};</script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=5.0.3'></script> <script type='text/javascript'>var qodeLike = {"ajaxurl":"https:\/\/accoladedigital.com\/wp-admin\/admin-ajax.php"};</script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/qode-like.min.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/plugins.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/jquery.carouFredSel-6.2.1.min.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/lemmon-slider.min.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/jquery.fullPage.min.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/jquery.mousewheel.min.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/jquery.touchSwipe.min.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/plugins/js_composer/assets/lib/bower/isotope/dist/isotope.pkgd.min.js?ver=4.12'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/jquery.stretch.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/default_dynamic.js?ver=1509379146'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/default.min.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/custom_js.js?ver=1509379146'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-includes/js/comment-reply.min.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/plugins/js_composer/assets/js/dist/js_composer_front.min.js?ver=4.12'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/themes/bridge/js/woocommerce.js?ver=4.9.8'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-content/plugins/woocommerce/assets/js/select2/select2.full.min.js?ver=4.0.3'></script> <script type='text/javascript' src='https://accoladedigital.com/wp-includes/js/wp-embed.min.js?ver=4.9.8'></script> <div id="cookie-notice" role="banner" class="cn-bottom bootstrap" style="color: #fff; background-color: #000;"><div class="cookie-notice-container"><span id="cn-notice-text">We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.</span><a href="#" id="cn-accept-cookie" data-cookie-set="accept" class="cn-set-cookie cn-button bootstrap button">Ok</a></div></div></body></html>